fix(sessions): hide onboard warm-up session from list and export#5533
Conversation
Signed-off-by: Rui Luo <ruluo@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughShared warmup-session prefixes now drive warm-up tagging, export and sessions list output hide warm-up sessions, and the related CLI text and OpenShell wrapper were updated. ChangesWarmup Session Filtering
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
prekshivyas
left a comment
There was a problem hiding this comment.
Correct. captureOpenshell is synchronous so the call at line 782 needs no await. filterWarmupSessionsListJson failing closed when it can't parse but a warm-up id is present is the right safety invariant. The includeStreams opt-in on the openshell client is additive and backward-compatible.
Two minor notes: (1) filterWarmupSessionsListPayload probes sessions, entries, and items but the tests only cover the sessions key — low risk since that's the live key, but a quick fixture for the other two paths would guard future format changes. (2) filterWarmupSessionsListText anchors on id:${WARMUP_SESSION_ID_PREFIX} — this is correct for the current OpenClaw text format but is format-fragile; a comment noting the dependency on the id: field label would help future maintainers.
Otherwise coverage is solid: fail-closed path, noisy-output tolerance, explicit-key bypass, and text count adjustment are all exercised.
Approve.
…anup Signed-off-by: Rui Luo <ruluo@nvidia.com> # Conflicts: # src/lib/actions/sandbox/sessions/export.test.ts # src/lib/actions/sandbox/sessions/export.ts
…anup Signed-off-by: Rui Luo <ruluo@nvidia.com> # Conflicts: # src/lib/actions/sandbox/sessions/export.test.ts
daafce2 to
2d43aae
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/sandbox-sessions-export-cli.test.ts (1)
71-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid keying JSON extraction to a hard-coded warning prefix.
Line 73 only parses correctly while stderr begins with
warning:. If the non-fatal message text changes,indexOf("\nwarning:")becomes-1and this test fails for the wrong reason. Parse the JSON portion independently of the warning text instead.Suggested change
- expect(result.out).toContain("warning: noisy but non-fatal"); - expect(result.out).not.toContain("nemoclaw-onboard-warmup-"); - expect(JSON.parse(result.out.slice(0, result.out.indexOf("\nwarning:")))).toEqual({ + expect(result.out).toContain("warning: noisy but non-fatal"); + expect(result.out).not.toContain("nemoclaw-onboard-warmup-"); + const jsonLine = result.out + .split("\n") + .find((line) => line.trimStart().startsWith("{")); + expect(jsonLine).toBeDefined(); + expect(JSON.parse(jsonLine!)).toEqual({ count: 1, totalCount: 1, sessions: [{ key: "agent:main:explicit:real", sessionId: "sid-real" }], });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/sandbox-sessions-export-cli.test.ts` around lines 71 - 73, The test in sandbox-sessions-export-cli.test.ts is too tightly coupled to the warning text by slicing stdout at a hard-coded warning prefix; update the JSON extraction in the sandbox-sessions export CLI test to locate the JSON payload independently of the warning message so it still parses correctly if the warning text changes. Use the existing result.out assertions in this test and replace the indexOf("\nwarning:") approach with a delimiter or structure based on the JSON output itself.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/sandbox-sessions-export-cli.test.ts`:
- Around line 71-73: The test in sandbox-sessions-export-cli.test.ts is too
tightly coupled to the warning text by slicing stdout at a hard-coded warning
prefix; update the JSON extraction in the sandbox-sessions export CLI test to
locate the JSON payload independently of the warning message so it still parses
correctly if the warning text changes. Use the existing result.out assertions in
this test and replace the indexOf("\nwarning:") approach with a delimiter or
structure based on the JSON output itself.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 6fd25d55-a0e8-4715-a08e-06d1c9379bd0
📒 Files selected for processing (7)
src/commands/sandbox/sessions.tssrc/commands/sandbox/sessions/export.tssrc/commands/sandbox/sessions/list.tssrc/lib/actions/sandbox/sessions/passthrough.test.tssrc/lib/actions/sandbox/sessions/passthrough.tssrc/lib/actions/sandbox/warmup-session.tstest/sandbox-sessions-export-cli.test.ts
✅ Files skipped from review due to trivial changes (3)
- src/commands/sandbox/sessions/export.ts
- src/commands/sandbox/sessions.ts
- src/commands/sandbox/sessions/list.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/lib/actions/sandbox/warmup-session.ts
- src/lib/actions/sandbox/sessions/passthrough.test.ts
- src/lib/actions/sandbox/sessions/passthrough.ts
Manual PR Review Advisor resultThis PR Review Advisor analysis was run manually via Run: https://github.com/NVIDIA/NemoClaw/actions/runs/28210598269 Recommendation:
PR Review AdvisorThe diff addresses the linked warm-up session visibility bug with focused filtering, security-sensitive command boundaries remain constrained, and the changed behavior has targeted unit plus CLI-stub coverage. Required before merge
Resolve or justify before merge
In-scope improvements
Test follow-ups to resolve or justify
What looks good
|
…DIA#5533) <!-- markdownlint-disable MD041 --> ## Summary <!-- 1-3 sentences: what this PR does and why. --> `nemoclaw onboard` runs a throwaway scope-upgrade warm-up that persists an internal `nemoclaw-onboard-warmup-*` session. On a freshly-onboarded sandbox that session is the only entry, so `nemoclaw <name> sessions list` reported 1 conversation and `sessions export` bundled a `"ping"` the user never sent. This filters that internal session out of the NemoClaw user-facing surfaces — `sessions list`, `sessions list --json`, and `sessions export`. ## Related Issue <!-- Fixes #NNN or Closes #NNN. Remove this section if none. --> Fixes NVIDIA#5511 ## Changes <!-- Bullet list of key changes. --> - **`src/lib/actions/sandbox/warmup-session.ts`** (new): single source of truth — `WARMUP_SESSION_ID_PREFIX` + `isWarmupSessionId`. - **`src/lib/actions/sandbox/sessions/passthrough.ts`**: capture `sessions list` and filter internal warm-up sessions from both human-table output (`filterWarmupSessionsListText`, anchored on the `id:` field) and `--json` (`filterWarmupSessionsListJson`, tolerant balanced-JSON parse reusing `parseSessionIndex`; **fails closed** — errors rather than emitting unfiltered output if it can't parse but a warm-up id is present). stdout is filtered; OpenClaw's stderr is preserved on its own stream. - **`src/lib/actions/sandbox/sessions/export.ts`**: exclude warm-up sessions from "export all" (explicit `--keys` still honored); harden `parseSessionIndex` with balanced-JSON extraction for multi-line payloads. - **`src/lib/adapters/openshell/client.ts` + `runtime.ts`**: opt-in `includeStreams` option exposing separate `stdout`/`stderr` on the capture result (additive, backward-compatible). - **`src/lib/actions/sandbox/auto-pair-warmup.ts`**: reference the shared prefix in `--session-id` only — **no change to warm-up timing/behavior**. - Tests: `passthrough.test.ts` (new), `client.test.ts` (new), and updates to `export.test.ts` / `auto-pair-warmup.test.ts`. ## Type of Change - [√] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification <!-- Check each item you ran and confirmed. Leave unchecked items you skipped. Doc-only changes do not require npm test unless you ran it. --> - [√] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [√] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [√] Targeted tests pass for changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [√] Tests added or updated for new or changed behavior - [√] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [√] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off is required in this PR description, and every commit must appear as Verified in GitHub. Run: git config user.name && git config user.email --> Signed-off-by: rluo8 <ruluo@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Warm-up sessions are now automatically hidden from default session listing and export-all, while still retrievable when explicitly requested. * Improved robustness for parsing `sessions list` JSON output, including noisy or wrapped responses. * **Bug Fixes** * Export and passthrough filtering now reliably exclude warm-up sessions. * Session list counts are adjusted correctly after warm-up entries are removed. * **Documentation** * Updated CLI help text to reflect warm-up hiding behavior. * **Tests** * Added/expanded coverage for warm-up tagging, filtering, export behavior, and tolerant noisy JSON handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Rui Luo <ruluo@nvidia.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Julie Yaunches <jyaunches@nvidia.com>
Summary
nemoclaw onboardruns a throwaway scope-upgrade warm-up that persists an internalnemoclaw-onboard-warmup-*session. On a freshly-onboarded sandbox that session is the only entry, sonemoclaw <name> sessions listreported 1 conversation andsessions exportbundled a"ping"the user never sent. This filters that internal session out of the NemoClaw user-facing surfaces —sessions list,sessions list --json, andsessions export.Related Issue
Fixes #5511
Changes
src/lib/actions/sandbox/warmup-session.ts(new): single source of truth —WARMUP_SESSION_ID_PREFIX+isWarmupSessionId.src/lib/actions/sandbox/sessions/passthrough.ts: capturesessions listand filter internal warm-up sessions from both human-table output (filterWarmupSessionsListText, anchored on theid:field) and--json(filterWarmupSessionsListJson, tolerant balanced-JSON parse reusingparseSessionIndex; fails closed — errors rather than emitting unfiltered output if it can't parse but a warm-up id is present). stdout is filtered; OpenClaw's stderr is preserved on its own stream.src/lib/actions/sandbox/sessions/export.ts: exclude warm-up sessions from "export all" (explicit--keysstill honored); hardenparseSessionIndexwith balanced-JSON extraction for multi-line payloads.src/lib/adapters/openshell/client.ts+runtime.ts: opt-inincludeStreamsoption exposing separatestdout/stderron the capture result (additive, backward-compatible).src/lib/actions/sandbox/auto-pair-warmup.ts: reference the shared prefix in--session-idonly — no change to warm-up timing/behavior.passthrough.test.ts(new),client.test.ts(new), and updates toexport.test.ts/auto-pair-warmup.test.ts.Type of Change
Verification
Verifiedin GitHubnpx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes only)Signed-off-by: rluo8 ruluo@nvidia.com
Summary by CodeRabbit
New Features
sessions listJSON output, including noisy or wrapped responses.Bug Fixes
Documentation
Tests