aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-05 09:33:45 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-05 09:33:45 +0200
commit146cee08ec9c4313bec5f69bb7ed7fbf73770aac (patch)
treebc2aa524868d55869625ef4cd78b1f8300e28300 /packages/meshbay-hub
parentcce8a911553597ada33e275bc9b29fd34121074d (diff)
downloadmeshbay-146cee08ec9c4313bec5f69bb7ed7fbf73770aac.tar.gz
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 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/index-dock.js10
1 files changed, 10 insertions, 0 deletions
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;
}