fix(web): persist sidebar shelf collapse state - #5136
Conversation
Collapsing Settled in Sidebar V2 read as a lasting preference but was component state, so every relaunch brought the history back. Move it to the useLocalStorage hook used for other client-only UI prefs, defaulting to expanded so nothing changes for anyone who hasn't collapsed it.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Approved caf78ae Simple client-side localStorage persistence for sidebar shelf collapse state. The changes are self-contained UI preference storage with no backend, schema, or security implications. Review comments point to pre-existing issues or style preferences rather than bugs introduced here. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate c92420d
c92420d to
caf78ae
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit caf78ae. Configure here.
caf78ae to
f575c74
Compare
|
Non-blocking follow-up: I briefly explored a Sidebar-local persistence helper because the current That helper was removed because shelf state should follow the repository rule and use the shared abstraction. This PR now uses |
|
@ipanasenko thanks for the initial PR! My PR workflow is to scan for existing PRs that match the functionality before I bother working on one--yours was most of the way there. In theory, I could target your branch instead and you could merge my changes into yours. I see you've closed yours, so I'll leave this one open since it covers both shelves. Since I'm not a core maintainer, I can't push to your PR branch directly. :) |


Summary
useLocalStoragehook with an independent key for each shelfWhy
Collapsing a shelf reads as a lasting preference. Today both shelves reset when the desktop app restarts, so users have to restore their preferred sidebar layout every launch.
This includes the Settled persistence change from #4573 by @ipanasenko with the original commit authorship preserved, then adds the missing Snoozed persistence.
Before / After
Both captures use the same isolated synthetic showcase dataset: three settled threads plus two showcase threads explicitly seeded with future snooze times. Before each restart, Snoozed was expanded and Settled was collapsed.
Verification
pnpm exec vp test run apps/web/src/hooks/useLocalStorage.test.ts(4 tests)pnpm exec vp lint --report-unused-disable-directives apps/web/src/components/SidebarV2.tsxpnpm --filter @t3tools/web typecheckChecklist
mainModel: GPT-5.6 Sol | Harness: Codex in T3 Code
Note
Low Risk
UI-only sidebar preference persistence with safe fallbacks; no auth, data, or server behavior changes.
Overview
Settled and Snoozed shelf expand/collapse in Sidebar V2 now survives reloads and desktop restarts instead of resetting every launch.
A new
usePersistentShelfExpandedhook reads and writes each shelf’s state tolocalStorageundert3code:sidebar-v2:settled-expandedandt3code:sidebar-v2:snoozed-expanded, withSchema.Booleanvalidation viagetLocalStorageItem/setLocalStorageItem. First-run defaults stay the same: Settled expanded, Snoozed collapsed. Failed reads or writes log to the console and fall back to in-memory state so toggles still work when storage is blocked or corrupt.Reviewed by Cursor Bugbot for commit caf78ae. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Persist sidebar shelf collapse state to localStorage in
SidebarV2Replaces
useStatewithuseLocalStoragefor the Settled and Snoozed shelf expanded flags in SidebarV2.tsx, so collapse state survives page reloads. Boolean values are validated usingeffect/Schema.Macroscope summarized f575c74.