From 146cee08ec9c4313bec5f69bb7ed7fbf73770aac Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Mon, 5 Oct 2026 09:33:45 +0200 Subject: fix: read the node token per call and detect before polling the index dock node:op only knew the daemon's token once a page had called detect(), and kept it after the daemon replaced it on restart: the index dock stayed empty on a node machine until the Node page was opened, every operation answered 401 after a node restart, and on a machine without a node each 30 s poll was a rejected IPC call Electron printed to the terminal ("Node not detected"). node:op now reads the config and token from disk on every call, and the dock asks detect() before its first operation and after any failure. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-hub/src/meshbay_hub/static/index-dock.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'packages/meshbay-hub/src') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js b/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js index 6730e60..6c89eb6 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js @@ -51,9 +51,18 @@ function useLoopbackActivity() { let stopped = false; let timer = null; let last = ''; + // Asked before the first operation and again after any failure: detect() + // answers "no node" as a value, where an operation on an absent node is a + // rejected IPC call that Electron prints to its terminal on every poll. + let present = false; const poll = async () => { let delay = IDLE_POLL_MS; try { + if (!present) { + const found = await platform.node.detect(); + if (!found || !found.detected) throw new Error('no node'); + present = true; + } const data = await platform.node.op('indexStatus'); const next = {}; for (const g of (data && data.groups) || []) next[g.group_id] = fromLoopback(g); @@ -64,6 +73,7 @@ function useLoopbackActivity() { if (!stopped && text !== last) { last = text; setLocal(next); } } catch { // No node on this machine, or one older than the route. + present = false; if (!stopped && last !== '{}') { last = '{}'; setLocal({}); } delay = ABSENT_POLL_MS; } -- cgit v1.2.3