Reports

#6277 · Catalog details omit close arbitration

BugPriority: MediumEffort: Lowui · desktop Issue · October 25, 2026 · base 3a2c49a267cd2a62a96ebff880068a7c37074251

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

1. TL;DR

The built-in catalog can display plugin details as tabs, but its view never registers a close-command handler or a desktop close-request listener. A renderer close request is consequently unhandled even with visible detail tabs. Desktop preload forwards that false result, and the main process closes the window. A renderer regression reproduces this for both close entry points and both viewport layouts; a second clean checkout repeats all four failures. Native macOS keyboard/menu dispatch was not exercised on this Linux host.

2. Claims vs findings

Behavior under investigationFindingEvidence
Visible catalog details do not intercept close requestsVerifiedFour pre-fix failures at the first handled=true assertion, in two checkouts.
The desktop closes after an unhandled renderer responseVerified in sourcePreload defaults handled to false; main closes on payload=false.
Existing tab-close behavior can close a neighbor and then return to the listVerified after repairThe same four cases pass through both closes, route changes, workspace state, empty/hidden-workspace fallback, and listener teardown.
Native Cmd+W gesture on macOSUnverifiedNo macOS/Electron run; the real renderer boundary and desktop source are covered instead.

3. Environment

4. Minimal reproduction

  1. Clone the trusted repository and detach at the recorded commit:
    git clone https://github.com/get-bb/bb.git bb-6277
    cd bb-6277
    git checkout --detach 3a2c49a267cd2a62a96ebff880068a7c37074251
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build --filter=@bb/app
  2. Save the complete inline patch below as regression.patch and apply it with git apply regression.patch. It extends the existing renderer test file and adds no dependencies.
  3. Run:
    pnpm exec turbo run test --filter=@bb/app -- --run src/views/ToolsView.plugin-detail.test.tsx -t 'Plugins catalog close arbitration'
  4. Expected: the request returns true, removes Automations, selects GitHub, closes GitHub on the next request, and returns false once no detail is active. Actual on unchanged production code:
    AssertionError: expected false to be true
    Tests  4 failed | 53 skipped (57)
    All four cases fail on the first close, not on setup or module resolution.

This is an event-arbitration defect, not a visual rendering defect. No screenshot is claimed.

Complete authored regression patch

Copy this patch to a local file. It supplies imports and integrates the test with existing catalog fixtures. Raw artifacts remain in local report storage, not in the public repository.

diff --git a/apps/app/src/views/ToolsView.plugin-detail.test.tsx b/apps/app/src/views/ToolsView.plugin-detail.test.tsx
index df4c7a77f..5f9ae51d9 100644
--- a/apps/app/src/views/ToolsView.plugin-detail.test.tsx
+++ b/apps/app/src/views/ToolsView.plugin-detail.test.tsx
@@ -52,6 +52,13 @@ import {
   makePluginRegistrationSet,
 } from "@/test/fixtures/plugins";
 import { LocationProbe } from "@/test/location-probe";
+import {
+  AppCommandProvider,
+  useAppCommandRunner,
+} from "@/components/commands/AppCommandProvider";
+import { pluginWorkspaceAtom } from "@/components/plugin/plugin-workspace-state";
+import { createBbDesktopApi } from "@/test/bb-desktop-test-utils";
+import type { BbDesktopCloseWindowRequestHandler } from "@bb/desktop-contract";
 
 vi.mock("@/components/layout/AppLayout", () => ({
   AppLayout: ({ children }: { children: ReactNode }) => <>{children}</>,
@@ -147,6 +154,131 @@ afterEach(() => {
   resetPluginSlotStoreForTest();
   vi.restoreAllMocks();
   vi.unstubAllGlobals();
+  delete window.bbDesktop;
+});
+
+function ClosePluginCommand({
+  onHandled,
+}: {
+  onHandled: (handled: boolean) => void;
+}) {
+  const runner = useAppCommandRunner();
+  return (
+    <button onClick={() => onHandled(runner.dispatch("panel.close", null))}>
+      Request plugin close
+    </button>
+  );
+}
+
+describe("Plugins catalog close arbitration", () => {
+  it.each([
+    ["desktop", false],
+    ["command", false],
+    ["desktop", true],
+    ["command", true],
+  ] as const)(
+    "closes active details before window fallback via %s (compact: %s)",
+    async (entryPoint, compact) => {
+      const handlers = new Set<BbDesktopCloseWindowRequestHandler>();
+      window.bbDesktop = {
+        ...createBbDesktopApi({
+          platform: "macos",
+          version: "0.0.0-test",
+          lastCheckedAt: null,
+          latestVersion: null,
+          pendingVersion: null,
+          updateAvailable: false,
+          updateDownloaded: false,
+        }),
+        onCloseWindowRequest(handler) {
+          handlers.add(handler);
+          return () => handlers.delete(handler);
+        },
+      };
+      const entries = [
+        GITHUB_CATALOG_ENTRY,
+        {
+          ...GITHUB_CATALOG_ENTRY,
+          entryId: "automations",
+          pluginId: "automations",
+          displayName: "Automations",
+          source: "builtin:automations",
+        },
+      ];
+      vi.stubGlobal(
+        "fetch",
+        vi.fn(async (input: RequestInfo | URL) => {
+          const url = String(input);
+          if (url === "/api/v1/plugins") {
+            return Response.json({ enabled: true, plugins: [] });
+          }
+          if (url.startsWith("/api/v1/plugin-catalog/search")) {
+            return Response.json({ results: entries, collections: [] });
+          }
+          return Response.json({ error: "not found" }, { status: 404 });
+        }),
+      );
+      const store = createStore();
+      store.set(pluginWorkspaceAtom, {
+        tabs: ["github", "automations"],
+        activePluginId: "automations",
+      });
+      const onHandled = vi.fn();
+      const view = renderWithQueryClient(
+        <Provider store={store}>
+          <CompactViewportOverrideProvider isCompactViewport={compact}>
+            <MemoryRouter initialEntries={["/plugins/automations"]}>
+              <AppCommandProvider>
+                <ClosePluginCommand onHandled={onHandled} />
+                <RoutedPluginsView />
+              </AppCommandProvider>
+            </MemoryRouter>
+          </CompactViewportOverrideProvider>
+        </Provider>,
+      );
+      await screen.findByRole("heading", { name: "Automations", level: 1 });
+      const requestClose = () => {
+        let handled = false;
+        act(() => {
+          if (entryPoint === "desktop") {
+            handled = [...handlers].some((handler) => handler());
+          } else {
+            fireEvent.click(
+              screen.getByRole("button", { name: "Request plugin close" }),
+            );
+            handled = onHandled.mock.lastCall?.[0] ?? false;
+          }
+        });
+        return handled;
+      };
+      expect(requestClose()).toBe(true);
+      expect(store.get(pluginWorkspaceAtom)).toEqual({
+        tabs: ["github"],
+        activePluginId: "github",
+      });
+      await screen.findByRole("heading", { name: "GitHub", level: 1 });
+      expect(screen.getByTestId("location").textContent).toBe(
+        "/plugins/github",
+      );
+      expect(requestClose()).toBe(true);
+      expect(store.get(pluginWorkspaceAtom)).toEqual({
+        tabs: [],
+        activePluginId: null,
+      });
+      expect(screen.getByTestId("location").textContent).toBe("/plugins");
+      expect(requestClose()).toBe(false);
+      act(() =>
+        store.set(pluginWorkspaceAtom, {
+          tabs: ["github"],
+          activePluginId: null,
+        }),
+      );
+      expect(requestClose()).toBe(false);
+      expect(store.get(pluginWorkspaceAtom).tabs).toEqual(["github"]);
+      view.unmount();
+      expect(handlers.size).toBe(0);
+    },
+  );
 });
 
 describe("PluginDetail official catalog lifecycle", () => {

5. Root cause

The catalog owns the correct tab-removal operation, including neighbor selection and list navigation, but its control flow goes straight from that callback to tab reordering without registering either close entry point:

apps/app/src/views/ToolsView.tsx:516

    });
  }, []);
  const closePanel = useCallback(() => {
    setIsPluginDetailFullPage(false);
    setWorkspace((current) => ({ ...current, activePluginId: null }));
    const params = new URLSearchParams(withoutPluginListing(location.search));
    params.delete("configure");
    navigate({ pathname: getPluginsRoutePath(), search: params.toString() });
    restoreFocus();
  }, [location.search, navigate, restoreFocus, setWorkspace]);
  const closeTab = useCallback(
    (closedPluginId: string) => {
      const tabs = openIds.filter((id) => id !== closedPluginId);
      const closedIndex = openIds.indexOf(closedPluginId);
      const next =
        activePluginId === closedPluginId
          ? (tabs[Math.min(closedIndex, tabs.length - 1)] ?? null)
          : activePluginId;
      setWorkspace({ tabs, activePluginId: next });
      if (next !== null) selectPlugin(next);
      else closePanel();
    },
    [activePluginId, closePanel, openIds, selectPlugin, setWorkspace],
  );
  const reorderTab = useCallback<SecondaryPanelTabReorderHandler>(
    ({ activeTabId, overTabId }) => {
      const tabs = [...openIds];
      const from = tabs.findIndex(
        (id) => `marketplace-plugin:${id}` === activeTabId,
      );

Other built-in surfaces demonstrate the existing contract: register the panel command and a desktop close-request callback, returning false only when the surface cannot handle it.

apps/app/src/views/RootComposePanelCommandHandlers.tsx:23

  useAppCommandHandler("panel.close", () => {
    if (!isFocused) return false;
    return onClose();
  });
  useEffect(() => {
    if (!isFocused) return;
    const desktopInfo = getBbDesktopInfo();
    if (desktopInfo?.onCloseWindowRequest === undefined) return;
    return desktopInfo.onCloseWindowRequest(onClose);
  }, [isFocused, onClose]);
  return null;

Without listeners, desktop preload computes false and sends it back:

apps/desktop/src/preload.ts:569

ipcRenderer.on(BB_DESKTOP_CLOSE_WINDOW_REQUEST_CHANNEL, () => {
  let handled = false;
  for (const listener of closeWindowRequestListeners) {
    handled = listener() || handled;
  }
  ipcRenderer.send(BB_DESKTOP_CLOSE_WINDOW_RESPONSE_CHANNEL, handled);
});

The desktop main-process response handler closes the application window for that false response. This is intended fallback behavior; the missing integration is in the catalog, not in desktop IPC.

apps/desktop/src/main.ts:2462

  ipcMain.on(BB_DESKTOP_CLOSE_WINDOW_RESPONSE_CHANNEL, (event, payload) => {
    const pending = pendingCloseWindowRequests.get(event.sender.id);
    if (pending !== undefined) {
      clearTimeout(pending);
      pendingCloseWindowRequests.delete(event.sender.id);
    }
    if (payload === false) {
      resolveApplicationWindow(event.sender)?.close();
    }
  });

6. Proposed fix and validation

Add one local close-active-tab callback that returns false unless a detail panel is visible and active, otherwise calls the existing closeTab and returns true. Register that same callback with panel.close and onCloseWindowRequest, retaining effect cleanup. No public protocol, SDK, stored state, dependency, or desktop change is necessary.

The implementation changes two files in the existing catalog subsystem: 143 additions, zero deletions. The focused regression passes all four cases after the fix. The complete affected catalog test and three existing close-command suites pass: 87 tests in four files. App build, typecheck, and lint pass; lint emits 246 warnings and no errors.

7. Linked PR metadata and static review

PR #6278 is closed and unmerged. Its metadata and diff were read only after independently designing and exercising the regression and implementing the repair; no branch or code from it was run. Static review shows the same two missing registrations addressed using the existing callback. Its test table covers the desktop and command paths; this investigation also covers compact layout and hidden-workspace fallback. No blocking issue was identified in that narrow diff; native gesture verification remains absent. This is not test evidence for that PR. No open PR linked to #6277 was found in the issue timeline or checked open search results.

8. Related issues

#4590 concerns plugin-owned nested panes and public arbitration access. This finding is narrower: a missing integration inside an existing built-in catalog view. It does not establish a fix for third-party nested panes.

9. Verification

The same agent repeated the regression in a second clean trusted checkout at the same full commit, with a separate frozen install and app build. The only tracked change there is the authored test patch; production code remains unchanged. The exact reproduction command above fails all four cases again with the same handled=false assertion. This is a second clean reproduction, not an independent-agent check. No correction to the renderer finding was needed; native macOS behavior remains explicitly unverified.

10. Appendix

First pre-fix checkout: AssertionError: expected false to be true
Tests  4 failed | 53 skipped (57)

Second clean pre-fix checkout: AssertionError: expected false to be true
Tests  4 failed | 53 skipped (57)

Focused post-fix run:
Test Files  1 passed (1)
Tests  4 passed | 53 skipped (57)

Affected suites:
Test Files  4 passed (4)
Tests  87 passed (87)

pnpm exec turbo run test --filter=@bb/app -- --run src/views/ToolsView.plugin-detail.test.tsx src/views/RootComposePanelCommandHandlers.test.tsx src/components/commands/AppCommandProvider.test.tsx src/components/commands/AppCommandProvider.availability.test.tsx
pnpm exec turbo run typecheck lint --filter=@bb/app
pnpm exec turbo run build --filter=@bb/app
git diff --check
git diff --numstat origin/main
132  0  apps/app/src/views/ToolsView.plugin-detail.test.tsx
11   0  apps/app/src/views/ToolsView.tsx

The initial unfiltered monorepo build failed because a plugin build attempted to consume an SDK host artifact before it existed. Explicitly building the SDK first and running the scoped app build succeeded. This bootstrap ordering failure is unrelated to close arbitration and is not changed by the repair.

Trust boundary: issue and PR contents were treated only as untrusted claims and static evidence. No supplied command, script, branch, linked URL, or patch from the issue was executed. All reproduction code was authored against the trusted repository.