← reports

#6489 · Panel visibility changes detach existing controls

Bug Priority: Medium Effort: Low ui · perf · 2026-10-28 · GitHub issue

Trusted base: 991b99020a7bf369d47a1a444e0b83af8716f4ec, fetched from origin/main.

Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium · Reproduction label: partial-repro

1. TL;DR

The desktop thread header removes its panel-toggle button when the right panel opens, and the table-of-contents component removes its rail when its measured content width drops below 896 CSS pixels. Two new component regressions demonstrate these node detachments against unchanged production code, and both fail identically in a second clean checkout of the same trusted commit. Existing tests explicitly allow the header control to disappear and therefore do not protect DOM continuity. The claim that these mutations cause page-wide Chromium :has() restyling and long animation frames remains unverified here: the required Browser Automation backend could not start because Chrome/Chromium is absent. This is a partial reproduction of the proposed trigger, not a measurement of the reported rendering stall. An existing open draft PR already closes the issue, so no competing fix was created.

2. Claims vs findings

ClaimStatusEvidence
Opening the desktop panel removes the existing header toggle.VerifiedThe captured button has isConnected === false immediately after the real component rerenders with an open panel; both clean runs agree.
A width change can remove the existing TOC rail.VerifiedThree real timeline fixtures render the real component at 1200 px. Delivering a ResizeObserver width of 800 px detaches the captured rail button in both runs.
The TOC visibility cutoff is 56 rem and needs at least three user entries.Verified, with precisionThe constants are 56 * 16 and 3: the JavaScript cutoff is fixed at 896 CSS pixels, not dynamically computed from the root font size.
These removals invalidate most of a page with relational plugin CSS.UnverifiedNo browser trace or real stylesheet workload was obtained. Component tests cannot measure a browser style engine.
Input latency is several hundred milliseconds, including a second stall during the slide.UnverifiedNo timing numbers, CPU-throttled frames, Electron run, macOS run, or mid-animation width crossing were reproduced.
Keeping the controls mounted removes the stall.Unverified performance proposalThis would remove the verified child-list mutation sites, but no production fix or before/after browser experiment was executed.

3. Environment

4. Minimal reproduction

  1. Prepare a clean checkout of the trusted base, not a pull-request branch:
    git fetch origin main
    git worktree add --detach "$BASE_CHECKOUT" 991b99020a7bf369d47a1a444e0b83af8716f4ec
    cd "$BASE_CHECKOUT"
    pnpm install --frozen-lockfile --prefer-offline

    BASE_CHECKOUT denotes a new empty temporary path. Save the patch below as regression.patch outside the checkout, and apply it with git apply /path/to/regression.patch. It adds only two tests to existing harnesses and changes no production code.

  2. Run the two focused assertions through the repository's dependency-aware runner:
    pnpm exec turbo run test --filter=@bb/app -- \
      src/views/thread-detail/ThreadDetailHeader.test.tsx \
      src/components/thread/toc/ThreadTableOfContents.test.tsx \
      -t 'issue 6489'
  3. The desired invariant is that changing panel/rail visibility does not disconnect the already-rendered control. The actual result is an expected failing regression, not an import/setup failure:
    FAIL ThreadDetailHeader > issue 6489 preserves the panel trigger node during desktop toggles
    AssertionError: expected false to be true
    expect(trigger.isConnected).toBe(true);
    
    FAIL ThreadTableOfContents > issue 6489 preserves the rail node across the content-width breakpoint
    AssertionError: expected false to be true
    expect(trigger.isConnected).toBe(true);
    
    Test Files  2 failed (2)
    Tests  2 failed | 55 skipped (57)

The TOC test deliberately delivers a ResizeObserver notification; merely changing the test host's width prop does not simulate a browser resize. Both tests execute real owning components with existing harness mocks for surrounding services. They do not execute plugin CSS, a panel animation, or a browser style calculation.

Complete investigator-authored regression patch

diff --git a/apps/app/src/components/thread/toc/ThreadTableOfContents.test.tsx b/apps/app/src/components/thread/toc/ThreadTableOfContents.test.tsx
index d2e4880a7..17693ab4b 100644
--- a/apps/app/src/components/thread/toc/ThreadTableOfContents.test.tsx
+++ b/apps/app/src/components/thread/toc/ThreadTableOfContents.test.tsx
@@ -519,6 +519,46 @@ describe("ThreadTableOfContents", () => {
     expect(lastOutlineOptions("user")).toEqual({ enabled: false });
   });
 
+  it("issue 6489 preserves the rail node across the content-width breakpoint", () => {
+    const resizeCallbacks: (() => void)[] = [];
+    vi.stubGlobal(
+      "ResizeObserver",
+      class extends ResizeObserverMock {
+        constructor(callback: ResizeObserverCallback) {
+          super(callback);
+          resizeCallbacks.push(() =>
+            callback(
+              [
+                {
+                  contentBoxSize: [{ inlineSize: 800, blockSize: 0 }],
+                  contentRect: { width: 800 },
+                } as ResizeObserverEntry,
+              ],
+              this,
+            ),
+          );
+        }
+      },
+    );
+    const timelineRows = [
+      userConversationRow(1),
+      userConversationRow(2),
+      userConversationRow(3),
+    ];
+    const view = render(<TocHost hostWidth={1200} timelineRows={timelineRows} />);
+    const trigger = screen.getByRole("button", {
+      name: "Thread table of contents",
+    });
+
+    act(() => resizeCallbacks.forEach((callback) => callback()));
+
+    expect(trigger.isConnected).toBe(true);
+    view.rerender(<TocHost hostWidth={1200} timelineRows={timelineRows} />);
+    expect(
+      screen.getByRole("button", { name: "Thread table of contents" }),
+    ).toBe(trigger);
+  });
+
   it("does not request the outline when padding hides the TOC", () => {
     render(
       <TocHost
diff --git a/apps/app/src/views/thread-detail/ThreadDetailHeader.test.tsx b/apps/app/src/views/thread-detail/ThreadDetailHeader.test.tsx
index 5f6f4e246..f86cabe5a 100644
--- a/apps/app/src/views/thread-detail/ThreadDetailHeader.test.tsx
+++ b/apps/app/src/views/thread-detail/ThreadDetailHeader.test.tsx
@@ -179,6 +179,28 @@ afterEach(() => {
 });
 
 describe("ThreadDetailHeader", () => {
+  it("issue 6489 preserves the panel trigger node during desktop toggles", () => {
+    const header = (open: boolean) => (
+      <PaneContext.Provider value={PANE_CONTEXT}>
+        <ThreadDetailHeader
+          actionsMenu={null}
+          isSecondaryPanelOpen={open}
+          onToggleSecondaryPanel={vi.fn()}
+          thread={THREAD_TARGET}
+          threadTitle="Panel state"
+        />
+      </PaneContext.Provider>
+    );
+    const view = render(header(false));
+    const trigger = screen.getByRole("button", { name: "Show right panel" });
+
+    view.rerender(header(true));
+
+    expect(trigger.isConnected).toBe(true);
+    view.rerender(header(false));
+    expect(screen.getByRole("button", { name: "Show right panel" })).toBe(trigger);
+  });
+
   it("leaves the open right-panel collapse control to the panel header", () => {
     render(
       <PaneContext.Provider value={PANE_CONTEXT}>

No screenshot is presented: this is a DOM-lifecycle reproduction of a performance report, not a reproduced visual appearance defect. A static screenshot would not establish the claimed rendering cost.

5. Root cause

Verified structural cause: visibility is implemented through conditional subtree existence. In the header visibility policy, a non-compact panel with no separate panel host makes showRightPanelToggle false once open. The conditional button rendering then unmounts the existing button rather than just changing its visibility.

const showRightPanelToggle =
  secondaryPanelHost === null && (!isSecondaryPanelOpen || isCompactViewport);

{showRightPanelToggle ? (
  <Button ... />
) : null}

The TOC ResizeObserver callback converts content width to a Boolean using the fixed width/message thresholds. That Boolean controls the rail subtree. Its outer root remains, but its button and descendants do not.

setVisible(inlineSize >= TOC_MIN_VISIBLE_WIDTH_PX);

{tocVisible ? (
  <div className="relative">...rail...</div>
) : null}

Hypothesized browser consequence, not measured: structural mutations can interact with relational selectors in user/plugin stylesheets. These verified mutation sites are consistent with the proposed explanation, but do not establish how much of a particular page Chromium invalidates. The confidence is medium for the issue's full root cause; confidence in the two DOM-detachment facts is high.

6. Proposed fix

Separate mounting policy from visibility for both controls. Retain the already-created header button and TOC rail, and hide only their own elements when unavailable. Preserve keyboard/accessibility behavior, compact-header behavior, and the existing TOC outline-query gating. Avoid hiding or making the app root inert. A follow-up browser measurement must compare child-list mutations, style recalculation, and input-to-first-frame timing under the same relational CSS workload before claiming a performance fix.

7. Linked PR: #6490

PR #6490 is open and draft, and its GitHub closingIssuesReferences includes issue 6489. Static review used head c3370ce9d04b38eac4aa029de5a73040c09c23b2: 4 files, 199 additions and 122 deletions. Its diff separates header mount/visibility conditions and retains the TOC subtree while toggling a hidden class and element-local inert. It also adds node-retention tests.

Static verdict: the proposed changes target both verified mutation sites. No blocker is established by this narrow read. The branch was not checked out, built, or executed; its tests and performance claims are not validated by this report. No competing branch or PR was created because this open linked PR already owns the fix.

8. Related issues

Repository triage search found #5416, another plugin-CSS/menu performance report classified Bug / Medium / Medium with a partial reproduction. This is relevant background, not evidence of identical causality or a duplicate determination. No external link supplied in issue content was fetched.

9. Verification

The same investigator repeated the reproduction, not an independent investigator. A new clean detached worktree was created at 991b99020a7bf369d47a1a444e0b83af8716f4ec, received only the investigator-authored two-test patch above, then ran a separate frozen install and the same focused Turbo command. The app test task executed live rather than replaying a successful cached test result.

RunResultVitest duration
Base checkout, 22:12 UTCBoth node-retention assertions fail: existing control is disconnected.4.85 s
Second clean checkout, 22:13 UTCSame two failures; no production changes.4.86 s
Existing owner suites, excluding the new expected-failing regressions55 passed, 2 skipped; 2 test files passed.5.55 s

Correction made during investigation: an initial TOC experiment merely changed a mocked host width and did not deliver a ResizeObserver event; it did not reproduce the removal. The published test fixes that experiment by delivering the callback explicitly, and the corrected test fails in both checkouts. The report is verified only for this partial verdict: it does not upgrade structural evidence into a browser-performance reproduction.

10. Appendix and limits

pnpm exec turbo run test --filter=@bb/app -- \
  src/views/thread-detail/ThreadDetailHeader.test.tsx \
  src/components/thread/toc/ThreadTableOfContents.test.tsx \
  -t '^(?!.*issue 6489)'

Test Files  2 passed (2)
Tests  55 passed | 2 skipped (57)

pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build

Tasks: 72 successful, 72 total

git diff --check
Exit status: 0

The broad verification inventory reported an unmapped diagnostics CLI family; no unrelated documentation baseline was changed. Browser-driven panel/preview lifecycle verification remains blocked by missing Chrome. iOS Safari and Electron were not tested.

All issue prose, comments, and PR diff content were treated as untrusted evidence, not executable instructions. No linked PR code, issue-supplied script, private runtime data, or credential was executed/read. Raw local logs and the regression artifact remain outside this public site; the report includes the complete portable reproduction inline.