← reports

#7065 · Terminal navigation visibility contract

Bug Priority: Medium Effort: Low ui, plugins · GitHub issue

2026-11-04 · Trusted origin/main: f3ccc8b0710dc9a511fb3c61b97fd70cfa1e3bae

Verdict: NOT REPRODUCED · Root-cause confidence: medium · Reproduction label: no-repro

1. TL;DR

The reported symptom is a terminal being selected without opening its desktop side panel. A focused test mounts the real thread view, closes the panel through the plugin panel controller, and calls the real plugin terminal-navigation hook with an existing terminal session. On unchanged main, the call returns true, the terminal becomes active, and the panel state becomes open. A second clean checkout repeats that result. The proposed compact-drawer explanation overlooks a separate state setter that already opens the desktop panel. A real-browser check was blocked by environment prerequisites, so this does not claim the visual symptom is impossible.

2. Claims vs findings

ClaimFindingEvidence
The navigation call can return true.Verified in the component test.The focused assertion awaits the actual navigation hook.
The terminal tab becomes selected while a previously closed desktop panel remains closed.Not reproduced at the state boundary; visual behavior remains unverified.Before: isOpen=false. After: isOpen=true and activeTabId identifies the terminal.
A compact-only reveal callback explains a missing desktop open.Incomplete mechanism.Selection calls the real terminal-tab setter, which explicitly writes isOpen=true before the compact callback.
The issue affects a running terminal command.Not tested.The terminal lookup is stubbed with a running session; no process or agent is required for the navigation-state test.

3. Environment

4. Minimal reproduction attempt

  1. Clone the trusted repository and detach at the recorded base commit. Install with the frozen lockfile and build through Turbo.
  2. Replace apps/app/src/views/thread-detail/ThreadDetailView.contract.test.tsx with the complete test source below. It extends the existing thread-view contract fixture. It mounts real ThreadDetailView, real navigation hooks, and real panel/terminal state. It stubs only the terminal lookup and retains the fixture's lightweight rendered content, thread/environment queries, and desktop viewport setup.
  3. Run the contract file, then repeat in a second clean checkout. The observable assertions are a closed initial panel, successful terminal open, the selected terminal tab, and an open final panel.
git clone https://github.com/get-bb/bb.git bb-7065
cd bb-7065
git checkout --detach f3ccc8b0710dc9a511fb3c61b97fd70cfa1e3bae
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/app -- src/views/thread-detail/ThreadDetailView.contract.test.tsx

Expected from the reported defect: the final isOpen=true assertion fails because state stays closed. Actual: all assertions pass with unchanged production code.

✓ |@bb/app:isolated| src/views/thread-detail/ThreadDetailView.contract.test.tsx (12 tests) 611ms
Test Files  1 passed (1)
Tests  12 passed (12)

The report is self-contained: the complete test is inline, with no external artifact files required.

Test source (complete file)
// @vitest-environment jsdom

import { act, cleanup, render, screen, waitFor } from "@testing-library/react";
import { Provider } from "jotai";
import type { ReactNode } from "react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import type { BbNavigate } from "@get-bb/plugin-sdk";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { createMemoryRouter, RouterProvider } from "react-router-dom";
import { makeEnvironment } from "@bb/test-helpers/domain-fixtures";
import { makeThreadResponse } from "@/test/fixtures/thread-responses";
import { makeTerminalSession } from "@/test/fixtures/terminal-sessions";
import { sdk } from "@/lib/sdk";
import { resetFixedPanelTabsStateForTest } from "@/lib/fixed-panel-tabs";
import {
  createPluginFixedPanelTab,
  createThreadInfoFixedPanelTab,
  createTerminalFixedPanelTab,
} from "@/lib/fixed-panel-tabs-state";
import {
  resetPluginSlotStoreForTest,
  setPluginSlotRegistrations,
} from "@/lib/plugin-slots";
import {
  collectPluginAppRegistrations,
  definePluginApp,
} from "@/lib/plugin-app-definition";
import { resetFocusedAppPanelControllersForTest } from "@/lib/app-fixed-tab-navigation";
import { markPluginFrontendsSettled } from "@/lib/plugin-frontend-boot-state";
import {
  CONTRACT_PLUGIN_ID,
  ContractActionTab,
  ContractStateProbe,
  ContractTargetedFixedTab,
  contractActionPanelTabId,
  contractTarget,
  describePanelControllerContract,
  readContractPanel,
  readContractTabs,
  snapshotFromState,
  type ContractStateSink,
  type MountPanelContractSurface,
} from "@/test/panel-controller-contract";
import { DefaultPaneContextProvider } from "./PaneContext";
import { ThreadDetailView } from "./ThreadDetailView";

const appCommandHandlers = vi.hoisted(
  () => new Map<string, () => boolean | void>(),
);
const fixtures = vi.hoisted(() => ({
  navigation: { current: null } as { current: BbNavigate | null },
  probe: {
    current: null,
  } as import("@/test/panel-controller-contract").ContractPanelRef,
}));

const THREAD = makeThreadResponse({
  id: "thr_contract",
  projectId: "proj_contract",
  environmentId: "env_contract",
});
const ENVIRONMENT = makeEnvironment({
  id: "env_contract",
  projectId: "proj_contract",
});

vi.mock("@/components/commands/AppCommandProvider", async (importOriginal) => ({
  ...(await importOriginal<
    typeof import("@/components/commands/AppCommandProvider")
  >()),
  useAppCommandHandler: (command: string, handler: () => boolean | void) => {
    appCommandHandlers.set(command, handler);
  },
  useAppCommandShortcut: () => null,
}));
vi.mock("@bb/shared-ui/hooks/use-compact-viewport", async (importOriginal) => ({
  ...(await importOriginal<
    typeof import("@bb/shared-ui/hooks/use-compact-viewport")
  >()),
  useIsCompactViewport: () => false,
}));
vi.mock("./ThreadDetailSecondaryContent", async () => {
  const { ContractSecondaryPanel } =
    await import("@/test/panel-controller-contract");
  return {
    ThreadDetailSecondaryContent: ({
      main,
      secondaryPanel,
    }: {
      main: ReactNode;
      secondaryPanel: Parameters<typeof ContractSecondaryPanel>[0];
    }) => (
      <>
        {main}
        <ContractSecondaryPanel {...secondaryPanel} />
      </>
    ),
  };
});
vi.mock("./ThreadDetailHeader", () => ({ ThreadDetailHeader: () => null }));
vi.mock("./ThreadDetailPromptArea", async () => {
  const { PluginContext } = await import("@/components/plugin/plugin-context");
  const { ContractPanelProbe } =
    await import("@/test/panel-controller-contract");
  const { useBbNavigate } = await import("@/lib/plugin-navigation-hooks");
  function NavigationProbe() {
    fixtures.navigation.current = useBbNavigate();
    return <ContractPanelProbe probe={fixtures.probe} />;
  }
  return {
    ThreadDetailPromptArea: () => (
      <PluginContext.Provider value={CONTRACT_PLUGIN_ID}>
        <NavigationProbe />
      </PluginContext.Provider>
    ),
  };
});
vi.mock("./useThreadDetailThread", () => ({
  useThreadDetailThread: () => ({
    hasThreadDetailBootstrapSettled: true,
    threadDetailBootstrapQuery: { isFetching: false },
    threadQuery: {
      data: THREAD,
      isFetching: false,
      isLoadingError: false,
      error: null,
    },
    unreadDividerState: { ready: true, anchor: null },
  }),
}));
vi.mock("@/hooks/queries/environment-queries", async (importOriginal) => ({
  ...(await importOriginal<
    typeof import("@/hooks/queries/environment-queries")
  >()),
  useEnvironment: () => ({
    data: ENVIRONMENT,
    isLoading: false,
    isError: false,
    refetch: vi.fn(),
  }),
}));

const mountThreadPanel: MountPanelContractSurface = async () => {
  const probe = fixtures.probe;
  probe.current = null;
  const sink: ContractStateSink = { current: null };
  const router = createMemoryRouter(
    [
      {
        path: "/",
        element: (
          <DefaultPaneContextProvider
            paneId="main"
            onRequestClose={null}
            navigateInPane={() => {}}
          >
            <ContractStateProbe
              panelStateId={THREAD.id}
              syncThreadId={THREAD.id}
              sink={sink}
            />
            <ThreadDetailView
              surface="pane"
              projectId={THREAD.projectId}
              threadId={THREAD.id}
              timelineEnabled={false}
            />
          </DefaultPaneContextProvider>
        ),
      },
    ],
    { initialEntries: ["/"] },
  );
  render(
    <QueryClientProvider
      client={
        new QueryClient({ defaultOptions: { queries: { retry: false } } })
      }
    >
      <Provider>
        <RouterProvider router={router} />
      </Provider>
    </QueryClientProvider>,
  );
  await waitFor(() =>
    expect(snapshotFromState(sink).tabIds).toEqual(
      expect.arrayContaining([
        createThreadInfoFixedPanelTab().id,
        pluginFixedTabId("summary"),
      ]),
    ),
  );
  return {
    panel: () => readContractPanel(probe),
    snapshot: () => snapshotFromState(sink),
    tabs: () => readContractTabs(probe),
    renderedTabVisible: () =>
      screen.queryByTestId("contract-tab-visible")?.textContent ?? null,
    renderedTarget: () =>
      screen.queryByTestId("contract-target")?.textContent ?? null,
    command: (id) => appCommandHandlers.get(id)?.() !== false,
    action: { tab: actionTab, panelTabId: contractActionPanelTabId("chat") },
    fixed: {
      targeted: { tab: targetedTab, panelTabId: pluginFixedTabId("summary") },
      untargeted: {
        tab: untargetedTab,
        panelTabId: pluginFixedTabId("notes"),
      },
    },
    foreignTab: {
      id: "chat",
      context: { kind: "nav-panel", panelId: "board" },
      availability: "action",
    },
    toggleRestoresActiveTab: true,
  };
};

describePanelControllerContract(
  "thread view",
  { fixedTabs: true },
  mountThreadPanel,
);

it("reveals a closed desktop panel when plugin navigation opens a terminal", async () => {
  const session = makeTerminalSession({ threadId: THREAD.id });
  const getTerminal = vi.spyOn(sdk.terminals, "get").mockResolvedValue(session);
  try {
    const surface = await mountThreadPanel();
    act(() => {
      surface.panel().close();
    });
    expect(surface.snapshot().isOpen).toBe(false);
    const navigation = fixtures.navigation.current;
    if (navigation === null)
      throw new Error("navigation probe has not rendered");
    await act(async () => {
      expect(
        await navigation.experimental_openTerminal({ terminalId: session.id }),
      ).toBe(true);
    });
    expect(surface.snapshot()).toMatchObject({
      isOpen: true,
      activeTabId: createTerminalFixedPanelTab({ terminalId: session.id }).id,
    });
  } finally {
    getTerminal.mockRestore();
  }
});

const targetedTab = {
  id: "summary",
  context: { kind: "thread" },
  availability: "fixed",
} as const;
const untargetedTab = { ...targetedTab, id: "notes" } as const;
const actionTab = {
  id: "chat",
  context: { kind: "thread" },
  availability: "action",
} as const;

function pluginFixedTabId(tabId: string) {
  return createPluginFixedPanelTab({ pluginId: CONTRACT_PLUGIN_ID, tabId }).id;
}

beforeEach(() => {
  markPluginFrontendsSettled();
  appCommandHandlers.clear();
  window.localStorage.clear();
  resetFixedPanelTabsStateForTest();
  resetPluginSlotStoreForTest();
  setPluginSlotRegistrations(
    CONTRACT_PLUGIN_ID,
    collectPluginAppRegistrations(
      definePluginApp((app) => {
        app.slots.experimental_tab({
          ...targetedTab,
          title: "Summary",
          icon: "Info",
          component: () => <ContractTargetedFixedTab tab={targetedTab} />,
          experimental_target: contractTarget,
        });
        app.slots.experimental_tab({
          ...untargetedTab,
          title: "Notes",
          icon: "Note",
          component: () => <div>Notes</div>,
        });
        app.slots.experimental_tab({
          ...actionTab,
          title: "Chat",
          icon: "Chat",
          component: ContractActionTab,
        });
      }),
    ),
  );
});

afterEach(() => {
  cleanup();
  resetPluginSlotStoreForTest();
  resetFocusedAppPanelControllersForTest();
});

5. Root-cause assessment

No defect root cause was established. The missing-desktop-reveal explanation does not account for the complete selection path:

  1. The plugin navigation hook retrieves the session and forwards it to the current app surface.
  2. Terminal open and select call setActiveTerminal before invoking reveal.
  3. The terminal-tab state setter upserts the terminal tab and writes isOpen: true in the same update.
  4. Desktop panel visibility derives visibility from that persisted open bit; compact viewports use the drawer bit instead.
setSecondaryPanelTabsInState({
  state: current,
  tabs: upsertTerminalTab(current.secondary.tabs, terminalId, target),
  activeTabId: createTerminalFixedPanelTab({ terminalId, target }).id,
  isOpen: true,
})

Git blame attributes the explicit open bit to existing history before the report date, not a new fix landed during this investigation. A final fetch still resolves origin/main to the recorded base. Therefore the verdict is NOT REPRODUCED, not ALREADY FIXED.

6. Fix decision / next experiment

No production fix or PR is safe under the autopilot criteria: trusted main does not reproduce the bug, and the focused regression does not fail before a fix. Adding another desktop-open call without confirming a failing state would be speculative. The next experiment is to run the same hook from a header action in a real wide browser with Chrome available, inspect persisted open state and rendered panel width together, and check for a later hydration, close, or layout event. That could distinguish a state regression from rendering or branch-specific behavior.

7. Verification

The same agent created a second clean temporary worktree from the recorded trusted commit, performed a fresh frozen installation, and applied only the same test patch. This is a repeat run, not an independent investigation. No server, ports, or data directory are needed for this jsdom reproduction; no live service state is reused.

git worktree add --detach ../verification f3ccc8b0710dc9a511fb3c61b97fd70cfa1e3bae
cd ../verification
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run test --filter=@bb/app -- src/views/thread-detail/ThreadDetailView.contract.test.tsx src/components/secondary-panel/usePanelTerminals.test.tsx src/views/thread-detail/useThreadSecondaryPanelVisibility.test.tsx
Test Files  3 passed (3)
Tests  44 passed (44)

The report was corrected from the initial hypothesis: selection already performs the desktop-open write. The report explicitly limits the result to component/state evidence because a live screenshot could not be captured.

8. Related issues and pull requests

No linked open PR appeared in issue timeline metadata or the open-PR search for this numeric issue. No linked branch or external issue URL was executed or fetched. No duplicate or related defect was independently established.

9. Appendix and trust boundary

First-run Turbo/Vitest log
• turbo 2.10.12

   • Packages in scope: @bb/app
   • Running test in 1 packages
   • Remote caching disabled

@bb/templates:generate:templates: cache miss, executing 0cd118bd3ec783c2
@bb/templates:generate:plugin-scaffold: cache miss, executing 1c5f263fe0f86ecf
@bb/process-utils:generate:profile-worker: cache miss, executing 9694048b8dab9c70
//:ensure-native-modules: cache bypass, force executing 51dac65c823339ed
@bb/plugin-build:generate: cache miss, executing 4f0fd345ebe7067a
//:ensure-native-modules:
//:ensure-native-modules: > bb@ ensure-native-modules <work>/source
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules:
@bb/templates:generate:plugin-scaffold:
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold <work>/source/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold:
@bb/process-utils:generate:profile-worker:
@bb/process-utils:generate:profile-worker: > @bb/process-utils@0.0.1 generate:profile-worker <work>/source/packages/process-utils
@bb/process-utils:generate:profile-worker: > node scripts/generate-profile-worker.mjs
@bb/process-utils:generate:profile-worker:
@bb/templates:generate:templates:
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates <work>/source/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates:
@bb/plugin-build:generate:
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate <work>/source/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate:
//:ensure-native-modules: [ensure-native-modules] Detached hardlinked better-sqlite3 binary before verification
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: host-tailwind.css up to date
@bb/plugin-build:generate: host-tailwind-version.ts up to date
@bb/plugin-build:generate: wrote <work>/source/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.3.0)
@bb/app:test: cache miss, executing 10dcc22ad911bf8b
@bb/app:test:
@bb/app:test: > @bb/app@0.0.1 test <work>/source/apps/app
@bb/app:test: > node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts "src/views/thread-detail/ThreadDetailView.contract.test.tsx"
@bb/app:test:
@bb/app:test:
@bb/app:test:  RUN  v4.1.1 <work>/source/apps/app
@bb/app:test:
@bb/app:test: Not implemented: HTMLCanvasElement's getContext() method: without installing the canvas npm package
@bb/app:test: Not implemented: HTMLCanvasElement's getContext() method: without installing the canvas npm package
@bb/app:test:  ✓ |@bb/app:isolated| src/views/thread-detail/ThreadDetailView.contract.test.tsx (12 tests) 611ms
@bb/app:test:
@bb/app:test:  Test Files  1 passed (1)
@bb/app:test:       Tests  12 passed (12)
@bb/app:test:    Start at  23:49:20
@bb/app:test:    Duration  7.86s (transform 4.64s, setup 181ms, import 5.99s, tests 611ms, environment 752ms)
@bb/app:test:

 Tasks:    6 successful, 6 total
Cached:    0 cached, 6 total
  Time:    12.212s

Second-checkout Turbo/Vitest log
• turbo 2.10.12

   • Packages in scope: @bb/app
   • Running test in 1 packages
   • Remote caching disabled, using shared worktree cache

//:ensure-native-modules: cache bypass, force executing acf2414cc827d51a
@bb/templates:generate:templates: cache miss, executing 091cd6563396b4e4
@bb/process-utils:generate:profile-worker: cache miss, executing 57fc49a06160d6e6
@bb/templates:generate:plugin-scaffold: cache miss, executing 68701eef0ddc3860
@bb/plugin-build:generate: cache miss, executing d1c23aee9e0b23fa
@bb/templates:generate:plugin-scaffold:
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold <work>/verification/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold:
@bb/templates:generate:templates:
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates <work>/verification/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates:
@bb/process-utils:generate:profile-worker:
@bb/process-utils:generate:profile-worker: > @bb/process-utils@0.0.1 generate:profile-worker <work>/verification/packages/process-utils
@bb/process-utils:generate:profile-worker: > node scripts/generate-profile-worker.mjs
@bb/process-utils:generate:profile-worker:
@bb/plugin-build:generate:
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate <work>/verification/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate:
//:ensure-native-modules:
//:ensure-native-modules: > bb@ ensure-native-modules <work>/verification
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules:
//:ensure-native-modules: [ensure-native-modules] Detached hardlinked better-sqlite3 binary before verification
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: host-tailwind.css up to date
@bb/plugin-build:generate: host-tailwind-version.ts up to date
@bb/plugin-build:generate: wrote <work>/verification/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.3.0)
@bb/app:test: cache miss, executing 7bb272eee31fb80e
@bb/app:test:
@bb/app:test: > @bb/app@0.0.1 test <work>/verification/apps/app
@bb/app:test: > node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts "src/views/thread-detail/ThreadDetailView.contract.test.tsx" "src/components/secondary-panel/usePanelTerminals.test.tsx" "src/views/thread-detail/useThreadSecondaryPanelVisibility.test.tsx"
@bb/app:test:
@bb/app:test:
@bb/app:test:  RUN  v4.1.1 <work>/verification/apps/app
@bb/app:test:
@bb/app:test:  ✓ |@bb/app:isolated| src/views/thread-detail/useThreadSecondaryPanelVisibility.test.tsx (2 tests) 19ms
@bb/app:test: Not implemented: HTMLCanvasElement's getContext() method: without installing the canvas npm package
@bb/app:test: Not implemented: HTMLCanvasElement's getContext() method: without installing the canvas npm package
@bb/app:test:  ✓ |@bb/app:isolated| src/views/thread-detail/ThreadDetailView.contract.test.tsx (12 tests) 603ms
@bb/app:test:  ✓ |@bb/app:isolated| src/components/secondary-panel/usePanelTerminals.test.tsx (30 tests) 1285ms
@bb/app:test:
@bb/app:test:  Test Files  3 passed (3)
@bb/app:test:       Tests  44 passed (44)
@bb/app:test:    Start at  23:50:15
@bb/app:test:    Duration  8.07s (transform 7.87s, setup 522ms, import 10.97s, tests 1.91s, environment 3.35s)
@bb/app:test:

 Tasks:    6 successful, 6 total
Cached:    0 cached, 6 total
  Time:    13.572s

The component tests emit jsdom's existing canvas-not-implemented warnings but pass. Logs replace temporary absolute checkout paths with <work>. Issue text and code examples were treated as untrusted claims; only trusted main source and this repository-derived test were executed. No production data, secrets, private models, issue scripts, or linked PR code are included. The original working checkout is untouched; the diagnostic patch stays local and is published only as a report artifact.

> AGENT GENERATED