Skip to content

fix(web): persist sidebar shelf collapse state - #5136

Open
PixPMusic wants to merge 2 commits into
pingdotgg:mainfrom
PixPMusic:pixpmusic/persist-sidebar-shelf-state
Open

fix(web): persist sidebar shelf collapse state#5136
PixPMusic wants to merge 2 commits into
pingdotgg:mainfrom
PixPMusic:pixpmusic/persist-sidebar-shelf-state

Conversation

@PixPMusic

@PixPMusic PixPMusic commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • persist the Sidebar V2 Settled and Snoozed expansion states across desktop restarts and web reloads
  • keep the first-run defaults: Settled expanded and Snoozed collapsed
  • use the existing schema-validated useLocalStorage hook with an independent key for each shelf

Why

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.

Before: current main after restart After: this branch after restart
Current main after restart: Snoozed resets collapsed and Settled resets expanded This branch after restart: Snoozed remains expanded and Settled remains 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.tsx
  • pnpm --filter @t3tools/web typecheck
  • reproduced the reset on current main with a full T3 Code Desktop quit and relaunch against the synthetic showcase fixture
  • verified the branch preserves expanded Snoozed and collapsed Settled states through the same full desktop restart

Checklist

Model: GPT-5.6 Sol | Harness: Codex in T3 Code


Open in Devin Review

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 usePersistentShelfExpanded hook reads and writes each shelf’s state to localStorage under t3code:sidebar-v2:settled-expanded and t3code:sidebar-v2:snoozed-expanded, with Schema.Boolean validation via getLocalStorageItem / 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 SidebarV2

Replaces useState with useLocalStorage for the Settled and Snoozed shelf expanded flags in SidebarV2.tsx, so collapse state survives page reloads. Boolean values are validated using effect/Schema.

Macroscope summarized f575c74.

ipanasenko and others added 2 commits July 31, 2026 10:28
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.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c3b1f3a-d144-4dd7-b161-8edbc9bf4315

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 31, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 31, 2026
@ipanasenko

Copy link
Copy Markdown
Contributor

@macroscopeapp
macroscopeapp Bot dismissed their stale review July 31, 2026 18:09

Dismissing prior approval to re-evaluate c92420d

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jul 31, 2026
Comment thread apps/web/src/hooks/useLocalStorage.ts
Comment thread apps/web/src/hooks/useLocalStorage.ts Outdated
@PixPMusic
PixPMusic force-pushed the pixpmusic/persist-sidebar-shelf-state branch from c92420d to caf78ae Compare July 31, 2026 18:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/SidebarV2.tsx Outdated
@PixPMusic
PixPMusic force-pushed the pixpmusic/persist-sidebar-shelf-state branch from caf78ae to f575c74 Compare July 31, 2026 18:33
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jul 31, 2026
@PixPMusic

Copy link
Copy Markdown
Contributor Author

Non-blocking follow-up: I briefly explored a Sidebar-local persistence helper because the current useLocalStorage failure path can leave a control unresponsive within the session. If reading, decoding, or writing local storage fails, the hook logs the error but cannot publish the attempted value. A malformed stored value is especially awkward: the render falls back to the default, then a functional update reads and decodes the same malformed value again and aborts before it can replace it.

That helper was removed because shelf state should follow the repository rule and use the shared abstraction. This PR now uses useLocalStorage directly and does not change the hook. Separately, the hook may be worth hardening so consumers retain usable in-memory state when persistence is unavailable and can recover from malformed values, while preserving its existing cross-tab behavior.

@PixPMusic

PixPMusic commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants