refactor: Create and use onboarding state hook#1606
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughCentralizes onboarding status by adding ChangesOnboarding state consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/contexts/chat-context.tsx (1)
90-90: ⚡ Quick winAvoid exposing a silent no-op setter in the context API.
setOnboardingCompletestill looks writable inChatContextType, but now it intentionally does nothing. That can hide incorrect assumptions in consumers. Prefer making onboarding completion read-only in the context contract (or emit a dev warning while deprecating the setter).Also applies to: 127-129
🤖 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 `@frontend/contexts/chat-context.tsx` at line 90, The context currently exposes setOnboardingComplete as a writable function on ChatContextType but it intentionally no-ops; remove or change that API so consumers can’t assume mutability: remove setOnboardingComplete from ChatContextType (and any exported Context default value), make onboardingComplete a read-only property, and update ChatProvider/useChatContext consumers to stop calling setOnboardingComplete (or if you must keep it for compatibility, replace the no-op implementation in ChatProvider with a dev-only console.warn in setOnboardingComplete that explains it is read-only/deprecated). Also update the other occurrences referenced (the same symbol around lines 127-129) to match the new read-only contract.
🤖 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.
Inline comments:
In `@frontend/hooks/use-onboarding-state.ts`:
- Around line 8-12: currentStep (from settings?.onboarding?.current_step) is
being checked only for undefined, which still allows null or non-number values
into numeric comparisons; change the guards for isOnboardingComplete and
isOnboardingActive to first ensure currentStep is a number (e.g., typeof
currentStep === 'number' && Number.isFinite(currentStep)) before comparing to
TOTAL_ONBOARDING_STEPS so both comparisons use a strict numeric guard; update
the expressions that define isOnboardingComplete and isOnboardingActive
accordingly.
---
Nitpick comments:
In `@frontend/contexts/chat-context.tsx`:
- Line 90: The context currently exposes setOnboardingComplete as a writable
function on ChatContextType but it intentionally no-ops; remove or change that
API so consumers can’t assume mutability: remove setOnboardingComplete from
ChatContextType (and any exported Context default value), make
onboardingComplete a read-only property, and update ChatProvider/useChatContext
consumers to stop calling setOnboardingComplete (or if you must keep it for
compatibility, replace the no-op implementation in ChatProvider with a dev-only
console.warn in setOnboardingComplete that explains it is read-only/deprecated).
Also update the other occurrences referenced (the same symbol around lines
127-129) to match the new read-only contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d6256d03-21f0-498a-a957-67861d3c3842
📒 Files selected for processing (4)
frontend/app/chat/page.tsxfrontend/contexts/chat-context.tsxfrontend/contexts/task-context.tsxfrontend/hooks/use-onboarding-state.ts
Creates
use-onboarding-statehook to consolidate onboarding stateSummary by CodeRabbit