Skip to content

fix(onboarding): clear all onboarding state on logout so overlay reappears#167

Merged
graycyrus merged 7 commits intomainfrom
fix/onboarding-overlay-fresh-install
Apr 1, 2026
Merged

fix(onboarding): clear all onboarding state on logout so overlay reappears#167
graycyrus merged 7 commits intomainfrom
fix/onboarding-overlay-fresh-install

Conversation

@graycyrus
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus commented Apr 1, 2026

Summary

  • Clear isOnboardedByUser and isAnalyticsEnabledByUser in the _clearToken reducer so persisted onboarding state doesn't survive logout
  • Call openhumanWorkspaceOnboardingFlagSet(false) on all three logout paths (Settings logout, Clear All Data, UserProvider auth recovery) to delete the workspace .skip_onboarding flag file
  • Add 3-second timeout fallback in OnboardingOverlay so the overlay still renders if user profile fetch is slow
  • Add unit test asserting clearToken resets all per-user fields to {}

Test plan

  • Log in and complete onboarding
  • Log out → log back in → onboarding overlay should reappear
  • "Log Out & Clear App Data" → log back in → onboarding overlay should reappear
  • Defer onboarding ("Set up later") → navigate around → overlay stays dismissed until next login
  • yarn typecheck, yarn lint, yarn format:check, yarn build all pass
  • yarn tauri dev launches and core connects

Closes #117

Summary by CodeRabbit

  • Bug Fixes

    • Ensure onboarding-related flags and analytics preferences are cleared when signing out, clearing app data, or during auth recovery.
    • Added a 3s timeout so the onboarding overlay proceeds even if user profile loading stalls.
  • Tests

    • Added coverage verifying onboarding/analytics state is fully cleared when a user session is reset.
  • Documentation

    • Clarified onboarding cleanup requirements and synchronized logout/recovery flows.

…download snackbar

- Add persisted `onboardingDeferredByUser` state so "Set up later" survives
  across sessions (no more overlay nagging on every launch)
- Add SetupBanner for non-intrusive "Finish setting up" reminder with resume path
- Convert LocalAIStep to fire-and-forget download, advancing immediately
- Add LocalAIDownloadSnackbar (bottom-left, collapsible) for persistent download
  progress that doesn't block the main chrome
- Extract shared helpers (formatBytes, formatEta, progressFromStatus) to localAiHelpers.ts
- Add Vitest tests for overlay gating, banner, and snackbar

Closes #101
…orts

The OnboardingOverlay test mocked utils/config with only DEV_FORCE_ONBOARDING,
which shadowed the global mock from setup.ts and dropped IS_DEV — causing
store/index.ts to fail on CI.
Two tests called .history() and .turn() on the (Agent, TempDir) tuple
instead of destructuring it first, causing compilation errors on CI.
…pears

On logout, `isOnboardedByUser` and `isAnalyticsEnabledByUser` were not
reset in the `_clearToken` reducer, and the workspace `.skip_onboarding`
flag file was never deleted. This caused the onboarding overlay to be
permanently skipped after the first completion — even for new users on
the same machine.

- Clear `isOnboardedByUser` and `isAnalyticsEnabledByUser` in `_clearToken`
- Call `openhumanWorkspaceOnboardingFlagSet(false)` on logout, clear-all,
  and auth recovery paths
- Add 3s timeout fallback in OnboardingOverlay for slow user profile loads
- Add unit test asserting `clearToken` resets all per-user fields

Closes #117
…y-fresh-install

# Conflicts:
#	.claude/memory.md
#	app/src/components/LocalAIDownloadSnackbar.tsx
#	app/src/components/OnboardingOverlay.tsx
#	app/src/pages/onboarding/steps/LocalAIStep.tsx
#	app/src/utils/localAiHelpers.ts
#	src/openhuman/agent/tests.rs
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28d53cbe-6262-409b-8812-2a41491ed4e0

📥 Commits

Reviewing files that changed from the base of the PR and between a3502a3 and a213347.

📒 Files selected for processing (2)
  • app/src/components/OnboardingOverlay.tsx
  • app/src/providers/UserProvider.tsx
✅ Files skipped from review due to trivial changes (1)
  • app/src/providers/UserProvider.tsx

📝 Walkthrough

Walkthrough

Clears per-user onboarding and analytics state on token clear, removes the workspace onboarding flag in three logout/auth-recovery flows, and adds a 3-second user-load timeout so the onboarding overlay can proceed even if the user profile is slow or absent.

Changes

Cohort / File(s) Summary
Auth State Reset
app/src/store/authSlice.ts, app/src/store/__tests__/authSlice.test.ts
_clearToken now also empties isOnboardedByUser and isAnalyticsEnabledByUser. New test ensures all per-user maps are cleared when clearToken() runs.
Logout & Recovery Flows
app/src/components/settings/SettingsHome.tsx, app/src/providers/UserProvider.tsx
After clearing tokens, both flows call openhumanWorkspaceOnboardingFlagSet(false) in try/catch to remove the workspace onboarding file; failures are warned but do not stop logout/recovery.
Onboarding Overlay Timeout
app/src/components/OnboardingOverlay.tsx
Introduced userLoadTimedOut (3s) and `userReady = !!user?._id
Documentation
.claude/memory.md
Documented the onboarding gotcha: _clearToken resets onboarding-related state and the workspace .skip_onboarding flag must be cleared via openhumanWorkspaceOnboardingFlagSet(false) in the three flows (SettingsHome logout, clearAllAppData, UserProvider auth recovery).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SettingsHome
  participant AuthStore
  participant TauriFS as WorkspaceFlagAPI

  User->>SettingsHome: Click "Logout" / "Clear All App Data"
  SettingsHome->>AuthStore: dispatch(clearToken())
  SettingsHome->>TauriFS: openhumanWorkspaceOnboardingFlagSet(false)
  TauriFS-->>SettingsHome: ack / error
  SettingsHome-->>User: redirect to "/"
Loading
sequenceDiagram
  participant AppStartup
  participant UserProvider
  participant AuthStore
  participant OnboardingOverlay
  participant TauriFS as WorkspaceFlagAPI

  AppStartup->>UserProvider: bootstrap auth
  UserProvider->>AuthStore: provide token/state
  OnboardingOverlay->>AuthStore: read token, isAuthBootstrapComplete
  OnboardingOverlay->>OnboardingOverlay: start 3s timer (userLoadTimedOut)
  OnboardingOverlay->>AuthStore: check user?._id or userLoadTimedOut
  OnboardingOverlay->>TauriFS: read workspace flag
  TauriFS-->>OnboardingOverlay: hasFlag / noFlag
  OnboardingOverlay-->>AppStartup: render onboarding or skip
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled flags and cleared the trail,
Reset the hops so onboarding won't fail.
A timeout blink if users take their time,
Now fresh installs will see the sign.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main objective: clearing onboarding state on logout so the overlay reappears, which aligns with all file changes and test additions.
Linked Issues check ✅ Passed The PR implementation fully addresses the three root causes in issue #117: clearing onboarding state in authSlice, deleting workspace flag on three logout paths, and adding timeout fallback in OnboardingOverlay.
Out of Scope Changes check ✅ Passed All changes directly address issue #117 requirements: authSlice state cleanup, workspace flag deletion across logout flows, OnboardingOverlay timeout handling, and corresponding unit tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/onboarding-overlay-fresh-install

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

Copy link
Copy Markdown
Contributor

@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: 3

🧹 Nitpick comments (1)
app/src/components/settings/SettingsHome.tsx (1)

22-43: Extract shared logout cleanup to avoid path drift

Both logout paths now duplicate the same workspace-flag clear block. Given this flow must stay synchronized, extracting a shared helper will reduce future divergence risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/components/settings/SettingsHome.tsx` around lines 22 - 43, Summary:
Duplicate cleanup logic in handleLogout and clearAllAppData should be extracted
into a shared helper to keep both paths synchronized. Create a new helper
function (e.g., performLogoutCleanup or clearTokenAndWorkspaceFlag) that does
the dispatch(clearToken()) and the try/catch around
openhumanWorkspaceOnboardingFlagSet(false) (and return or surface errors as
needed); then replace the duplicated blocks in handleLogout and clearAllAppData
to call that helper. Keep handleLogout's additional try/catch around tauriLogout
and the final window.location.hash assignment unchanged so only the shared
cleanup is centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/components/OnboardingOverlay.tsx`:
- Around line 30-39: The timeout flag userLoadTimedOut in OnboardingOverlay is
set true but never reset, causing future sessions to skip gating; update the
useEffect that creates the timer (and/or add a separate effect) to reset
userLoadTimedOut to false whenever token becomes falsy or when user._id appears
(i.e., on changes to token, isAuthBootstrapComplete, or user?._id) and keep the
existing timer logic that sets it true after 3s; refer to the userLoadTimedOut
state and the existing useEffect that uses setTimeout/clearTimeout to implement
this reset so the flag does not persist across sessions.

In `@app/src/providers/UserProvider.tsx`:
- Around line 58-62: The catch block in the UserProvider recovery path currently
swallows errors from openhumanWorkspaceOnboardingFlagSet(false); update it to
catch the error (e) and emit a namespaced debug/warn log so failures remain
observable—for example call your app's namespaced logger or debug utility (e.g.,
debug("UserProvider:openhumanWorkspaceOnboardingFlagSet", e) or
logger.warn("UserProvider:openhumanWorkspaceOnboardingFlagSet failed", e))
inside the catch; keep it best-effort (do not rethrow) so auth recovery still
proceeds.

In `@app/src/store/authSlice.ts`:
- Around line 59-62: The analytics map reset leaves missing keys undefined which
current readers treat as enabled; update all reads of
state.auth.isAnalyticsEnabledByUser to treat missing entries as false (e.g.,
replace expressions like state.auth.isAnalyticsEnabledByUser[userId] with
state.auth.isAnalyticsEnabledByUser[userId] ?? false or use a selector/getter
that returns false by default), and ensure any selector or helper (e.g.,
getIsAnalyticsEnabled, isAnalyticsEnabledByUser access sites) is updated
accordingly so post-logout missing keys do not imply opt-in.

---

Nitpick comments:
In `@app/src/components/settings/SettingsHome.tsx`:
- Around line 22-43: Summary: Duplicate cleanup logic in handleLogout and
clearAllAppData should be extracted into a shared helper to keep both paths
synchronized. Create a new helper function (e.g., performLogoutCleanup or
clearTokenAndWorkspaceFlag) that does the dispatch(clearToken()) and the
try/catch around openhumanWorkspaceOnboardingFlagSet(false) (and return or
surface errors as needed); then replace the duplicated blocks in handleLogout
and clearAllAppData to call that helper. Keep handleLogout's additional
try/catch around tauriLogout and the final window.location.hash assignment
unchanged so only the shared cleanup is centralized.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f811a15-1e46-4c5c-bd34-258d290690e6

📥 Commits

Reviewing files that changed from the base of the PR and between 7fd4568 and a3502a3.

📒 Files selected for processing (6)
  • .claude/memory.md
  • app/src/components/OnboardingOverlay.tsx
  • app/src/components/settings/SettingsHome.tsx
  • app/src/providers/UserProvider.tsx
  • app/src/store/__tests__/authSlice.test.ts
  • app/src/store/authSlice.ts

- Add console.warn in UserProvider catch block for workspace flag clear
- Add inline comment explaining userLoadTimedOut stickiness is harmless

Closes #117
@graycyrus graycyrus merged commit ec6f954 into main Apr 1, 2026
12 checks passed
@senamakel senamakel deleted the fix/onboarding-overlay-fresh-install branch April 4, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Onboarding overlay does not show on fresh install

1 participant