From f7e0e8dff8593bedcecf6694e74e19465272c9a2 Mon Sep 17 00:00:00 2001 From: Jaakko Vanhala Date: Thu, 9 Apr 2026 21:48:23 +0300 Subject: [PATCH] =?UTF-8?q?Status-palkki=20tunnistaa=20natiivisolmun:=20ei?= =?UTF-8?q?=20en=C3=A4=C3=A4=20turhaa=20Wasm-latausta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sivulatauksessa tarkistetaan onko hubissa jo laskentasolmu (natiivi/Wasm). Jos on → "Valmis (natiivi)", llmReady=true, ei Wasm-latausta. Jos 503 → Wasm-fallback "Alusta"-napista. Poistettu automaattinen Wasm-käynnistys (ensureNode) sivulatauksessa koska natiivisolmu hoitaa laskennan. Co-Authored-By: Claude Opus 4.6 (1M context) --- network-poc/frontend/src/pages/index.astro | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) 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 = {};