From cab00a68518b7bdc051c2f4dd72eafb120ed95ef Mon Sep 17 00:00:00 2001 From: ColinM-sys Date: Tue, 14 Apr 2026 14:01:33 -0400 Subject: [PATCH] fix(cli): auto-detect sandbox name from registry in nemoclaw debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit detectSandboxName() fell back to the hardcoded string "default" when openshell sandbox list returned nothing or wasn't available. This meant `nemoclaw debug --quick` always targeted a sandbox named "default" even when the user's sandbox was named "my-assistant" or anything else — producing diagnostics for a non-existent sandbox. Check the local registry (sandboxes.json) first, which knows the user's defaultSandbox from onboard. Only fall back to the openshell probe and then "default" if the registry is empty or unreadable. Refs: #1728 Signed-off-by: ColinM-sys --- src/lib/debug.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/debug.ts b/src/lib/debug.ts index 19bb7d64e3e..aa898cf443f 100644 --- a/src/lib/debug.ts +++ b/src/lib/debug.ts @@ -7,6 +7,7 @@ import { platform, tmpdir } from "node:os"; import { basename, dirname, join } from "node:path"; import { DASHBOARD_PORT } from "./ports"; +import { listSandboxes } from "./registry"; // --------------------------------------------------------------------------- // Types @@ -141,6 +142,22 @@ function collectShell(collectDir: string, label: string, shellCmd: string): void // --------------------------------------------------------------------------- function detectSandboxName(): string { + // First, check the local registry for the default sandbox. This is + // the authoritative source — it reflects the user's actual onboard + // choices and survives gateway restarts. Falling back to "default" + // without checking the registry was the bug in #1728: debug always + // targeted a sandbox named "default" even though the user's sandbox + // was named something else (e.g. "my-assistant"). + try { + const registry = listSandboxes(); + if (registry.defaultSandbox) return registry.defaultSandbox; + const names = registry.sandboxes.map((s) => s.name).filter(Boolean); + if (names.length > 0) return names[0]; + } catch { + /* registry unreadable — fall through to openshell probe */ + } + + // Fallback: ask the live gateway directly if (!commandExists("openshell")) return "default"; try { const output = execFileSync("openshell", ["sandbox", "list"], {