diff --git a/network-poc/frontend/src/pages/index.astro b/network-poc/frontend/src/pages/index.astro
index 8ff9bfe..3e9ebfd 100644
--- a/network-poc/frontend/src/pages/index.astro
+++ b/network-poc/frontend/src/pages/index.astro
@@ -207,17 +207,9 @@ import AgentBar from "../components/AgentBar.astro";
termPanel.scrollTop = termPanel.scrollHeight;
try {
- // Varmistetaan solmu
- if (!wasmNodeStarted) {
- statusDiv.innerHTML = ' → Käynnistetään laskentasolmua...';
- await ensureNode();
- // Odotetaan kunnes malli on latautunut tai 60s
- for (let i = 0; i < 120 && !llmReady; i++) await new Promise(r => setTimeout(r, 500));
- if (!llmReady) {
- statusDiv.innerHTML = ' ✗ Mallin lataus aikakatkaistiin';
- return null;
- }
- }
+ // Ei odotetaan Wasmia — lähetetään suoraan hubille.
+ // Jos hub löytää natiivisolmun, vastaus tulee nopeasti.
+ // Jos 503, käynnistetään Wasm-fallback.
if (!silent) {
const streamDiv = document.createElement('div');
@@ -236,6 +228,15 @@ import AgentBar from "../components/AgentBar.astro";
body: JSON.stringify({ model, prompt, task_id: taskId }),
});
+ if (res.status === 503 && !wasmNodeStarted) {
+ // Ei natiivisolmua — käynnistetään Wasm-fallback
+ statusDiv.innerHTML = ' → Ei natiivisolmua — käynnistetään selainlaskenta...';
+ await ensureNode();
+ for (let i = 0; i < 120 && !llmReady; i++) await new Promise(r => setTimeout(r, 500));
+ if (!llmReady) { statusDiv.innerHTML = ' ✗ Mallin lataus aikakatkaistiin'; return null; }
+ // Yritetään uudelleen
+ return kpnRun(model, prompt, silent);
+ }
if (!res.ok) {
const err = await res.text().catch(() => res.statusText);
statusDiv.innerHTML = ` ✗ ${esc(err)}`;