From dc7dc75bccc444935154a0c1ddbee176f051b456 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Sun, 4 Oct 2026 17:39:53 +0200 Subject: [PATCH] fix(theseus/ariadne): toggle every Ariadne task regardless of install scope User report (2026-10-04): "Plug-Ins/Ariadne's Thread is not working properly, it doesn't switch on / off the daemon. Other PC can't turn it on, and other browsers on it don't recognize BNS names." Root cause. ariadneSetState's elevated script hard-coded two names, 'BNS Resolver Daemon' and 'BNS Sia Bridge'. Those are the pre-0.2 names and the All-users / All-browsers compat names. A machine that received a fresh 0.2.0 install under Just-me scope has NO task with either of those names -- the resolver there is 'Ariadne BNS Resolver ()' and the indexer is 'Ariadne BNS Indexer ()'. The toggle silently did nothing (exit 2 handling returned 'no BNS Resolver Daemon'), and the panel's state query -- which already knows about 'Ariadne BNS Indexer' -- still displayed the previous state because it was reading the correct task but nothing had actually started it. Fix. The inner script now enumerates scheduled tasks dynamically and anchors a regex at: ^(Ariadne BNS Indexer |Ariadne BNS Indexer \(.+\) |Ariadne BNS Resolver \(.+\) |BNS Resolver Daemon |BNS Sia Bridge)$ That hits every Ariadne task across all three install schemes without touching the user's own unrelated 'BNS Indexer' task (which has no 'Ariadne' prefix -- memory://ariadne-task-names). Enable/Start (or Stop/Disable) runs against each match; exit code is: 0 = at least one task accepted the verb 2 = no Ariadne task found at all (needs reinstall) 3 = tasks found but none accepted (surface in a clearer error) Note. Full 0.2.0 integration (named-pipe IPC via Argus/src/lib/bns-pipe.js, scope-aware policy.json path) ships via step 3 on branch claude/agitated-bell-bd4ac2 (see TheseusNavigator/DESIGN-bns-indexer-service.md). This commit fixes the specific toggle bug on master so the user's "can't turn it on" symptom is resolved WITHOUT waiting for that larger merge. The 0.1.13 settings-panel sections (collision policy / sources / status-report via http://127.0.0.1/api/status) still display 'Daemon unreachable' honestly on 0.2.0 installs; they'll be superseded by the pipe-based status feed when step 3 lands. --- main.js | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/main.js b/main.js index 80623adf..ead3e359 100644 --- a/main.js +++ b/main.js @@ -7100,20 +7100,31 @@ function ariadneSetState(on) { // the elevated shell ever saw it — the elevated shell got // `foreach ( in ...)`, failed to parse, and the outer shell still exited // 0, so the toggle reported success while doing nothing. - const inner = on - ? `$ok = $true -foreach ($t in 'BNS Resolver Daemon','BNS Sia Bridge') { - try { Enable-ScheduledTask -TaskName $t -ErrorAction Stop | Out-Null; Start-ScheduledTask -TaskName $t -ErrorAction Stop } - catch { if ($t -eq 'BNS Resolver Daemon') { $ok = $false } } + // Scope-aware: Ariadne 0.2.0 renamed tasks per install scope. + // All users: 'Ariadne BNS Indexer' + 'BNS Resolver Daemon' (kept for compat) + // Just me: 'Ariadne BNS Indexer ()' + 'Ariadne BNS Resolver ()' + // pre-0.2: 'BNS Resolver Daemon' + 'BNS Sia Bridge' + // Enumerate all Ariadne-owned tasks dynamically by DisplayName pattern so + // we hit whichever scheme is on disk; previously the toggle only acted on + // 'BNS Resolver Daemon' and silently did nothing on Just-me 0.2.0 installs + // -- user visible as "panel toggle has no effect". exit codes: + // 0 = at least one task was started/stopped + // 2 = no Ariadne task found at all (needs reinstall) + // 3 = tasks found but none accepted the start/stop verb + const action = on + ? `Enable-ScheduledTask -TaskName $n -ErrorAction SilentlyContinue | Out-Null; Start-ScheduledTask -TaskName $n -ErrorAction Stop` + : `Stop-ScheduledTask -TaskName $n -ErrorAction SilentlyContinue; Disable-ScheduledTask -TaskName $n -ErrorAction Stop | Out-Null`; + const inner = `$found = $false; $ok = $false +# Match every Ariadne-owned task name regardless of scope. The anchored +# patterns deliberately exclude the user's own unrelated 'BNS Indexer' task +# (ChipnetData chain indexer) which has no 'Ariadne' prefix. +$pat = '^(Ariadne BNS Indexer|Ariadne BNS Indexer \\(.+\\)|Ariadne BNS Resolver \\(.+\\)|BNS Resolver Daemon|BNS Sia Bridge)$' +foreach ($task in (Get-ScheduledTask -ErrorAction SilentlyContinue | Where-Object { $_.TaskName -match $pat })) { + $found = $true + $n = $task.TaskName + try { ${action}; $ok = $true } catch {} } -if ($ok) { exit 0 } else { exit 2 }` - : `$ok = $true -foreach ($t in 'BNS Resolver Daemon','BNS Sia Bridge') { - try { Stop-ScheduledTask -TaskName $t -ErrorAction Stop } catch {} - try { Disable-ScheduledTask -TaskName $t -ErrorAction Stop | Out-Null } - catch { if ($t -eq 'BNS Resolver Daemon') { $ok = $false } } -} -if ($ok) { exit 0 } else { exit 2 }`; +if ($ok) { exit 0 } elseif ($found) { exit 3 } else { exit 2 }`; const encoded = Buffer.from(inner, "utf16le").toString("base64"); // -PassThru + exit $p.ExitCode: the elevated shell's exit code (0 ok, // 2 = daemon task missing) reaches us; a declined UAC prompt makes @@ -7122,7 +7133,8 @@ if ($ok) { exit 0 } else { exit 2 }`; `$p = Start-Process powershell -Verb RunAs -Wait -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded}'; exit $p.ExitCode`], { windowsHide: true }); ps.on("close", (code) => { if (code === 0) resolve(true); - else if (code === 2) reject(new Error("the 'BNS Resolver Daemon' scheduled task is missing — reinstall Ariadne's Thread")); + else if (code === 2) reject(new Error("no Ariadne scheduled task found — reinstall Ariadne's Thread")); + else if (code === 3) reject(new Error("Ariadne tasks exist but none accepted start/stop — check task state in Task Scheduler")); else reject(new Error("UAC declined or task failed (exit " + code + ")")); }); ps.on("error", (e) => reject(e));