← reports

#7438 · Root composer browser ownership is not handed off

BugPriority: MediumEffort: Mediumdesktop · ui · partial-reproIssue2026-11-11 · base 365d7c5237ae270be0555b5b44ea61020252713e

PARTIALLY REPRODUCED · Root-cause confidence: high for the missing ownership handoff

1. TL;DR

The New thread composer and an existing conversation use separate panel state. A focused test of the real submission handler confirms that successful creation navigates to the conversation without moving its browser tab: the destination stays empty and closed, while the root composer retains its selected tab. Repeating this test in a second clean checkout produces the same three failed expectations. The native browser manager also deliberately rejects reattaching an existing tab under a different thread. A complete correction therefore needs coordinated UI-state and native-page ownership transfer, not just copying the saved URL. This Linux investigation did not launch the macOS desktop app, so native page continuity and the exact reported CLI output remain unverified.

2. Claims vs findings

ClaimStatusEvidence
Creating a conversation does not adopt its root browser tab.Verified at the UI state boundaryThe real RootComposeView submit callback completes and navigates, but the destination panel has no tabs.
The destination panel is closed and the next root composer keeps the tab.Verified at the UI state boundaryDestination isOpen=false; root isOpen=true, with its original selected browser ID and URL.
Moving just the tab record will preserve the native page.Refuted as a sufficient fixThe existing production-manager regression test confirms that another thread cannot reattach the same native tab.
Native page state survives the route transition and reappears on returning to New thread.Unverified end to endNo macOS/Electron display is available. Retained root UI state is verified, but no actual native page was opened.
The released macOS build and thread-scoped CLI exhibit the precise reported output.UnverifiedNo release installation or user data was accessed. The test stubs thread creation and does not call the server.

3. Environment

4. Minimal reproduction

Download the authored regression test. It replaces only the composer input surface, successful thread-creation transport, and pane navigation with test doubles. It exercises the real RootComposeView submission callback, Jotai panel state, local-storage parsing, and default navigation preference. Both state probes disable server synchronization deliberately; no claim is made about an actual server request or native rendered page.

  1. Create a fresh trusted checkout and install/build its existing dependencies:
    git clone https://github.com/get-bb/bb.git bb-repro
    cd bb-repro
    git checkout --detach 365d7c5237ae270be0555b5b44ea61020252713e
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Place the downloaded test at apps/app/src/views/RootComposeView.browser-handoff.test.tsx. Run:
    pnpm exec turbo run test --force --filter=@bb/app -- src/views/RootComposeView.browser-handoff.test.tsx
  3. The test seeds an open browser tab in the root panel and checks that it is actually loaded before submission. It clicks its synthetic composer button, waits for the real callback to navigate, then asserts that the created conversation owns the tab and the next composer does not.
  4. Expected: the created panel contains the same browser tab and stays open; the root panel is cleared. Actual: the test exits 1 with three assertions failing (destination tabs, destination open state, retained root tabs). The second run logs this state verbatim:
    {
      "createdThread": {
        "tabs": [],
        "activeTabId": null,
        "isOpen": false
      },
      "nextComposer": {
        "tabs": [
          {
            "environmentId": null,
            "id": "browser:i54ykMlPVFPgEs0g6texw:none",
            "kind": "browser",
            "title": null,
            "url": "about:blank"
          }
        ],
        "activeTabId": "browser:i54ykMlPVFPgEs0g6texw:none",
        "isOpen": true
      }
    }
  5. Run the pre-existing native ownership regression:
    pnpm exec turbo run test --force --filter=@bb/desktop -- test/desktop-browser-view-manager.test.ts -t 'rejects a different thread reattaching the same native tab without mutating it'
    It passes in both checkouts (1 passed, 114 skipped). It confirms the native manager retains ownership rather than automatically transferring it.
Complete reproduction test
// @vitest-environment jsdom

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import {
  act,
  cleanup,
  fireEvent,
  render,
  screen,
} from "@testing-library/react";
import { Provider, createStore } from "jotai";
import { afterEach, expect, it, vi } from "vitest";
import type { NewThreadComposerProps } from "@/components/promptbox/NewThreadComposer";
import {
  createBrowserFixedPanelTab,
  createEmptyFixedPanelTabsState,
  getFixedPanelTabsStateStorageKey,
  serializeFixedPanelTabsState,
} from "@/lib/fixed-panel-tabs-state";
import {
  resetFixedPanelTabsStateForTest,
  useFixedPanelTabsState,
} from "@/lib/fixed-panel-tabs";
import { RootComposeView } from "./RootComposeView";
import { ROOT_COMPOSE_FIXED_PANEL_STATE_ID } from "./RootComposePanelTabContent";

const controls = vi.hoisted(() => ({
  createThread: vi.fn(),
  navigate: vi.fn(),
}));

vi.mock("@/hooks/mutations/thread-runtime-mutations", () => ({
  useCreateThread: () => ({ mutateAsync: controls.createThread }),
}));

vi.mock("@/views/thread-detail/PaneContext", async (importOriginal) => ({
  ...(await importOriginal<
    typeof import("@/views/thread-detail/PaneContext")
  >()),
  usePaneContext: () => ({ navigateInPane: controls.navigate }),
}));

vi.mock("@/components/promptbox/NewThreadComposer", () => ({
  NewThreadComposer: ({ onSubmit }: NewThreadComposerProps) => (
    <button
      onClick={() =>
        void onSubmit({
          projectId: "project-repro",
          providerId: "provider-repro",
          model: "model-repro",
          reasoningLevel: "high",
          permissionMode: "auto",
          executionInputSources: {},
          environment: { type: "project-default" },
          input: [{ type: "text", text: "Ownership probe", mentions: [] }],
        })
      }
    >
      Create conversation
    </button>
  ),
}));

function PanelProbe({ stateId }: { stateId: string }) {
  const state = useFixedPanelTabsState(stateId, null);
  return (
    <output data-testid={stateId}>{JSON.stringify(state.secondary)}</output>
  );
}

afterEach(() => {
  cleanup();
  window.localStorage.clear();
  resetFixedPanelTabsStateForTest();
  vi.clearAllMocks();
});

it("moves the root browser tab into the created conversation and clears the next composer", async () => {
  resetFixedPanelTabsStateForTest();
  const browser = createBrowserFixedPanelTab({
    environmentId: null,
    url: "about:blank",
  });
  const initial = createEmptyFixedPanelTabsState();
  const root = {
    ...initial,
    lastUsedAt: Date.now(),
    secondary: { isOpen: true, activeTabId: browser.id, tabs: [browser] },
  };
  window.localStorage.setItem(
    getFixedPanelTabsStateStorageKey({
      threadId: ROOT_COMPOSE_FIXED_PANEL_STATE_ID,
    }),
    serializeFixedPanelTabsState({ state: root }),
  );
  controls.createThread.mockResolvedValue({
    id: "thread-created",
    projectId: "project-repro",
  });
  const queryClient = new QueryClient({
    defaultOptions: { queries: { retry: false } },
  });
  render(
    <QueryClientProvider client={queryClient}>
      <Provider store={createStore()}>
        <PanelProbe stateId={ROOT_COMPOSE_FIXED_PANEL_STATE_ID} />
        <PanelProbe stateId="thread-created" />
        <RootComposeView />
      </Provider>
    </QueryClientProvider>,
  );
  expect(
    screen.getByTestId(ROOT_COMPOSE_FIXED_PANEL_STATE_ID).textContent,
  ).toContain(browser.id);
  await act(async () =>
    fireEvent.click(screen.getByText("Create conversation")),
  );
  expect(controls.navigate).toHaveBeenCalledWith({
    projectId: "project-repro",
    threadId: "thread-created",
  });
  const created = JSON.parse(
    screen.getByTestId("thread-created").textContent ?? "null",
  );
  const remaining = JSON.parse(
    screen.getByTestId(ROOT_COMPOSE_FIXED_PANEL_STATE_ID).textContent ?? "null",
  );
  console.log(
    JSON.stringify(
      { createdThread: created, nextComposer: remaining },
      null,
      2,
    ),
  );
  expect.soft(created.tabs).toEqual([browser]);
  expect.soft(created.isOpen).toBe(true);
  expect.soft(remaining.tabs).toEqual([]);
  queryClient.clear();
});

5. Root cause

Successful creation never adopts the root panel

RootComposeView.tsx:408–420 awaits creation, records the new ID, resets placement, and navigates. There is no panel transfer or root-panel cleanup in this path:

const thread = await createThread.mutateAsync({ ...requestFields, ...placement, ... });
setLastCreatedThreadId(thread.id);
setPlacement(DEFAULT_THREAD_CREATION_PLACEMENT);
if (navigateToThreadAfterCreate) {
  navigateInPane({ projectId: thread.projectId, threadId: thread.id });
}

The root panel reads ROOT_COMPOSE_FIXED_PANEL_STATE_ID with syncThreadId=null (lines 697–701). Its native browser deck also receives that root ID (lines 1042–1055). Real conversation panels use their own thread ID; no implicit relationship joins the two stores.

Native ownership is a separate invariant

desktop-browser-view.ts:1705–1727 looks up an existing view by window/tab key and refuses both cold and warm entries when the supplied thread ID differs. The existing ownership-isolation test passes, confirming this is intentional behavior. Removing that guard would weaken thread isolation and is not an acceptable shortcut.

if (cold !== undefined && cold.threadId !== request.threadId) return;
...
if (existing !== null && existing.threadId !== request.threadId) {
  return;
}

Additionally, the desktop broker snapshot publisher emits host-facing tab updates only for raw thread IDs. Root-composer tabs are not automatically persisted as conversation tabs through that channel.

6. Proposed fix and simple-fix decision

Introduce an explicit, validated root-composer-to-created-thread handoff that preserves the native view, tab ID, page history, and control state. Coordinate that native ownership change with UI tab persistence, active selection, panel openness, and clearing the consumed root tab. Retain all ordinary cross-thread reattachment protections and cover failed creation and handoff failure without losing the page.

No pull request opened. A UI-only copy does not fix native ownership. A complete handoff spans app state and the desktop browser owner and needs an explicit cross-boundary contract or a deliberate change to its ownership semantics. That fails this rule's one-subsystem/no-protocol-or-security-boundary-change simple-fix gate. No production patch, fix branch, or dependency change was made. The authored test is published as evidence rather than committed as a failing test to the application repository.

7. Related work

GitHub issue cross-reference metadata and an open-PR search for issue 7438 showed no linked open pull request at investigation time. No pull-request branch or external issue-provided URL was fetched. Existing test coverage protects ordinary thread isolation, but does not exercise the initial composer-to-conversation ownership transition.

8. Verification

The same agent repeated the reproduction in a second clean temporary checkout at 365d7c5237ae270be0555b5b44ea61020252713e, with a separate frozen dependency installation and full build. Only the final authored test file was copied into that checkout. The UI command above was run with --force to prevent a Turbo cache replay. It again exits 1 with the same three contract failures: destination tabs empty, destination closed, root tab retained. The existing native guard test was also forced and passes there. No live process was needed, so ports/data directories are not applicable.

Report correction during test development: the initial seed used an expired panel timestamp. That run was discarded. The final test sets lastUsedAt=Date.now() and asserts the source tab is present before clicking. The final artifact also uses a valid permission-mode value and passes the app typecheck. The clean-checkout rerun uses this corrected final artifact. This is a repeat by one agent, not independent verification.

9. Appendix

Trust boundary: issue content was treated solely as untrusted claims. No issue-provided command, script, patch, branch, URL, or user runtime identifier was executed or reused. Test inputs and file names were authored from trusted repository code. No report comment is posted by the publisher; SlopCop supplies the final issue summary and verdict label.