Skip to content

refactor: Create and use onboarding state hook#1606

Merged
mfortman11 merged 3 commits into
mainfrom
refactor-onboarding-state
May 15, 2026
Merged

refactor: Create and use onboarding state hook#1606
mfortman11 merged 3 commits into
mainfrom
refactor-onboarding-state

Conversation

@mfortman11
Copy link
Copy Markdown
Contributor

@mfortman11 mfortman11 commented May 14, 2026

Creates use-onboarding-state hook to consolidate onboarding state

Summary by CodeRabbit

  • Refactor
    • Centralized onboarding state across the app for consistent behavior.
    • Nudges and task-completion/failure notifications now respect the centralized onboarding status.
    • Onboarding completion is now derived from the central state (removes local/manual completion handling).

Review Change Stack

@mfortman11 mfortman11 requested a review from lucaseduoli May 14, 2026 18:26
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a83412c-b55a-4683-bdfb-e60d7eaab102

📥 Commits

Reviewing files that changed from the base of the PR and between 56778bd and db1662e.

📒 Files selected for processing (1)
  • frontend/hooks/use-onboarding-state.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/hooks/use-onboarding-state.ts

Walkthrough

Centralizes onboarding status by adding useOnboardingState and switching Chat page, ChatProvider, and TaskContext to consume that hook for isOnboardingComplete / isOnboardingActive instead of computing from settings locally.

Changes

Onboarding state consolidation

Layer / File(s) Summary
Create centralized onboarding state hook
frontend/hooks/use-onboarding-state.ts
Adds useOnboardingState() (client hook) that reads useGetSettingsQuery() and returns { currentStep, isOnboardingComplete, isOnboardingActive } using TOTAL_ONBOARDING_STEPS and finite-number validation.
ChatProvider: source onboarding from hook
frontend/contexts/chat-context.tsx
Replaces local settings-derived onboarding logic with const { isOnboardingComplete } = useOnboardingState() and changes setOnboardingComplete to a no-op while keeping context API shape.
TaskContext: gate toasts using hook boolean
frontend/contexts/task-context.tsx
Imports useOnboardingState and replaces isOnboardingActive() callback and its settings-based derivation with const { isOnboardingActive } = useOnboardingState(); uses boolean in task-completed and task-failed toast gating and effect dependencies.
Chat page: use hook for nudge gating
frontend/app/chat/page.tsx
Imports useOnboardingState and replaces inline settings-based completion check with const { isOnboardingComplete } = useOnboardingState() for existing nudge-fetch enabled gating.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • lucaseduoli
  • Wallgau
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: creating and using a new onboarding state hook across multiple files. It is concise, specific, and clearly conveys the refactoring objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-onboarding-state

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.

❤️ Share

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

@github-actions github-actions Bot added frontend 🟨 Issues related to the UI/UX community refactor and removed refactor labels May 14, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/contexts/chat-context.tsx (1)

90-90: ⚡ Quick win

Avoid exposing a silent no-op setter in the context API.

setOnboardingComplete still looks writable in ChatContextType, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5598705 and 56778bd.

📒 Files selected for processing (4)
  • frontend/app/chat/page.tsx
  • frontend/contexts/chat-context.tsx
  • frontend/contexts/task-context.tsx
  • frontend/hooks/use-onboarding-state.ts

Comment thread frontend/hooks/use-onboarding-state.ts Outdated
@mfortman11 mfortman11 enabled auto-merge (squash) May 15, 2026 17:13
@mfortman11 mfortman11 merged commit afe80ab into main May 15, 2026
10 of 12 checks passed
@github-actions github-actions Bot added the lgtm label May 15, 2026
@github-actions github-actions Bot deleted the refactor-onboarding-state branch May 15, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community frontend 🟨 Issues related to the UI/UX lgtm refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants