refactor(cli): extract onboard finalization handler#3876
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughExtracts inline end-of-onboarding logic into a new async handler ChangesOnboarding Finalization Handler Extraction
Sequence Diagram(s)sequenceDiagram
participant Onboard
participant FinalizationHandler
participant recordSessionComplete
participant verifyDeployment
participant printLiveDashboard
Onboard->>FinalizationHandler: call handleFinalizationState(options, deps)
FinalizationHandler->>recordSessionComplete: deps.recordSessionComplete(sessionUpdates)
FinalizationHandler->>verifyDeployment: deps.verifyDeployment(verifyChain)
verifyDeployment->>FinalizationHandler: verificationDiagnostics
FinalizationHandler->>printLiveDashboard: deps.printLiveDashboard(session, verificationDiagnostics)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
|
✨ Related open PRs: Related open issues: |
…lization-handler # Conflicts: # src/lib/agent/onboard.ts # src/lib/onboard.ts # src/lib/onboard/machine/events.ts # src/lib/onboard/machine/handlers/agent-setup.test.ts # src/lib/onboard/machine/handlers/agent-setup.ts # src/lib/onboard/machine/handlers/gateway.test.ts # src/lib/onboard/machine/handlers/gateway.ts # src/lib/onboard/machine/handlers/policies.test.ts # src/lib/onboard/machine/handlers/policies.ts # src/lib/onboard/machine/handlers/preflight.test.ts # src/lib/onboard/machine/handlers/preflight.ts # src/lib/onboard/machine/handlers/provider-inference.test.ts # src/lib/onboard/machine/handlers/provider-inference.ts # src/lib/onboard/machine/handlers/sandbox.test.ts # src/lib/onboard/machine/handlers/sandbox.ts # src/lib/onboard/machine/hooks.test.ts # src/lib/onboard/machine/hooks.ts # src/lib/onboard/machine/transitions.ts # src/lib/onboard/machine/types.ts # src/lib/state/onboard-session.test.ts # src/lib/state/onboard-session.ts
E2E Scenario Advisor RecommendationRequired scenario E2E: None Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
PR Review AdvisorFindings: 0 needs attention, 1 worth checking, 0 nice ideas Review findings🛠️ Needs attention
🔎 Worth checking
🌱 Nice ideas
Since last review detailsCurrent findings:
This is an automated advisory review. A human maintainer must make the final merge decision. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/onboard/machine/handlers/finalization.test.ts (1)
88-96: ⚡ Quick winAssert the call order claimed by the test name.
This case says forwarding happens before completion, but it only checks both were called. Add an explicit order assertion so the behavior is locked in.
Proposed test tightening
await handleFinalizationState({ ...baseOptions(deps), agent }); expect(calls.ensureAgentDashboard).toHaveBeenCalledWith("my-assistant", agent); + expect(calls.complete).toHaveBeenCalled(); + expect(calls.ensureAgentDashboard.mock.invocationCallOrder[0]).toBeLessThan( + calls.complete.mock.invocationCallOrder[0], + ); expect(calls.dashboard).toHaveBeenCalledWith("my-assistant", "model", "provider", null, agent);🤖 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 `@src/lib/onboard/machine/handlers/finalization.test.ts` around lines 88 - 96, The test needs to assert call order so forwarding happens before completion: in the "ensures agent dashboard forwarding before completion for non-OpenClaw agents" test (which calls handleFinalizationState), add an explicit order check between the mocks for ensureAgentDashboard and dashboard (e.g., compare their mock invocation order or use a toHaveBeenCalledBefore helper) so that calls.ensureAgentDashboard is asserted to have been invoked before calls.dashboard; update the expectation after the existing toHaveBeenCalledWith assertions to lock in the sequence.
🤖 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 `@src/lib/onboard/machine/handlers/finalization.test.ts`:
- Around line 88-96: The test needs to assert call order so forwarding happens
before completion: in the "ensures agent dashboard forwarding before completion
for non-OpenClaw agents" test (which calls handleFinalizationState), add an
explicit order check between the mocks for ensureAgentDashboard and dashboard
(e.g., compare their mock invocation order or use a toHaveBeenCalledBefore
helper) so that calls.ensureAgentDashboard is asserted to have been invoked
before calls.dashboard; update the expectation after the existing
toHaveBeenCalledWith assertions to lock in the sequence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 38249545-8e6a-48d4-a40a-911349c86a46
📒 Files selected for processing (3)
src/lib/onboard.tssrc/lib/onboard/machine/handlers/finalization.test.tssrc/lib/onboard/machine/handlers/finalization.ts
ericksoa
left a comment
There was a problem hiding this comment.
Adversarial review after the topper: the requested blocker is fixed by preserving the finalization session result and setting completed = true only after successful finalization. The unused handler parameter was removed, issue-ordering comments were restored, local build/typecheck/focused tests passed, and GitHub checks are green. CodeRabbit only left a non-blocking test-order nit.
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
…o local variable' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Selective E2E Results — ✅ All requested jobs passedRun: 26325368107
|
Selective E2E Results — ✅ All requested jobs passedRun: 26325512338
|
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Selective E2E Results — ✅ All requested jobs passedRun: 26325562470
|
ericksoa
left a comment
There was a problem hiding this comment.
Re-reviewed the current cleanup head after the CodeQL auto-fix and follow-up cleanup. The requested completed=true blocker remains fixed, the unused finalization result is gone, local build/typecheck/finalization tests passed, and all GitHub checks are green on this head.
Selective E2E Results — ✅ All requested jobs passedRun: 26325725908
|
## Summary Remove direct onboard-session writes from non-OpenClaw agent setup. This stacks on #3876 and routes agent setup completion/failure through the context supplied by the onboarding handler/runtime boundary. ## Related Issue Refs #3802 Stacked on #3876 ## Changes - Removed the direct `../state/onboard-session` import from `src/lib/agent/onboard.ts`. - Extended `OnboardContext` with `recordStepComplete` and `recordStepFailed` callbacks. - Routed agent setup resume completion, final completion, and failure recording through the context instead of direct session calls. - Updated `src/lib/onboard.ts` to pass runtime-backed completion/failure callbacks into agent setup. - Added a source-shape guard in `src/lib/agent/onboard.test.ts` to prevent direct onboard-session writes from returning. ## Type of Change - [x] 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 - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make 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) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added validation tests for session state handling to ensure proper session boundary management in the agent setup workflow. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/3879?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
Summary
Extract final onboarding completion and post-verify orchestration into an explicit handler. This stacks on #3874 and preserves legacy credential cleanup, stale host cleanup, sandbox process recovery, deployment verification, diagnostics printing, and dashboard output.
Related Issue
Refs #3802
Stacked on #3874
Changes
handleFinalizationState(...)undersrc/lib/onboard/machine/handlers/finalization.ts.src/lib/onboard.tsto route finalization through the handler.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Refactor
Bug Fixes / Reliability
Tests