refactor(onboard): add refined flow context guards#5559
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
📝 WalkthroughWalkthroughIntroduces two typed context refinements ( Onboarding FSM context assertion refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
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)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the branch is 96%. Coverage data for the branch is not yet available. Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the branch is 46%. Coverage data for the branch is not yet available. Show a code coverage summary of the most covered files.
Updated |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: Dispatch required Vitest E2E scenarios:
Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
PR Review AdvisorFindings: 0 needs attention, 0 worth checking, 0 nice ideas Consider writing more tests for
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/flow-context.test.ts (1)
76-80: ⚡ Quick winAdd an isolated failure test for missing
sandboxGpuConfigin provider-selected context.This test currently fails because multiple required fields are missing, so it won’t catch regressions where only the
sandboxGpuConfigcheck is removed.Proposed test addition
it("rejects missing provider-selected context fields", () => { expect(() => assertProviderSelectedContext(baseContext(), "sandbox setup")).toThrow( /Onboarding state is incomplete before sandbox setup\./, ); }); + + it("rejects missing sandboxGpuConfig before sandbox setup", () => { + const context = mergeOnboardFlowContext(baseContext(), { + provider: "nvidia-prod", + model: "model", + sandboxGpuConfig: null, + }); + + expect(() => assertProviderSelectedContext(context, "sandbox setup")).toThrow( + /Onboarding state is incomplete before sandbox setup\./, + ); + });🤖 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/flow-context.test.ts` around lines 76 - 80, The current test "rejects missing provider-selected context fields" fails due to multiple missing fields, which won't catch regressions if only the sandboxGpuConfig validation is removed. Add a new isolated test case that calls assertProviderSelectedContext with a baseContext that provides all other required provider-selected context fields but specifically omits only the sandboxGpuConfig field, ensuring the test validates sandboxGpuConfig validation in isolation and will catch if that specific check is accidentally removed.
🤖 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/flow-context.test.ts`:
- Around line 76-80: The current test "rejects missing provider-selected context
fields" fails due to multiple missing fields, which won't catch regressions if
only the sandboxGpuConfig validation is removed. Add a new isolated test case
that calls assertProviderSelectedContext with a baseContext that provides all
other required provider-selected context fields but specifically omits only the
sandboxGpuConfig field, ensuring the test validates sandboxGpuConfig validation
in isolation and will catch if that specific check is accidentally removed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 7d77c7b9-c47f-4c3f-a53b-5ead91e09820
📒 Files selected for processing (4)
src/lib/onboard/machine/core-flow-phases.tssrc/lib/onboard/machine/final-flow-phases.tssrc/lib/onboard/machine/flow-context.test.tssrc/lib/onboard/machine/flow-context.ts
Summary
Add shared refined onboarding flow context types and assertion helpers for the first #5518 nullability cleanup. The core and final onboard phases now reuse those guards instead of carrying local ad hoc not-null checks.
Related Issue
Refs #5518
Changes
ProviderSelectedOnboardFlowContext,SandboxCreatedOnboardFlowContext, andFinalOnboardFlowContextaliases insrc/lib/onboard/machine/flow-context.ts.assertProviderSelectedContextandassertSandboxCreatedContexthelpers to narrow phase context before dependent work runs.Type of Change
Verification
npx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Chores
Tests