diff --git a/network-poc/frontend/src/pages/index.astro b/network-poc/frontend/src/pages/index.astro index 134dcb7..53317ba 100644 --- a/network-poc/frontend/src/pages/index.astro +++ b/network-poc/frontend/src/pages/index.astro @@ -167,7 +167,7 @@ import AgentBar from "../components/AgentBar.astro"; const uiSocket = new WebSocket(wsUrl); window._uiSocket = uiSocket; - uiSocket.onopen = () => { + uiSocket.onopen = async () => { document.getElementById('hub-dot').style.background = '#3fb950'; document.getElementById('hub-label').textContent = 'Yhdistetty'; document.getElementById('hub-label').style.color = '#3fb950'; @@ -177,6 +177,31 @@ import AgentBar from "../components/AgentBar.astro"; platform: navigator.platform || '', cpu_cores: navigator.hardwareConcurrency || 0, device_memory_gb: navigator.deviceMemory || 0, allocated_gb: 0, selected_task: 'viewer', })); + // Tarkistetaan onko natiivisolmu jo hubissa + try { + const res = await fetch('/api/v1/chat/completions', { + method: 'POST', headers: {'Content-Type':'application/json'}, + body: JSON.stringify({ model: 'qwen-coder', prompt: 'ping', task_id: 'status-check' }), + signal: AbortSignal.timeout(3000), + }); + if (res.status !== 503) { + // Solmu löytyi (natiivi tai Wasm) + document.getElementById('compute-dot').style.background = '#3fb950'; + document.getElementById('compute-label').textContent = 'Valmis (natiivi)'; + document.getElementById('compute-label').style.color = '#3fb950'; + document.getElementById('compute-btn').textContent = '✓ Valmis'; + document.getElementById('compute-btn').className = 'btn btn-green'; + llmReady = true; + } + } catch(e) { + // Timeout = solmu on olemassa mutta laskee — se on ok + document.getElementById('compute-dot').style.background = '#3fb950'; + document.getElementById('compute-label').textContent = 'Valmis (natiivi)'; + document.getElementById('compute-label').style.color = '#3fb950'; + document.getElementById('compute-btn').textContent = '✓ Valmis'; + document.getElementById('compute-btn').className = 'btn btn-green'; + llmReady = true; + } }; uiSocket.onclose = () => { document.getElementById('hub-dot').style.background = '#f85149'; @@ -277,10 +302,7 @@ import AgentBar from "../components/AgentBar.astro"; ensureNode(); }); - // Autostart - if (localStorage.getItem('kpn-coder-loaded') === 'true') { - setTimeout(() => ensureNode(), 300); - } + // Wasm-autostart vain jos natiivisolmua ei löydy (tarkistetaan onopen:ssa) // === kpnRun: lähettää promptin mallille === const activeStreams = {};