Repository navigation
Conversation
The left sidebar's open state (`bb.sidebar.open`) and width (`bb.sidebar.width`) were stored with `createLocalStorageSyncStorage`, whose `subscribe` relays the browser's `storage` event into the jotai atom. Writing either value in one tab therefore pushed it live into every other open tab and desktop window, so collapsing the sidebar to make room for the right panel in one thread's tab collapsed it everywhere. Move both to the existing `createTabScopedStorage` helper already used by the root composer's selection and the split layout: reads prefer this tab's `sessionStorage` and fall back to `localStorage`, writes update both, and there is no `subscribe`, so no cross-tab event can rewrite a tab's layout. With `persistInitialValue`, a tab pins the value it started with, so reloading it keeps its own view. A newly opened tab or window still starts from the most recent choice made anywhere in that browser, via the `localStorage` mirror. Verification: with the worktree dev app on two real browser tabs, collapsing and resizing the sidebar in one tab leaves the other untouched; a third tab opened afterwards inherits the latest collapse and width; reloading the untouched tab keeps its own state. Two new `AppLayout` tests dispatch a cross-tab `storage` event and assert this tab's sidebar does not move; both fail against the previous storage. `turbo run test typecheck lint` passes for @bb/app and @bb/templates. Co-Authored-By: Claude Opus 5 <[email protected]>
ymichael
deleted the
bb/left-sidebar-collapse-should-be-sessionstorage-n-thr_2gic8imcix
branch
October 1, 2026 16:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The left sidebar's open state (
bb.sidebar.open) and width (bb.sidebar.width) were persisted withcreateLocalStorageSyncStorage, whosesubscriberelays the browser'sstorageevent into the backing jotai atom. A write in one tab was therefore pushed live into every other open tab and desktop window. Someone keeping several threads open in tabs, with the right panel open in some of them, would collapse the sidebar in one tab to make room — and every other tab collapsed with it. This is the same defect class as #3190 (a stale second tab reverting the root composer's project selection), which was fixed by scoping that state to the tab.Reported in the Discord #bugs forum thread "Left sidebar collapse should be sessionStorage not localStorage" (autocole, 2026-09-30), seconded by webcoder. No GitHub issue was filed, so there is nothing for this PR to close.
What changed
apps/app/src/components/layout/AppLayout.tsx— both sidebar storages now use the existingcreateTabScopedStoragehelper (apps/app/src/lib/browser-storage.ts) withpersistInitialValue: true. No new mechanism; the same helper already backs the root composer's selection and the split layout.sessionStorage[key]→ elselocalStorage[key]→ else the default (true,320)subscribe, so nostorageevent can rewrite a tab's layoutpersistInitialValuepins the value the tab started with into its ownsessionStorageThe resulting behaviour:
persistInitialValuebuys — without it, "per-tab" would silently lapse on every refresh.Sidebar width is included deliberately, not smuggled in. It is the same storage mechanism, the same user-visible surprise, and the same one-line change, and
docs/configuration.mdalready treats the pair as one unit ("Sidebar width and open state stay in the browser because they depend on the window size"). Resizing in one tab was verified to propagate to others before this change.Neighbouring layout state was measured and deliberately left alone. The right panel's open state (per-thread
fixedPanelTabsState, which already omitssubscribe) and its width percent (bb.thread.secondaryPanel.widthPercent, only read as a mount-time default by react-resizable-panels) were both checked live and neither reproduces this bug. Split layout and maximized pane already usecreateTabScopedStorage.Docs:
docs/configuration.mdandpackages/templates/src/templates/bb-guide-customization.mdnow state the per-tab rule in the "Client-local UI preferences" section.No wire changes.
HOST_DAEMON_PROTOCOL_VERSIONis untouched and does not apply — this is client-only, with no server, daemon, schema, SDK, CLI or plugin surface involved. Storage keys and value formats are unchanged, so an existing user's saved value is read as the seed on first load after upgrade and nobody's sidebar resets; rolling back finds exactly the values the old build expects.How you verified
Tests. Two tests added to
AppLayout.test.tsxrender the layout, dispatch a cross-tabstorageevent, and assert this tab's sidebar does not move. Confirmed to fail against the previous storage and pass after:sessionStorage.clear()was also added to the file's existing hooks, which only clearedlocalStorage.Commands.
pnpm exec turbo run test typecheck lint --filter='...[origin/main]'on the rebased head — app, server, mobile and every bundled plugin: all tests pass, typecheck clean, 0 lint errors (remaining warnings are pre-existing and none are in touched code).Manual, in the real app. Two separate builds of the dev app — the parent commit and this change — each driven with two real browser tabs at 1280×800 with storage cleared first:
Before: collapsing in tab A collapsed tab B (
ls_open:"false", Bstate:"collapsed"); dragging the width in tab A moved tab B to the same 404px.After: collapsing in tab A left tab B at
state:"expanded"; dragging tab B's width to 404px left tab A and tab C at their own widths (ls_width:"404"butss_width:"320"in the untouched tabs); a newly opened tab inherited the latest collapse and width; reloading an untouched tab kept its own state.Not verified: desktop two-window. I did not run the Electron app, and the source reading (application windows share a session partition, so one
localStorage, but each renderer gets its ownsessionStorage) is a hypothesis rather than evidence. It is worth exercising deliberately before relying on it.