Reports

#6289 · Responsive pane swaps discard live thread state

BugPriority: MediumEffort: Mediumui GitHub issue · October 26, 2026

Trusted main: 3a2c49a267cd2a62a96ebff880068a7c37074251

Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro

1. TL;DR

The responsive thread container replaces its component tree when compact mode changes, even with just one thread open. A focused test of the real container reproduces replacement of both the editor fixture and its scroll element in both directions. Focus disappears, the selected range resets, and scrollTop becomes zero; persisted draft text survives. This is a component lifecycle defect, not evidence that draft text is deleted. The same agent repeated the test in a second clean checkout at the same trusted commit and obtained identical results.

2. Claims vs findings

ClaimFindingEvidence / limits
A single thread is remounted on a compact transition.VerifiedReal SplitThreadArea; editor and scroller identity both change in both directions.
Focus and selection are lost.Verified at container boundaryFocused textarea fixture loses focus and selection [2,8] becomes [0,0]. This does not establish ProseMirror's exact post-remount cursor position.
Draft text is destroyed.Not observed; not required by the reported defectThe persisted draft remains identical in both runs.
Scroll state is lost.Verified at container boundaryA replacement scroll node has scrollTop 0 instead of 37.
A resize within the same mode does not remount.Verified controlA pre-transition rerender preserves node identity, focus, and range in both desktop and compact modes.
Compact and desktop expose different pane identifiers.VerifiedThe test observes main after entering compact and pane-1 after leaving it; the default context hard-codes main.
Performance measurements and the full editor's end-of-text selection.UnverifiedNo timing benchmark, full ProseMirror editor, browser, Electron, iOS, physical device, or release build was exercised.
An external prototype fixes the problem and keeps split behavior.UnverifiedNo external branch, patch, test, or linked code was fetched or run. No split-layout transition was included in this reproduction.

3. Environment

4. Minimal reproduction

The regression extends the existing owner-boundary suite rather than replacing the responsive container with a mock. The fixture substitutes a textarea and scroll div for the heavy thread detail view, as the trusted suite already does. It adds no production-only test seam and exercises the real conditional render path. Existing tests cover split maximization and drafts, but do not cross the compact boundary for one pane.

  1. Use a clean trusted checkout at the recorded main commit. Install and build:
git clone https://github.com/get-bb/bb.git bb-repro
cd bb-repro
git checkout --detach 3a2c49a267cd2a62a96ebff880068a7c37074251
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
  1. Download the authored regression patch, then apply it to the checkout and run:
git apply /path/to/breakpoint-regression.patch
pnpm exec turbo run test --filter=@bb/app -- src/views/thread-detail/SplitThreadArea.test.tsx -t 'preserves a single thread'
  1. The two parameter cases start on opposite sides of the breakpoint. Each opens one pane, types a draft, focuses the editor, selects [2,8], and sets scrollTop to 37. A same-mode rerender is the passing control. The compact-hook value then flips, and a normal layout-atom notification rerenders the real container. No physical window resize or media-query event is simulated.

Expected: editorRetained=true, focusRetained=true, selection=[2,8], scrollerRetained=true, scrollTop=37, draftRetained=true. Actual diagnostic lines, verbatim from the first test run:

{"initialCompact":false,"editorRetained":false,"focusRetained":false,"selection":[0,0],"scrollerRetained":false,"scrollTop":0,"draftRetained":true,"paneId":"main"}
{"initialCompact":true,"editorRetained":false,"focusRetained":false,"selection":[0,0],"scrollerRetained":false,"scrollTop":0,"draftRetained":true,"paneId":"pane-1"}
Test Files  1 failed (1)
Tests  2 failed | 70 skipped (72)
Process exit code: 1

The failing assertions concern node identity, focus, selection and scroll only. Draft preservation passes. This lifecycle reproduction has no pixel-rendering claim or screenshot; jsdom cannot establish browser timing or visual fidelity.

Complete regression addition

diff --git a/apps/app/src/views/thread-detail/SplitThreadArea.test.tsx b/apps/app/src/views/thread-detail/SplitThreadArea.test.tsx
index fe7c33b25..4cfdd06e4 100644
--- a/apps/app/src/views/thread-detail/SplitThreadArea.test.tsx
+++ b/apps/app/src/views/thread-detail/SplitThreadArea.test.tsx
@@ -785,6 +785,56 @@ afterEach(() => {
 });
 
 describe("SplitThreadArea", () => {
+  it.each([false, true])(
+    "preserves a single thread's live state when compact changes from %s",
+    async (initialCompact) => {
+      viewportState.compact = initialCompact;
+      const layout: SplitLayout = {
+        root: {
+          type: "pane",
+          paneId: "pane-1",
+          content: threadContent("thr-a"),
+        },
+        focusedPaneId: "pane-1",
+      };
+      const store = renderSplitArea({ path: threadPath("thr-a"), layout });
+      const editor = await screen.findByTestId<HTMLTextAreaElement>("draft-thr-a");
+      const scroller = screen.getByTestId("scroll-thr-a");
+      fireEvent.change(editor, { target: { value: "keep this draft" } });
+      editor.focus();
+      editor.setSelectionRange(2, 8);
+      scroller.scrollTop = 37;
+
+      act(() => store.set(splitLayoutAtom, { ...layout }));
+      expect(screen.getByTestId("draft-thr-a")).toBe(editor);
+      expect(document.activeElement).toBe(editor);
+      expect(editor.selectionStart).toBe(2);
+      expect(editor.selectionEnd).toBe(8);
+
+      viewportState.compact = !initialCompact;
+      act(() => store.set(splitLayoutAtom, { ...layout }));
+      const nextEditor = await screen.findByTestId<HTMLTextAreaElement>("draft-thr-a");
+      const nextScroller = screen.getByTestId("scroll-thr-a");
+      const observed = {
+        initialCompact,
+        editorRetained: nextEditor === editor,
+        focusRetained: document.activeElement === nextEditor,
+        selection: [nextEditor.selectionStart, nextEditor.selectionEnd],
+        scrollerRetained: nextScroller === scroller,
+        scrollTop: nextScroller.scrollTop,
+        draftRetained: nextEditor.value === "keep this draft",
+        paneId: paneContextRenders.get("thr-a")?.at(-1)?.paneId,
+      };
+      console.log("breakpoint-repro", JSON.stringify(observed));
+      expect.soft(observed.editorRetained).toBe(true);
+      expect.soft(observed.focusRetained).toBe(true);
+      expect.soft(observed.selection).toEqual([2, 8]);
+      expect.soft(observed.scrollerRetained).toBe(true);
+      expect.soft(observed.scrollTop).toBe(37);
+      expect.soft(observed.draftRetained).toBe(true);
+    },
+  );
+
   it("hosts Browser-tab navigation on compact plugin-panel routes", async () => {
     viewportState.compact = true;
 

5. Root cause

The production compact query is max-width 767px. The split-workspace hook is its negation:

packages/shared-ui/src/components/ui/hooks/use-compact-viewport.tsx:9

export const COMPACT_VIEWPORT_QUERY = "(max-width: 767px)";

apps/app/src/hooks/useSplitWorkspaceActive.ts:1

import { useIsCompactViewport } from "@bb/shared-ui/hooks/use-compact-viewport";

export function useSplitWorkspaceActive(): boolean {
  const isCompactViewport = useIsCompactViewport();
  return !isCompactViewport;
}

On compact, the container returns StandalonePaneContent; on desktop, the one-pane branch returns a fragment containing command handlers and WorkspacePaneContent. These are different tree shapes and component types, so the thread subtree does not retain identity.

apps/app/src/views/thread-detail/SplitThreadArea.tsx:683

  if (layout === null || currentContent === null) return null;
  if (!splitWorkspaceActive) {
    return (
      <StandalonePaneContent
        content={currentContent}
        paneId={layout.focusedPaneId}
        onRequestClose={
          currentContent.kind === "new-thread"
            ? null
            : () => closePane(layout.focusedPaneId)
        }
        onNavigateInPane={navigateInPane}
      />
    );
  }

  const commandHandlers = (
    <SplitPaneCommandHandlers
      closePane={closePane}
      focusPane={(paneId) => {
        focusPane(paneId);
        setKeyboardFocusRequest({ paneId });
      }}
      isSplitActive={isSplitActive}
      layout={layout}
      maximizedPaneId={effectiveMaximizedPaneId}
      panes={panes}
      toggleMaximizePane={toggleMaximizePane}
    />
  );

  const firstPane = panes[0];
  if (panes.length === 1 && firstPane !== undefined) {
    return (
      <>
        {commandHandlers}
        <WorkspacePaneContent
          content={firstPane.content}
          paneId={firstPane.paneId}

The compact branch wraps a page-surface thread in DefaultPaneContextProvider. The workspace branch supplies the layout pane identifier and a pane-surface thread. Even simply sharing the outer wrapper would not be sufficient if a nested page/pane switch continued to change element types.

apps/app/src/views/thread-detail/SplitThreadArea.tsx:1113

  }

  return (
    <PaneContext.Provider value={value}>
      <ThreadDetailView
        surface="pane"
        projectId={content.projectId}
        threadId={content.threadId}
        timelineEnabled={timelineEnabled}
      />
    </PaneContext.Provider>
  );
});

apps/app/src/views/thread-detail/SplitThreadArea.tsx:1143

  if (content.kind === "thread" || content.kind === "new-thread") {
    return (
      <DefaultPaneContextProvider
        onRequestClose={onRequestClose}
        navigateInPane={navigateInPane}
      >
        {content.kind === "thread" ? (
          <ThreadDetailView surface="page" />
        ) : (
          <RootComposeView />
        )}
      </DefaultPaneContextProvider>

apps/app/src/views/thread-detail/PaneContext.tsx:138

export function DefaultPaneContextProvider({
  children,
  onRequestClose,
  navigateInPane,
}: DefaultPaneContextProviderProps) {
  const value = useMemo<PaneContextValue>(
    () => ({
      paneId: "main",
      isFocused: true,
      isSplitPane: false,
      secondaryPanelHost: null,
      reservesWindowPanelToggle: false,
      onRequestClose,
      isMaximized: false,
      onToggleMaximize: null,
      isBoundedPane: false,
      isTopRow: true,

apps/app/src/views/thread-detail/ThreadDetailView.tsx:429

  const { projectId, threadId } = useRouteState();

  if (!projectId || !threadId) {
    return <ThreadDetailNotFound />;
  }

  return (
    <ThreadDetailViewInternal
      projectId={projectId}
      threadId={threadId}
      timelineEnabled
    />
  );
}

queueSplitDownload("queued-messages-list");

export function ThreadDetailView(props: ThreadDetailViewProps) {
  if (props.surface === "pane") {
    return <ThreadDetailViewInternal {...props} />;
  }
  return <RoutedThreadDetailView />;
}

6. Proposed fix and safety decision

Maintain a stable single-thread component path on both sides of the breakpoint; alter surrounding chrome without replacing the mounted editor/timeline owner. Keep route-driven thread selection correct on compact, restrict split commands to their active mode, and retain the separate handling for a new-thread page and collapsed multi-pane workspaces.

No automated fix PR: this is not safely a branch substitution alone. The current paths deliberately differ in pane identity (main versus the layout pane), route resolution, and page/pane rendering surface. Choosing a stable identity and reconciling those semantics needs a product/compatibility decision, which fails the autopilot's simple-fix gate. No external prototype was reviewed or endorsed. No production changes, fix branch, push, or fix PR were made.

7. Verification

The same agent created a second clean temporary worktree, CHECKOUT_B, directly at the recorded origin/main commit. Its initial git status was empty. After a fresh frozen install, only the locally authored regression patch was added; production source remained unchanged.

git worktree add --detach CHECKOUT_B 3a2c49a267cd2a62a96ebff880068a7c37074251
cd CHECKOUT_B
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run test --filter=@bb/app -- src/views/thread-detail/SplitThreadArea.test.tsx -t 'preserves a single thread'

Result: exit 1, two intended failures, 70 skipped. Both diagnostic JSON objects exactly match CHECKOUT_A. No report correction was needed. This is a repeated clean-checkout verification by the same agent, not independent verification.

The complete owner suite in CHECKOUT_A returns two intended new failures and all 70 pre-existing tests pass. The authored patch passes git diff --check in both checkouts and changes only one test file (50 additions, no deletions, no production changes).

8. Related issues and pull requests

Issue timeline cross-reference metadata and an open-PR search for issue 6289 showed no linked open pull request at investigation time. Narrow repository searches for compact/remount and composer/resize found no verified duplicate of this lifecycle failure. External fork links were not fetched.

9. Appendix

Command categories used: read-only GitHub metadata and classifications; trusted origin/main fetch, source inspection and history; frozen installs; Turbo SDK/full builds; two focused reproduction runs and the owner suite; diff hygiene; report generation and publication. Paths in attached logs are normalized to CHECKOUT_A, CHECKOUT_B, REPORT_WORK and HOME. No private runtime data is included.

Untrusted-data handling: issue text and comments were treated only as claims to test, not instructions. No issue-provided URL, branch, code, patch, or command was fetched or executed. The reproduction was authored from trusted repository evidence.

AGENT GENERATED