Skip to content

One panel controller for plugins and core - #6356

Merged
ymichael merged 2 commits into
mainfrom
bb/panel-controller-one-opentab-toggletab-close-for-thr_d3492dsc27
Oct 27, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/panel-controller-one-opentab-toggletab-close-for-thr_d3492dsc27

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugins and core opened the right panel through different paths. Plugins had four overlapping members: ctx.openPanel, useBbNavigate().openThreadPanel, experimental_useAppPanel().experimental_openTab and experimental_useAppPanel().openFixedTab. Each worked on only some screens. Core's own controls (diff.toggle, panel.toggle, Info, the tab strip) had separate code in each panel host. AGENTS.md requires a plugin API that performs a core action to be the path core uses, so the plugin API could not be stabilized.

What changed

One panel controller (ExperimentalPanelController in @get-bb/plugin-sdk/app):

  • openTab({tab, target?}) for fixed tabs, openTab({tab, params?, title?}) for action tabs. The types enforce the split.
  • toggleTab(options) closes the panel when that tab is showing, otherwise opens it.
  • close() closes the panel.
  • Each returns boolean. false means this screen doesn't have the tab or the options are invalid.

Where plugins get it:

  • experimental_useAppPanel() on the thread view, plugin nav-panel pages and the New thread screen.
  • ctx.experimental_panel in commands, thread actions, message actions, New-thread panel actions and action tabs' run.
  • Thread fixed tabs can now declare experimental_target, which experimental_useFixedTabTarget reads.

Core uses the same path. apps/app/src/lib/app-fixed-tab-navigation.tsx holds the controller. ThreadDetailView, PluginPanelRightPanelHost and RootComposeView each build one, and core's diff.toggle (Mod+D), panel.toggle, Info, the fixed-tab strip, file/commit opens and the side-chat title action all call it. It replaces PluginThreadPanelNavigationProvider, usePanelPluginPanels and the panel-opener prop chain through the timeline and markdown renderers, all deleted.

Retired members (ctx.openPanel, openThreadPanel, experimental_openTab, openFixedTab):

  • Removed from the typings, the Plugin Guide and the bb-guide references.
  • They keep working at runtime with the same behaviour.
  • packages/plugin-build/src/retired-sdk-members.ts warns at build time and names the replacement call.

Marketplace check (342 bb-community repos):

Retired member Call sites Repos
openPanel 102 47
openThreadPanel 111 55
experimental_openTab 3 2
openFixedTab 11 8

None relies on the one behaviour difference: only registered tabs resolve.

Test harness: renderSlot takes an experimental_panel option and records experimental_panelCalls. The retired harness options and logs keep working at runtime.

Migrated callers: side-chat, tasks, workflows, docs and the thread-chat demo, with engines >=0.6.88. The SDK is bumped 0.6.87 → 0.6.88 with scripts/bump-plugin-sdk.mjs.

Docs: a new Panel controller entry in docs/api_to_audit.md, Plugin Guide surfaces in plugins/plugin-api-docs/src/surfaces.ts, and a "Panel controller" section with a migration note in the bb-guide frontend-hooks-and-ui.md.

Size:

Area + − Net
Production 1188 1080 +108
Docs 166 99 +67
Tests 1858 480 +1378

Most of the test growth is the new contract table, because the panel on these screens had no tests before (ThreadDetailView had never been mounted in a test). The second commit removes unit tests and contract rows the table already covers.

How you verified

Contract table (apps/app/src/test/panel-controller-contract.tsx):

Screen Passed Skipped (screen lacks the feature)
Thread view 9 0
Plugin nav-panel page 8 1
New thread screen 5 4
  • Breaking toggleTab makes 6 rows fail.
  • Removing the availability check makes the "declines" row fail on all three screens.

Checks: pnpm exec turbo run typecheck lint test --continue --filter='...[origin/main]' on the head.

  • Typecheck and lint pass for every task (0 lint errors).

  • Selected test totals:

    Package Passed
    @bb/app 6423 (6 skipped)
    @bb/server 3679 (1 skipped)
    @get-bb/plugin-sdk 403
    @bb/plugin-build 229 (1 skipped)
    tasks 410
    workflows 249
    thread-list 474
    push-notifications 45
    side-chat 26
  • Load-sensitive tests that failed in the full run on a loaded machine, and how each was resolved:

    • FilePreview worker pool, scroll-position-keeper model, mcp cli-runner timeout, builtin-plugins hot reload, scripts pr-approval: pass when rerun alone.
    • @bb/host-watcher workspace-root-ignores and @bb/desktop preload-build: fail the same way on a clean origin/main checkout here.

Manual run (pnpm start:worktree, at the pre-rebase commit; the only conflict since was a JSX provider):

  • Mod+D:
    • From closed, it opens on Diff.
    • With Diff showing, it closes the panel.
    • From Info, it switches to Diff and the panel stays open.
  • Mod+J and the toggle button close and reopen on the last tab on the thread view, a plugin page and the New thread screen.
  • "Start side chat" opens a Side chat tab, and the "Reply in side chat" message action opens another one.
  • The ThreadChat demo's "Open compact tab" with a target renders the targeted thread.

🤖 Generated with Claude Code

AGENT GENERATED

Michael Yong and others added 2 commits October 26, 2026 20:40
Plugins and core opened, toggled and closed the side panel through several
parallel paths: ctx.openPanel on each launcher, useBbNavigate().openThreadPanel,
experimental_useAppPanel().experimental_openTab/openFixedTab, and core's own
diff.toggle, panel.toggle and Info handlers. Each surface (thread view, plugin
nav-panel page, New thread screen) now builds one AppPanelController from its
registered destinations, and every path goes through it.

- SDK: ExperimentalOpenTabOptions and ExperimentalPanelController
  (openTab/toggleTab/close). experimental_useAppPanel() returns the controller
  for the current surface; every launcher context carries ctx.experimental_panel.
  Thread fixed tabs may declare experimental_target, and
  experimental_useFixedTabTarget reads them.
- Retired from typings, kept working at runtime through the controller, with
  bb plugin build warnings naming the replacement: ctx.openPanel,
  useBbNavigate().openThreadPanel, experimental_useAppPanel().experimental_openTab
  and .openFixedTab, plus the matching renderSlot options and logs (replaced
  by experimental_panel and experimental_panelCalls).
- Core: Mod+D toggles the Diff tab through toggleTab; panel.toggle, the panel
  toggle button, close buttons, panel.close and the window-close request close
  through close(); Info, the fixed-tab strip and Diff file/commit opens use
  openTab. The opener context, focused-opener registry and the timeline's
  onOpenPluginPanel prop chain are deleted.
- In-repo callers (side-chat, tasks, workflows, docs, ThreadChat demo) use the
  new API. Plugin SDK 0.6.86.
- One contract table runs against the real thread view, nav-panel page and
  New thread screen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 298b04e into main Oct 27, 2026
51 checks passed
@ymichael
ymichael deleted the bb/panel-controller-one-opentab-toggletab-close-for-thr_d3492dsc27 branch October 27, 2026 03:52
ymichael pushed a commit that referenced this pull request Oct 27, 2026
…ugin

The Git plugin now draws the Diff tab, the Info tab's branch, merge base,
git status, Commits and Uncommitted files rows, and the composer's
changed-files segment through the public slots, on top of the panel
controller (#6356), experimental_useCanOpenFileExternally (#6357),
automatic Add to chat (#6353) and experimental_ref (#6348).

- Thread tabs and Info rows receive environment: { id } | null straight
  from the thread, null only without one. The Git plugin reads everything
  else itself: the Diff tab's loading, failure and Retry come from its
  bb--git status read, and a missing workspace folder shows "Workspace not
  found" in Info.
- experimental_useTabVisible() tells any panel tab whether it is selected
  in an open panel; the Diff tab pauses its file list, patch and Viewed
  reads while it is false.
- Mod+D is the Git plugin's toggle-diff command, calling the panel
  controller's toggleTab.
- InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for
  core and the plugin; the subheading and commit rail live in the plugin.
- Keyed RPC reads gain refetchKeys for a per-row Retry.
- Plugin SDK 0.6.90.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael pushed a commit that referenced this pull request Oct 27, 2026
…ugin

The Git plugin now draws the Diff tab, the Info tab's branch, merge base,
git status, Commits and Uncommitted files rows, and the composer's
changed-files segment through the public slots, on top of the panel
controller (#6356), experimental_useCanOpenFileExternally (#6357),
automatic Add to chat (#6353) and experimental_ref (#6348).

- Thread tabs and Info rows receive environment: { id } | null straight
  from the thread, null only without one. The Git plugin reads everything
  else itself: the Diff tab's loading, failure and Retry come from its
  bb--git status read, and a missing workspace folder shows "Workspace not
  found" in Info.
- experimental_useTabVisible() tells any panel tab whether it is selected
  in an open panel; the Diff tab pauses its file list, patch and Viewed
  reads while it is false.
- Mod+D is the Git plugin's toggle-diff command, calling the panel
  controller's toggleTab.
- InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for
  core and the plugin; the subheading and commit rail live in the plugin.
- Keyed RPC reads gain refetchKeys for a per-row Retry.
- Plugin SDK 0.6.90.

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

## Human comments

## What was wrong

Since #6165, the Git plugin owns every git read, but core still drew the
Diff tab, the Info tab's branch, merge base, git status, Commits and
Uncommitted files rows, and the composer's changed-files segment.
Plugins couldn't replace them, and turning the plugin off left them
showing errors. This PR moves that UI into the Git plugin, through the
same public slots any plugin uses, on top of the four prep PRs: the
panel controller (#6356), `experimental_useCanOpenFileExternally`
(#6357), automatic Add to chat on diff and code views (#6353) and
`experimental_ref` on workspace file targets (#6348).

## What changed

**Moved into the Git plugin (`plugins/git/app.tsx`, `plugins/git/ui/`)**

- **Diff tab**: a thread fixed `experimental_tab` with `{ kind: "file",
path }` and `{ kind: "commit", sha }` targets.
- It shows its own loading state, failure and Retry from its `bb--git`
status read, and hides for a workspace that isn't a git repository.
  - Filters are kept per environment, so they survive switching tabs.
- Open in editor is decided per file card with
`experimental_useCanOpenFileExternally`. The workspace path for copying
absolute paths comes from the plugin's own environment read.
- **Mod+D**: the plugin's `toggle-diff` command calls
`ctx.experimental_panel.toggleTab`. A user's saved `diff.toggle` binding
migrates to it, as before.
- **Info**:
- Branch, Merge base and Git status rows, plus the Commits and
Uncommitted files sections.
- A missing workspace folder shows "Workspace not found" from the
plugin's status read.
- Changed files with status D preview read-only at `HEAD` or the merge
base through `experimental_ref`.
- **Composer**: the changed-files segment with its merge-base picker.
- **Merge-base picker**: takes its branch from the plugin's own status
read, not from an environment record.
- **Removed from core**:
- The Diff tab and its panel code, the Info git rows and sections, and
the changed-files segment.
  - The status, files, patches, branches and Viewed query hooks.
- `diff.toggle`, and the core Diff case in the panel controller contract
table.
- Core still reads status through the plugin for the Commit button and
the composer branch chip.

**Components**

- Moved to `@bb/shared-ui`, because both core and the plugin render
them:
- The diff card body and header, diff parsing and patch text, renderers,
and `BranchPicker` with its picker helpers.
- Git status display, the workspace change summary and changes list, and
the diff stats tally.
- The file path link, Open in editor button, copy button, image preview
and diff loading skeleton.
- `InfoListRow` with its row actions, and `InfoRowTime`. Core's Related
threads and thread storage sections use these too.
- Kept inside the plugin, because only it uses them: the Diff panel,
toolbar, filters, the Info subheading and the commit rail.

**Plugin SDK 0.6.90** (all in `docs/api_to_audit.md` and the Plugin
Guide)

- **`environment` on thread tabs and Info rows.**
- Thread tabs (fixed and action, including `useVisible` and action
`run`) and Info rows receive `environment: { id } | null`. It comes
straight from the thread and is null only when the thread has no
environment.
  - Components read the environment's state themselves.
- Core no longer filters Info rows' environment through its "can use git
UI" check.
  - New type: `ExperimentalThreadTabProps`.
- **`experimental_useTabVisible(): boolean`**:
- True while the panel tab it renders in is selected and the side panel
is open. False when the panel is closed or suppressed, when another tab
is selected, and outside a tab.
- Core keeps a closed panel's tab mounted, as before.
`ThreadSecondaryPanel` provides the value for every surface.
- The Diff tab pauses its file list, patch, Viewed and branch-list reads
while it is false, as core's Diff did with `isDiffPanelLive`.
  - The test harness answers it with `tabVisible`, default true.
- **`refetchKeys(keys)` on keyed reads**: reads only those keys again
and keeps every other row. The Diff tab retries one failed patch with
it, and Retry re-reads one environment's status.

**Dropped from the previous version of this PR**

- `environmentState`, `threadArchived` and `isOpen` on tab props, and
keeping visited fixed tabs mounted.
- `useVisible` returning `"pending"` for context segments.
- `experimental_shortcutCommandId` (on main the shortcut appeared only
in the Diff tab's screen-reader label) and
`experimental_inactiveInInputs`.
- `experimental_InfoRowTime`, `experimental_InfoSubheading`, `InfoList`
`rail` and `InfoListRow` `actions` as SDK members.
- `DiffProps.experimental_addSelectionToChat`, now automatic since
#6353.
- `experimental_deleted`, replaced by `experimental_ref`.
- `ctx.experimental_toggleTab`, replaced by the panel controller.

**Differences from main (accepted)**

- Mod+D also toggles the Diff tab while typing.
- The composer context row appears when git status arrives, instead of
being held back until then.
- Turning the Git plugin off hides the Diff tab, the Info git rows and
the composer segment. With the plugin off, Commit returns 409
`git_plugin_unavailable`.

## How you verified

- **Turbo checks:**
- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`
passes.
- Tests pass for `@bb/app` (6286), the Git plugin, `@bb/shared-ui`,
`@get-bb/plugin-sdk`, `@bb/query-tags`, `@bb/client-core`, the Plugin
Guide, the GitHub, Side chat, Tasks, Workflows, Docs and Automations
plugins, and the server's authoring-docs and keybinding tests.
- **New tests (each fails without its change):**
- `ThreadSecondaryPanel.tabVisible.test.tsx`: true while selected and
open; false once closed, still mounted.
- The panel controller contract table: "reports the shown tab visible
only while the side panel is open", run against the thread view, plugin
page and New thread surfaces.
- `DiffTab.test.tsx`: visibility from status; the status failure with
Retry; no file list while the tab isn't showing; Open in editor only for
a valid per-file target.
- `DiffFilesPanel.test.tsx`: no patch or Viewed reads while the tab is
hidden.
- `PluginThreadFixedTabs.test.tsx`: the tab and its `useVisible` receive
the thread's environment.
  - `plugins/git/app.test.tsx`: Mod+D calls `toggleTab` on the Diff tab.
- **Squash tests on Windows:** in
`plugins/git/host/workspace-status-cache.test.ts`, the squash-detection
tests now read again until the check completes, as bb does on the next
refresh. The plugin package now also runs the Diff and Info UI tests,
and that extra load on Windows runners pushed single reads past the 1 s
squash budget (three runs, three different tests). The tests of the
timeout itself are unchanged.
- **Real app QA:** this branch and `main` built side by side on the same
data and repository (a rename, edits, a deletion, a binary file, an
image, a mode change).

| Check | Branch | Main |
|---|---|---|
| Diff tab opens and closes with Mod+D and lists the same files | Pass |
Pass |
| Open in editor on every Diff card (7) | Pass | Pass |
| Mod+D while typing in the composer | Toggles (accepted) | Does nothing
|
| Composer context row "Uncommitted · 7 files, +3 −74" and merge-base
picker | Pass | Pass |
| Info: branch, merge base, git status, Uncommitted files | Pass | Pass
|
| Merge-base picker opens with the branch list | Pass | Pass |
| Add to chat on selected diff lines inserts the quoted diff | Pass |
Pass |
| A deleted file opens a read-only preview at `HEAD` | Pass | Pass |
| A thread whose workspace folder is gone shows "Workspace not found" |
Pass | n/a |
| No file list, patch or Viewed reads after an edit while the Diff tab
is closed; reads resume on reopen | Pass | Pass |

> AGENT GENERATED

Co-authored-by: Michael Yong <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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