Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"], {
Expand Down
Loading