Skip to content

Mount secondary panel content once on a thread switch - #7803

Merged
ymichael merged 4 commits into
get-bb:mainfrom
lanjak:fix-secondary-panel-double-mount
Nov 20, 2026
Merged

ymichael merged 4 commits into
get-bb:mainfrom
lanjak:fix-secondary-panel-double-mount

Conversation

@lanjak

@lanjak lanjak commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

ThreadSecondaryPanel only mounted SidebarSplitContainer once the thread's fixed tabs were ready (areFixedTabsReady). Until then it rendered the flat panel surface. On a thread switch, readiness is false on the first render: plugin tabs report visibility from layout effects, and since #7878 a thread also waits for its saved thread tabs (useThreadTabs) to load. When readiness arrived, the panel replaced the flat surface with the split container, and React mounted all panel content a second time. The same swap ran whenever readiness dropped mid-session, for example while a plugin that owns a saved tab reloads. The gate came from #6013. It keeps a saved split layout from being parsed, and overwritten, against an incomplete tab list.

What changed

  • ThreadSecondaryPanel mounts SidebarSplitContainer right away and passes readiness down as isTabListReady. There is no flat-to-split swap, so content mounts once on a switch and stays mounted through plugin reloads.
  • SidebarSplitContainer (new required isTabListReady prop): if it mounts before the tab list is ready and a saved layout exists, it renders a best-effort layout from the available tabs, skips persistence so the saved value stays intact, and restores the saved layout once the list is ready. With no saved layout it uses the deterministic default layout, so nothing remounts when tabs arrive.
  • No skeleton is shown on a switch. The first version of this PR held the panel behind SecondaryPanelContentSkeleton. After Gate plugin surfaces on the plugin they need, not on every bundle #7878 that skeleton painted for one thread-tabs fetch on every first visit to a thread: 33 ms locally and 333 ms with 150 ms of added latency, with no tab bar or close button.
  • The drawer path is unchanged.

How you verified

  • ThreadSecondaryPanel.threadSwitch.test.tsx uses the real useThreadFixedTabs, a real plugin tab registration and a stubbed sdk.threads.tabs.get. Content mounts once per switch for Info and an open file. Content stays mounted with no skeleton while a saved tab's owning plugin reloads, for Info, an open file and a plugin tab. These five tests fail with main's ThreadSecondaryPanel.tsx and SidebarSplitContainer.tsx (expected [ 'info:thr_b', 'info:thr_b' ] to deeply equal [ 'info:thr_b' ]). Further tests check that panel content shows while saved tabs load and that a reloaded plugin tab stays selected.
  • The existing saved-split test in ThreadSecondaryPanel.collapseControl.test.tsx passes: the stored split survives while visibility resolves and is restored afterwards. It now seeds the thread's lastUsedAt, because the container mounts earlier and pruneSidebarSplitStorage drops splits for threads without one.
  • pnpm exec turbo run typecheck lint --filter=@bb/app passes. The secondary-panel/, plugin/ and thread-detail/ suites pass, apart from two failures unrelated to this change: a lazy-loading test that times out under load and passes alone, and a branding.icon test that reads leftover untracked plugin directories in this checkout.
  • Live, headless Chromium at 1600x1000 on pnpm start:worktree:
    • Repeated switches, Info or Diff active, 30 each: 1 panel chrome insertion per switch (main: 2). Click-to-paint median 16 ms both ways.
    • First visit to a thread after a reload, 4 runs each at 0 ms and 150 ms added latency: 1 insertion, 0 skeleton frames.
    • Saved Info | Diff split, first visit after a reload, at 0 ms and 150 ms: the panel shows Info, then restores both panes. The stored layout is unchanged and no skeleton frames paint.
    • Disabling and re-enabling the Git plugin and another plugin with the panel open: 0 panel remounts, 0 skeleton frames.
    • Main-thread CPU per switch, measured on the pre-Gate plugin surfaces on the plugin they need, not on every bundle #7878 base (main: 1 run, branch: 2 runs): Info 50 ms on main vs 45–47 ms on the branch, Diff 92 ms vs 80–84 ms.

Related: #7801. With that change, the duplicate mount opened one extra short-lived terminal socket per thread switch.

Fixes #7802

AGENT GENERATED

ymichael and others added 3 commits November 20, 2026 11:15
Wait for fixed-tab readiness only before the first split surface for a
thread. A later readiness drop (plugin reconcile, server plugins
starting) no longer swaps the panel for the skeleton and remounts its
content; the split container already restores tabs that leave and come
back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After get-bb#7878 a thread's tab readiness also waits for its saved thread
tabs to load, so holding the split surface behind a skeleton showed a
blank panel for a network round trip on a first visit. Mount the split
container immediately instead. When it mounts before the tab list is
ready with a saved layout, it renders a best-effort layout, skips
persistence, and restores the saved layout once the list is ready.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit eeb9659 into get-bb:main Nov 20, 2026
31 checks passed
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.

Secondary panel mounts its active content twice on each thread switch

2 participants