#7802 · Panel setup repeats during thread changes
Verdict: REPRODUCED · Root-cause confidence: high
1. TL;DR
The right-hand panel initializes the selected thread's Info content twice when switching threads with a visibility-aware plugin tab registered. The first render uses a plain panel because visibility for the new thread has not been reported yet. A layout-effect report then enables the split-panel wrapper, replacing the content tree and running its setup again. A new focused component test exercises the real panel, built-in Info registration, plugin registration, and visibility hook: every one of ten thread switches produces two content effect activations. The same test in drawer mode produces one activation per switch.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Info content initializes twice per thread switch. | Verified | Two fresh trusted checkouts each produce ten counts of 2; the once-per-switch assertion fails for the intended reason. |
| The cause is the readiness-driven switch between flat and split render trees. | Verified | Real visibility observer, readiness calculation, panel branch, and a passing drawer control all support this mechanism. |
| The behavior requires agent output or a terminal. | Not required | The reproduction uses neither a provider nor a terminal. |
| The default Git plugin and an open file also exhibit it in Chromium. | Unverified here | This investigation uses a minimal registered visibility-aware plugin and the built-in Info content, not a full browser/Git/file integration. |
| Additional terminal sockets and general thread latency follow. | Unverified here | No socket or performance claims are inferred from component effect counts. |
3. Environment
- Public target repository:
get-bb/bb, trusted commit49d0b57a8c0fd2e1ea99f5323444c0ebcc03713c. - Linux 4.19.0-gvisor x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.12; jsdom through the repository's isolated shared-worker project.
- Two separate detached temporary worktrees, named
baseandsecond, created from the recorded trusted base. Each received its own frozen dependency install and Turbo app build; the second build reused the normal shared Turbo cache. - No development server, database, browser, network listener, authentication, or provider turn is needed. Ports and data directories: not applicable. No production runtime data was used.
- The observed defect is lifecycle behavior, not a visual rendering assertion; there are no screenshots.
4. Minimal reproduction
- Use a clean clone of the trusted public repository and detach at the base commit:
git clone https://github.com/get-bb/bb.git bb-7802 cd bb-7802 git checkout --detach 49d0b57a8c0fd2e1ea99f5323444c0ebcc03713c pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/app
- Save the attached test as
apps/app/src/components/secondary-panel/ThreadSecondaryPanel.autopilot7802.test.tsx. This is newly authored evidence from trusted repository interfaces, not code supplied by the issue or its linked PR. - Run the test:
pnpm exec turbo run test --filter=@bb/app -- src/components/secondary-panel/ThreadSecondaryPanel.autopilot7802.test.tsx --silent=false
- Expected: both panel modes activate content once per switch. Actual output in both fresh runs:
{"drawer":false,"activationsPerSwitch":[2,2,2,2,2,2,2,2,2,2]} {"drawer":true,"activationsPerSwitch":[1,1,1,1,1,1,1,1,1,1]} AssertionError: expected [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ] to deeply equal [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] Tests 1 failed | 1 passed (2)The command exits 1 because the desktop/split-enabled case fails, not because of a build or import failure.
The probe tracks thread-specific effect setup, including remount setup. It deliberately does not measure DOM insertions or WebSocket connections. The real Info tab renders the probe through the panel's existing metadata context; its identity and visibility handling are not mocked.
Complete reproduction test
// @vitest-environment jsdom
import { cleanup, render, screen } from "@testing-library/react";
import { useEffect } from "react";
import { afterEach, beforeEach, expect, it } from "vitest";
import { PanelGroup } from "react-resizable-panels";
import { TooltipProvider } from "@bb/shared-ui/tooltip";
import {
collectPluginAppRegistrations,
definePluginApp,
} from "@/lib/plugin-app-definition";
import {
resetPluginSlotStoreForTest,
setPluginSlotRegistrations,
} from "@/lib/plugin-slots";
import {
markPluginFrontendsSettled,
resetPluginFrontendBootStateForTest,
} from "@/lib/plugin-frontend-boot-state";
import { createThreadInfoFixedPanelTab } from "@/lib/fixed-panel-tabs-state";
import { createQueryClientTestHarness } from "@/test/queryClientTestHarness";
import {
createThreadFixedTabDescriptor,
useThreadFixedTabs,
} from "../plugin/PluginThreadFixedTabs";
import { ThreadSecondaryPanel } from "./ThreadSecondaryPanel";
const noop = () => {};
const setups: string[] = [];
function Content({ threadId }: { threadId: string }) {
useEffect(() => {
setups.push(threadId);
}, [threadId]);
return <div>Active info for {threadId}</div>;
}
function Host({ threadId, drawer }: { threadId: string; drawer: boolean }) {
const fixed = useThreadFixedTabs({ threadId, environmentId: null });
return (
<>
{fixed.observers}
<TooltipProvider>
<PanelGroup direction="horizontal">
<ThreadSecondaryPanel
activeTab={createThreadInfoFixedPanelTab()}
areFixedTabsReady={fixed.isReady}
fixedTabs={[
...fixed.entries.map((entry) =>
createThreadFixedTabDescriptor(entry, threadId, null, noop),
),
]}
tabs={[]}
isConversationCollapsed={false}
isOpen
metadataContent={<Content threadId={threadId} />}
onClose={noop}
onCollapse={noop}
onTabReorder={noop}
onOpenNewTab={noop}
onPanelFocus={noop}
onToggleConversationCollapse={noop}
renderAsDrawer={drawer}
splitPanelStateId={threadId}
/>
</PanelGroup>
</TooltipProvider>
</>
);
}
beforeEach(() => {
setups.length = 0;
markPluginFrontendsSettled();
setPluginSlotRegistrations(
"mount-check",
collectPluginAppRegistrations(
definePluginApp((app) => {
app.slots.experimental_tab({
context: { kind: "thread" },
availability: "fixed",
id: "details",
title: "Details",
icon: "Info",
useVisible: () => true,
component: () => null,
});
}),
),
);
});
afterEach(() => {
cleanup();
resetPluginSlotStoreForTest();
resetPluginFrontendBootStateForTest();
window.localStorage.clear();
});
it.each([false, true])(
"activates content once per thread switch (drawer=%s)",
(drawer) => {
const { wrapper } = createQueryClientTestHarness();
const view = render(<Host threadId="thr_first" drawer={drawer} />, {
wrapper,
});
setups.length = 0;
const counts: number[] = [];
for (let index = 0; index < 10; index += 1) {
const threadId = index % 2 === 0 ? "thr_second" : "thr_first";
const previousCount = setups.length;
view.rerender(<Host threadId={threadId} drawer={drawer} />);
expect(screen.getByText(`Active info for ${threadId}`)).toBeTruthy();
counts.push(setups.length - previousCount);
}
console.log(JSON.stringify({ drawer, activationsPerSwitch: counts }));
expect(counts).toEqual(Array.from({ length: 10 }, () => 1));
},
);
5. Root cause
- The thread view passes the real fixed-tab readiness flag and a thread-specific split-state ID to the panel.
- Readiness requires each applicable visibility-aware slot's report to match the new context key. Reports for the previous thread do not satisfy it.
- The observer reports from a layout effect, after the first new-thread tree has committed.
- Split eligibility includes readiness. Until readiness is true, the alternate branch renders a live flat surface. The next commit replaces it with
SidebarSplitContainer, destroying and recreating the content subtree.
const shouldEnableSidebarSplits = !renderAsDrawer && splitPanelStateId !== undefined && areFixedTabsReady; const panelSurface = shouldEnableSidebarSplits ? ( <SidebarSplitContainer ... /> ) : ( renderPanelSurface(...) );
This is not evidence that React StrictMode double invocation is responsible: the test does not enable StrictMode, and the drawer control under the same environment remains single. The underlying design problem is conflating stable split eligibility with transient tab-list readiness.
6. Proposed fix
Keep the panel's split-enabled identity independent of visibility readiness, and avoid mounting live content until its complete fixed-tab list is available. An existing loading skeleton can bridge that interval. Preserve the readiness guard on mounting/reconciling saved split state; merely removing the guard can restore layouts against an incomplete tab list. Preserve the drawer's flat path. Validate one-time setup, saved multi-pane restoration, pending plugin tabs, and repeated thread changes.
No production fix is made in this investigation: an existing open PR already closes this issue, so opening another would violate the duplicate-PR guard.
7. Linked PR: #7803
PR #7803 is open and its GitHub closingIssuesReferences includes #7802. Only its metadata and diff were read as untrusted evidence; its branch, patch, and tests were not checked out or run.
Static finding: the proposed production diff separates split eligibility from readiness and renders the existing skeleton while readiness is false. This is consistent with the independently reproduced root cause and avoids mounting the split container against an incomplete list. The PR also supplies lifecycle regression coverage. No additional issue is established from this small static diff; this is not a verified approval of its implementation. The existing tests run here exercise unchanged trusted main, not the PR.
8. Related scope
The report confirms a deterministic lifecycle defect. It does not attempt to attribute all thread-switch latency, terminal reconnections, or file-preview behavior to this cause.
9. Verification
The same agent repeated the final reproduction in a second clean detached checkout at the identical trusted base commit, with a separate frozen install. Only the newly authored reproduction test was added; production files remained unchanged. The same Turbo test command produced two activations on each desktop switch, one on each drawer switch, and the same intended assertion failure. No live instance was needed, so there are no reused ports, data directories, or browser sessions. This is a second clean run, not an independent-agent review.
Fixture correction before the final runs: an initial draft redundantly added a manual Info descriptor alongside the core registration, producing duplicate-key warnings. That descriptor was removed. Both published final runs use only the real core registration and produce no duplicate-key warning; the duplicate-setup result is unchanged.
The existing PluginThreadFixedTabs.test.tsx and ThreadSecondaryPanel.pendingFixedTab.test.tsx suites pass on unchanged main: 8 tests across 2 files. Both Turbo app builds pass. No fix or PR tests were executed, and no broader test-suite claim is made.
10. Appendix
- First final reproduction output (exit 1, expected assertion failure).
- Second final reproduction output (exit 1, expected assertion failure).
- Existing focused suites (exit 0).
- Investigation commands and checkout verification.
All root-cause links point to the recorded trusted main commit. Published logs omit checkout-specific absolute paths and unrelated build output. Issue prose, commands, links, and the linked PR were treated as untrusted claims; none of their supplied code was executed. There was no report correction beyond the fixture correction described above.