Repository navigation
Description
Summary
With two bb tabs open on the same origin, pressing a project's sidebar plus button ("New thread in ") in one tab flashes the project into the composer for one frame and then reverts to "Work in a project" (personal). The other tab — which loaded before the project was created and still has a stale sidebar-bootstrap project list — receives the selection over the localStorage storage event, fails to find the project in its list, and writes proj_personal back, clobbering the first tab. Expected: a project that exists on the server is selectable regardless of what other tabs have cached.
Versions and environment
- bb-app 0.42.1 (npm, launched from source via a thin launcher;
@get-bb/plugin-sdk0.4.47), macOS 15, Node 24.15 - Chrome 152, two tabs on
http://127.0.0.1:38899 - Standard project with a
local_pathsource; no Connect, no worktree env - Also reproduced against
mainsource at accd559 by reading the code paths below (same logic as the shipped bundle)
Steps to reproduce
- Open bb in tab A. Leave it on the root composer.
- Create a new project (Settings → New project, or
POST /api/v1/projects). Do not reload tab A. (Equivalent, and what I used for a deterministic repro: interceptGET /api/v1/sidebar-bootstrapin tab A so the response omits the new project —network route "**/api/v1/sidebar-bootstrap*" --body <json without the project>.) - Open bb in tab B (fresh load; its sidebar shows the new project).
- In tab B, hover the new project's sidebar row and press its plus button ("New thread in "), or pick the project in the composer's "Work in a project" picker.
Did not reproduce with: a single tab; two tabs that both loaded after the project was created; any project that exists in both tabs' lists.
Expected vs actual
Tab B (clicking tab), instrumented Storage.prototype.setItem + 'storage' listener, key bb.root-compose.project-id:
[35399 ms] B-set proj_ekybszguti <- plus button writes the selection
[35425 ms] B-evt proj_personal <- storage event from tab A, 26 ms later
localStorage now: proj_personal
composer footer: "Work in a project"
Tab A (stale tab), same instrumentation:
[123245 ms] A-evt proj_ekybszguti <- receives B's selection via storage event
[123247 ms] A-set proj_personal <- NewThreadComposer normalises unknown id -> personal and writes it back
sidebar in A: only "New thread in kiro-verify" (no Yojaka row; stale list)
Visually in tab B the composer shows Yojaka · Work locally · Current (mainline) for ~1–2 frames (6 fps screen recording, frames 9→11) then snaps back to Work in a project. Server is consistent throughout: GET /api/v1/sidebar-bootstrap returns both projects, GET /api/v1/projects/proj_ekybszguti/branch-options?hostId=… → 200.
Expected: tab B keeps proj_ekybszguti and shows the environment/branch selectors. Tab A, at most, should ignore or refetch — never overwrite a shared key based on its own stale cache.
Evidence
Mechanism, at accd559:
- The selection is a cross-tab-synced
atomWithStorage(createLocalStorageSyncStoragesubscribes tostorage):andbb/apps/app/src/lib/root-compose-selection.ts
Lines 15 to 25 in accd559
const rootComposeProjectIdStorage = createLocalStorageSyncStorage<string>({ parse: parseStoredProjectId, serialize: (value) => value, }); const rootComposeProjectIdAtom = atomWithStorage<string>( ROOT_COMPOSE_PROJECT_ID_STORAGE_KEY, PERSONAL_PROJECT_ID, rootComposeProjectIdStorage, { getOnInit: true }, ); bb/apps/app/src/lib/browser-storage.ts
Lines 58 to 79 in accd559
function subscribeToLocalStorageKey( key: string, callback: StoredValueListener, ): () => void { const localStorage = getLocalStorage(); if ( !localStorage || typeof window === "undefined" || typeof window.addEventListener !== "function" ) { return () => {}; } const handleStorage = (event: StorageEvent) => { if (event.storageArea === localStorage && event.key === key) { callback(event.newValue); } }; window.addEventListener("storage", handleStorage); return () => { window.removeEventListener("storage", handleStorage); NewThreadComposervalidates the requested id againstuseSidebarNavigation().data.projectsand substitutesPERSONAL_PROJECT_IDwhen it is absent and the query is no longer placeholder data:bb/apps/app/src/components/promptbox/NewThreadComposer.tsx
Lines 385 to 398 in accd559
const requestedCandidate = requestedProjectId ?? PERSONAL_PROJECT_ID; const candidateKnown = isProjectlessProjectId(requestedCandidate) || (projects?.some((project) => project.id === requestedCandidate) ?? false); const replayKnowsCandidate = !sidebarNavigationQuery.isPlaceholderData || candidateKnown; const sidebarNavigationSettled = sidebarNavigationQuery.isError || (sidebarNavigationQuery.isSuccess && replayKnowsCandidate); const projectId = useMemo(() => { if (isProjectlessProjectId(requestedCandidate)) return PERSONAL_PROJECT_ID; if (!projects || !replayKnowsCandidate) return requestedCandidate; return candidateKnown ? requestedCandidate : PERSONAL_PROJECT_ID; }, [candidateKnown, projects, replayKnowsCandidate, requestedCandidate]); RootComposeViewthen writes the normalised value back to the shared atom, which is what propagates to the other tab:bb/apps/app/src/views/RootComposeView.tsx
Lines 695 to 698 in accd559
useEffect(() => { if (projectId === rootComposeProjectId) return; setRootComposeProjectId(projectId); }, [projectId, rootComposeProjectId, setRootComposeProjectId]);
So any tab whose sidebar-bootstrap cache lacks the project acts as a "reverter" for every other tab. Stale caches are easy to get: a background tab that lost its live-update socket, or simply one that loaded before the project was created (the New project flow in the other tab doesn't invalidate this tab's query).
IDs from the repro: proj_ekybszguti (new project), proj_87mvthcq9x (pre-existing), host host_jd965tsynm.
What you ruled out
- Not A project's new-thread button replaces the focused pane instead of opening beside it #2795 — that is about which pane the composer opens in; here the composer opens but the project selection is reverted.
- Not a server/project problem:
/api/v1/projects/<id>/branch-optionsandsidebar-bootstrapboth return the project; the click sticks with a single tab. - Not the picker vs. plus button: both write the same atom and both revert.
- Reloading tab A (so its list includes the project) makes the problem disappear, which is the workaround.
Suggested priority and effort (optional)
Medium — anyone who keeps a second bb tab open cannot start a thread in a newly created project until they find and reload the other tab, and there is no UI hint about why. Effort probably Low: either don't write the normalised fallback back to storage when the change came from a remote storage event (or when the candidate is not known only because of this tab's cache — e.g. refetch sidebar-bootstrap before deciding), or make the write-back local-only (sessionStorage/no cross-tab sync for the normalised value).
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report.
AGENT GENERATED — written by a coding agent (pi) from a live repro on the user's machine; instrumented traces above were captured with a headless Chrome driven via agent-browser, screen recording frames reviewed by the agent. Filed on behalf of @apsknight.
Activity
bb-slop-cop commentedon Sep 7, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui,confirmed-reproconfirmed-reproKeep new-thread picker selections tab-local (#3191)
Keep sidebar layout per tab (#4615)