Skip to content

Let plugins list, select and close every side panel tab - #6594

Merged
ymichael merged 7 commits into
mainfrom
bb/panel-tabs-api-thr_an3vhi6xak
Oct 29, 2026
Merged

ymichael merged 7 commits into
mainfrom
bb/panel-tabs-api-thr_an3vhi6xak

Conversation

@ymichael

@ymichael ymichael commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A plugin could open, toggle and close only the side panel tabs it registered itself. Nothing told it which tabs were open, and it could not select or close bb's own tabs (Browser, terminal, Diff, Info, files) or another plugin's. That blocks a "float this tab" control for the floating tabs work and a thread context card section listing open terminals and Browser pages. Underneath, the panels had no single tab model to expose: plugin detail tabs were an in-memory overlay on the thread, New thread and plugin page panels; the Plugins browse page kept its own tab list and had no panel controller; and each of the four surfaces built its tab strip with its own copy of the same per-kind switch.

What changed

Plugin detail tabs are ordinary panel tabs (plugin-detail kind in client-core's FixedPanelTabsState):

  • They survive reloads on the thread view, New thread screen and plugin pages (the browse page already did), take part in splits instead of turning them off, and reopen like other tabs. Each thread keeps its own.
  • They stay out of thread-tab server sync; a sync from another client keeps them where they are (thread-tabs-sync.ts).
  • The Plugins browse page moves onto the shared state; its URL still selects the tab, and tabs saved under bb.plugins.workspace.tabs move over once.
  • Removed: the detail overlay (usePluginDetailPanelProps/usePluginDetailPanelState), the browse page's pluginWorkspaceAtom, and the closed-tab history's detail special case and tab-order store.

One tab-strip presenter (usePanelTabPresenter.tsx) gives every surface the same label, icon, status and pinned state; surfaces keep only select, close and content. Visible change: plugin pages show the file-type and plugin action icons the other panels already showed.

Plugin API (experimental, plugin SDK 0.6.103 → 0.6.104):

  • experimental_usePanelTabs() → { open, selectedKey, tabs }, the tab strip's list and order for the surface the component renders in, live. Each tab is { key, title, status, closable, detail }; detail is info, file, browser, terminal, new-tab, plugin (tab reference and params) or plugin-details.
  • ExperimentalPanelController gains getTabs() (the same list once, for commands and other non-component code), selectTab(key) and closeTab(key).
  • experimental_PanelTabIcon({ tabKey }) draws the strip's icon.
  • Testing: renderSlot takes experimental_panelTabs and logs selectTab/closeTab; @get-bb/plugin-sdk/testing exports experimental_makePanelController(overrides?) so tests stop hand-building controllers (Git, side-chat and SDK tests moved onto it).

Core uses the same path. Each surface renders AppPanelTabsPublisher with the same tab objects it gives ThreadSecondaryPanel; it writes into that surface's useAppPanelController store, and the hook, getTabs, selectTab, closeTab and the icon read that store. selectTab/closeTab call the strip's own onSelect/onClose, so closing a terminal's tab ends the terminal. The browse page gets a panel controller like the other surfaces.

Docs: docs/api_to_audit.md (new "Open panel tabs" entry), Plugin Guide side-panel surface, bb-guide frontend-panel-tabs.md (new, routed from SKILL.md), frontend-hooks-and-ui.md, frontend-components.md, testing.md, API indexes.

Behaviour changes to know about:

  • Plugin detail tabs persist locally per surface across reloads and no longer clear when the thread or workspace changes; each thread keeps its own.
  • Opening plugin details from a thread (for example "View details") adds a tab to that thread's panel, like any other tab.
  • The Plugins browse page has its own panel controller, registered as focused when its pane is (paneContext?.isFocused ?? true), so focused-surface commands now reach it.
  • Tabs saved under bb.plugins.workspace.tabs move into the browse page's panel state once, and the old key is removed.
  • Legacy git-diff tabs are left out of the plugin-facing list; Diff appears as the Git plugin's plugin tab.
  • The backend API index no longer lists frontend-only types (ExperimentalThreadContextKind, the panel tab types); the frontend index has them, and this keeps the shipped skill under its 500-line reference limit.

No server/daemon wire changes; thread tabs saved on the server are unchanged.

How you verified

  • turbo typecheck across all 54 plugins, @bb/server, @bb/cli, mobile and web (57 tasks); turbo typecheck lint test for the SDK, @bb/app (full suite), client-core, domain, Git, side-chat, Plugin Guide, bb-guide, plugin-build and templates (32 tasks); server plugin and docs tests (578).
  • The shared panel controller contract (apps/app/src/test/panel-controller-contract.tsx) now lists, selects and closes by key, checks getTabs() against the hook, and checks fixed tabs refuse to close, on the thread view, New thread screen and plugin page; the browse page test checks it publishes its tabs. app-panel-tabs.test.tsx covers the kind → detail table, routing through the strip's handlers, and that plugins re-render only when listed data changes.
  • New tests for detail tabs: kept local through a remote sync without being saved; opened in the focused pane only, no duplicates, close and reopen; the browse page's one-time migration. The existing bulk-close tests caught a stale-closure bug in my first browse page version (fixed).
  • Browser, on a start:worktree server: browse page detail tabs and a thread's "View details" tab survive reload; the thread's server-saved tabs still list only Info and Diff.
  • End to end with a throwaway path plugin that used only the new API (an "Open tabs" thread context card section): it listed Info and Diff with Info selected; selecting from it opened the panel and moved bb's strip selection; a new tab from bb's "+" appeared with its icon; closing it from the plugin removed it from bb's strip.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 7 commits October 29, 2026 15:11
Plugin details were an in-memory overlay on the thread, New thread and
plugin page panels, and the plugins browse page kept its own tab list. They
are now a plugin-detail tab kind in the shared panel tab state: they survive
reloads, take part in splits, reopen like other tabs, and stay out of
thread-tab server sync. The browse page uses the same state, migrating its
saved tabs once, and its URL still selects the tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The thread view, New thread screen, plugin page and plugins browse page each
had their own switch turning panel tabs into strip entries. One presenter now
gives every surface the same label, icon, status and pinned state; surfaces
keep only their select, close and content behaviour. Plugin pages pick up the
file-type and plugin action icons the other panels already showed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
experimental_usePanelTabs() returns the side panel's open tabs, bb's and
plugins', in the tab strip's order with what each shows, and the panel
controller gains selectTab(key) and closeTab(key). Each surface publishes the
same tab objects its strip renders, so these calls run the strip's own select
and close. experimental_PanelTabIcon draws a tab's icon. The Plugins browse
page gets a panel controller like the other surfaces. Plugin SDK 0.6.104.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ExperimentalPanelController.getTabs() returns the same list
experimental_usePanelTabs() follows, once, for commands, thread actions and
other code that is not a component. Also updates the Git and side-chat
plugins' test stubs for the panel controller's new members.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@get-bb/plugin-sdk/testing exports experimental_makePanelController: every
method declines and getTabs() reports a closed, empty panel unless a test
overrides it. The Git and side-chat plugin tests and the SDK's own tests use it
instead of hand-built controllers, so a new controller member no longer breaks
each of them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The backend index had grown past the shipped-skills 500-line limit. The panel
tab types and ExperimentalThreadContextKind are frontend-only and already
listed in the frontend index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Compare the plugin-facing tab list field by field instead of serializing it on
every surface render, check that selecting a content tab reopens a closed
panel on every surface, and inline the plugin page's leftover aliases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 29, 2026
…bs (#6611)

## Human comments

## What was wrong

Two races in the client's thread-tab sync (`apps/app`), both on `main`,
found while testing #6594:

1. **A new terminal jumps back to Info.** Closing a terminal saves the
thread's tabs, and the realtime "tabs changed" event starts a fetch of
the saved list. Starting a new terminal then saves a newer list (higher
revision). If that earlier fetch lands last, React Query writes the
older list into the cache, hydration drops the new terminal's tab,
selection falls back to Info, and the terminal sync re-adds the tab
unselected. Nothing compared revisions: neither `setCachedThreadTabs`
nor the `useThreadTabs` fetch. Network latency (bb Connect) makes the
late landing likelier.
2. **Pinned tabs get reordered (Diff saved before Info).** A device that
has never opened a thread's panel starts with an empty local list and
seeds it with the pinned tabs available at that moment, often just Info
(the Git plugin's Diff tab isn't available yet). On save,
`mergeThreadTabChanges(server=[info, diff], previous=[], next=[info])`
treated Info as newly added and appended it after the server's tabs,
saving `[diff, info]` for every device, permanently.

## What changed

- **Keep the newer tab list**
(`hooks/cache-owners/thread-tabs-cache-owner.ts`,
`hooks/queries/thread-tabs-query.ts`): `setCachedThreadTabs` and the
`useThreadTabs` fetch (via `resolveFetchedThreadTabs`) keep whichever
list has the higher revision. Both are needed because React Query writes
fetch results straight into the cache. Revisions only increase on the
server (`replaceStoredThreadTabs` checks the expected revision and
stores revision + 1), so a real change from another device always wins.
- **Keep server positions for tabs a device "adds" that the server
already has** (`lib/thread-tabs-sync.ts`, `mergeThreadTabChanges`),
unless the local list deliberately places the tab before another server
tab. That exception keeps the existing case where a registered Browser
tab replaces a New tab placeholder.

No server, wire or SDK changes.

## How you verified

- New tests, each failing before its fix and passing after:
- `fixed-panel-tabs-sync.test.ts` "keeps a newer saved tab list when an
older tab fetch lands last": real hooks and query cache; a terminal
close saved as rev 2, the triggered fetch hangs, a new terminal saved as
rev 3, then the fetch returns rev 2. Before: cache rolled back to rev 2
without the terminal. After: rev 3 with the terminal selected.
- `thread-tabs-sync.test.ts` "keeps a server tab in place when a device
that never loaded the list adds it": server `[info, diff]` + previous
`[]` + next `[info]` → `[info, diff]` (was `[diff, info]`).
- `pnpm exec turbo run typecheck lint test --filter=@bb/app`: 8 tasks
green (6,501 tests).
- Live repro on `start:worktree` servers with the same data, `main` vs
this branch:

| Repro | `main` | This branch |
|---|---|---|
| Close a terminal, immediately start another, with tab fetch responses
held 1.5 s in the browser (forces the late landing) | 5/5 bad: terminal
dropped, Info active, terminal re-added unselected ~2.5 s later | 5/5
ok: terminal stays selected |
| Fresh browser profile, open the Pull request thread's panel and start
a terminal right after load, server order reset to `[info, diff]` each
time | Flipped to `[diff, info]` in 2 of 3 | 0 of 3 |

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit c87815d into main Oct 29, 2026
52 checks passed
@ymichael
ymichael deleted the bb/panel-tabs-api-thr_an3vhi6xak branch October 29, 2026 23:47
nesyeklaf added a commit to nesyeklaf/sandy that referenced this pull request Nov 1, 2026
…ump rail (#39)

## Human comments

## What was wrong

Plugins had no way to add typeahead menus to the composer. Only the built-in `/` commands and `@` mentions opened a menu, so a plugin that wanted a menu of its own (for example skills sorted by use case) had to build a separate picker. Long menus with several groups also had no quick way to jump between groups. Both commits were built in thread thr_2awpg9fnrd. The server on this host (Netcup) has been running them since 13:18 today from a build of `1a8d78591`, which was never on main. A release built from main alone would have dropped them, so they land here first.

## What changed

- `b666d5b40` Let plugins add composer menus and submenus (`experimental_menus`):
  - `packages/plugin-sdk/src/app-contract.ts`: `ComposerCustomization.experimental_menus` registers `{ id, trigger, label, items(query) }`. `trigger` is `/`, `#`, `!` or `~`. `/` adds a group to the command menu; the others open their own menu, also on a bare trigger. A row with `items` is a submenu (Enter, click or right arrow opens it; left arrow, Backspace on an empty query or Escape goes back). A leaf row runs `run({ composer })` after the host removes the trigger text. `ExperimentalComposerContributions.menus` and `runMenuItem` let other composers render the same menus. Menu ids are validated in `internal/composer-customization-validation.ts`.
  - `apps/app`: `PluginComposerMenus.tsx`, the slot resolver and composer hooks collect the registered menus and hand them to the composer.
  - `plugins/composer`: `mentions/plugin-menu.ts` turns the registrations into rows of the existing `/` and `@` menu (`MentionMenu.tsx`, `PromptBoxInternal.tsx`, `typeahead-suggestions.ts`).
  - Docs: an `experimental_` entry in `docs/api_to_audit.md` with its stabilization checks, the Plugin Guide surface in `plugins/plugin-api-docs/src/surfaces.ts`, and the plugin-authoring references in `plugins/sandy-guide`.
- `1a8d78591` Add a group jump rail to the composer typeahead menu: `plugins/composer/src/mentions/MentionMenu.tsx` shows a rail of group labels when the results have more than one group. It marks the group of the selected row and scrolls to a group on click.
- `packages/domain/src/plugin-sdk-version.ts` and `packages/plugin-sdk/package.json`: `PLUGIN_SDK_VERSION` 0.6.104 → 0.6.105, because `app-contract.ts` gains public surface (the Version Lockstep check asks for it). The 17 `extensions/sandy/*/package-lock.json` files still say 0.6.104; earlier bumps (get-bb#6594) left them alone too.
- No server/daemon wire change, so `HOST_DAEMON_PROTOCOL_VERSION` stays 261.

## How you verified

On Netcup (Linux, Node 22.19.0), local branch `a7e568e0b` + both commits cherry-picked (no conflicts):
- `scripts/fork/release.sh test`: 109 files, 1202 passed, 2 skipped.
- `plugins/composer` `vitest run`: 11 files, 102 passed, 3 skipped (includes the new `mentions/plugin-menu.test.ts`).
- `packages/plugin-sdk` `vitest run` after `turbo run build:types --filter=@sandy-sdk/plugin-sdk`: 35 files, 409 passed (includes the new `composer-menu-registration.test.ts`). Without the generated `bundled-types/`, 11 tests fail with ENOENT, identically on main `a7e568e0b`.
- Live: the server here has run a build of these two commits since 13:18.

## Not tested

- `turbo run typecheck` for the touched packages; `release.sh build` compiles them for the release.
- The stabilization checks listed in `docs/api_to_audit.md` (keyboard navigation and drawer on compact Safari, several plugins on one trigger).
- A plugin that registers `experimental_menus` in the live app; I did not exercise the menus by hand.

> AGENT GENERATED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant