Skip to content

fix(cli): auto-detect sandbox name from registry in nemoclaw debug (#1728) - #1878

Merged
cv merged 3 commits into
NVIDIA:mainfrom
ColinM-sys:fix/1728-debug-sandbox-autodetect
Apr 14, 2026
Merged

fix(cli): auto-detect sandbox name from registry in nemoclaw debug (#1728)#1878
cv merged 3 commits into
NVIDIA:mainfrom
ColinM-sys:fix/1728-debug-sandbox-autodetect

Conversation

@ColinM-sys

@ColinM-sys ColinM-sys commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detectSandboxName() in src/lib/debug.ts now checks the local registry (sandboxes.json) for defaultSandbox before falling back to openshell sandbox list and then the hardcoded "default".

Fixes #1728.

Why

nemoclaw debug --quick always collected diagnostics for a sandbox named "default" because detectSandboxName() only tried openshell sandbox list (which may return nothing or time out) and then fell back to the literal string "default". The user's actual sandbox (e.g. "my-assistant") was ignored. The docs say sandbox name is "auto-detected" but the implementation never checked the authoritative source — the local registry.

Test plan

  • npm run build:cli — compiles cleanly.
  • Manual: nemoclaw debug --quick with a sandbox named anything other than "default" — should now target the correct sandbox.

Summary by CodeRabbit

  • Bug Fixes
    • Sandbox detection now prefers local registry configuration over live gateway probing, falls back to previous discovery methods when local data is missing or fails, and includes more robust error handling to avoid incorrect or missing sandbox names.

Signed-off-by: ColinM-sys cmcdonough@50words.com

@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

detectSandboxName() in src/lib/debug.ts now attempts to read the local sandbox registry via listSandboxes() first (returning registry.defaultSandbox or the first non-empty sandbox name). If registry access fails or yields no name, it falls back to the prior openshell sandbox list gateway probing and then "default".

Changes

Cohort / File(s) Summary
Sandbox Detection Enhancement
src/lib/debug.ts
Import listSandboxes from ./registry. detectSandboxName() now tries local registry lookup inside a try/catch, returning registry.defaultSandbox or first non-empty registry.sandboxes entry; on error or no result, falls back to existing openshell sandbox list probing and final "default" fallback.

Sequence Diagram(s)

sequenceDiagram
    actor DebugModule as Debug
    participant Registry as Registry (listSandboxes)
    participant Shell as Openshell CLI
    Debug->>Registry: call listSandboxes()
    alt registry returns defaultSandbox or sandbox name
        Registry-->>Debug: defaultSandbox / first sandbox name
        Debug-->>Debug: return sandbox name
    else registry fails or returns no names
        Registry--xDebug: throws / empty
        Debug->>Shell: run "openshell sandbox list"
        Shell-->>Debug: parsed sandbox name or empty
        alt Shell returns name
            Debug-->>Debug: return parsed name
        else no name
            Debug-->>Debug: return "default"
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I peeked through registry leaves so bright,

Found a sandbox name by morning light.
If the clouds hide it, I nudge the shell's song,
Then hop home happy, no default for long. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: auto-detecting sandbox name from registry in the debug command, which directly addresses the issue.
Linked Issues check ✅ Passed The PR directly addresses issue #1728 by implementing registry-based sandbox auto-detection with proper fallback logic, matching the expected behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to the debug sandbox name detection logic in src/lib/debug.ts, with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/lib/debug.ts (1)

153-155: Optional hardening: trim registry names before returning.

A whitespace-only defaultSandbox or sandbox name from malformed config would currently pass through as a target value.

Suggested hardening patch
-    if (registry.defaultSandbox) return registry.defaultSandbox;
-    const names = registry.sandboxes.map((s) => s.name).filter(Boolean);
-    if (names.length > 0) return names[0];
+    const defaultName = registry.defaultSandbox?.trim();
+    if (defaultName) return defaultName;
+    const firstName = registry.sandboxes
+      .map((s) => s.name.trim())
+      .find((name) => name.length > 0);
+    if (firstName) return firstName;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/debug.ts` around lines 153 - 155, The registry selection logic should
trim whitespace-only names before returning them: when checking
registry.defaultSandbox, trim it and return only if the trimmed value is
non-empty; when building names from registry.sandboxes (used in the names
variable), map each s.name to its trimmed value and filter out
empty/whitespace-only strings (e.g., filter by trimmed truthiness) so you return
the first valid trimmed name. Update checks around registry.defaultSandbox and
the names array generation to operate on trimmed strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/lib/debug.ts`:
- Around line 153-155: The registry selection logic should trim whitespace-only
names before returning them: when checking registry.defaultSandbox, trim it and
return only if the trimmed value is non-empty; when building names from
registry.sandboxes (used in the names variable), map each s.name to its trimmed
value and filter out empty/whitespace-only strings (e.g., filter by trimmed
truthiness) so you return the first valid trimmed name. Update checks around
registry.defaultSandbox and the names array generation to operate on trimmed
strings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 85fc1387-6de5-45c1-844c-1f2c7e2e0637

📥 Commits

Reviewing files that changed from the base of the PR and between 855924f and e7f2df8.

📒 Files selected for processing (1)
  • src/lib/debug.ts

@cjagwani cjagwani self-assigned this Apr 14, 2026
@cjagwani
cjagwani requested review from brandonpelfrey and cv April 14, 2026 23:22
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: NVIDIA#1728
Signed-off-by: ColinM-sys <cmcdonough@50words.com>
@ColinM-sys
ColinM-sys force-pushed the fix/1728-debug-sandbox-autodetect branch from 56a29d8 to cab00a6 Compare April 14, 2026 23:26
@cjagwani

Copy link
Copy Markdown
Collaborator

@ColinM-sys DCO check will fail on this one too — add this line to your PR description:

Signed-off-by: Your Name <your@email.com>

Code looks good, ready to merge once DCO passes.

@ColinM-sys

Copy link
Copy Markdown
Contributor Author

Thank you so much — added the sign-off to the PR description here too!

@cv
cv merged commit 8fac9d6 into NVIDIA:main Apr 14, 2026
12 of 13 checks passed
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[All Platforms] nemoclaw debug defaults to sandbox name 'default' but docs say it "auto-detects"

4 participants