Skip to content

Make plugin surfaces prove they use core's path and delete plugin-only switches - #7731

Merged
ymichael merged 11 commits into
mainfrom
bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva
Nov 18, 2026
Merged

ymichael merged 11 commits into
mainfrom
bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva

Conversation

@ymichael

@ymichael ymichael commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

AGENTS.md says a plugin API that performs a core action must be the path core uses, proven by one contract test table run against every surface. Only part of that was enforced. The view-level panel table (test/panel-controller-contract.tsx) covered panel tabs, not openTerminal, openFilePreview or openUrl. The terminal and file tables were hook-level and mocked reveal. There was no table for ThreadScreen consumers, Markdown surfaces or single-pane layout. So per-surface switches that turn a feature off for plugin surfaces kept shipping. Each was a small, reasonable-looking exception that no table asserted against:

Earlier issues and fixes from the same root cause

This is the 20th fix in the class. Each earlier one patched a single surface:

The open issues the tables catch today are #7065, #2967, #7277 and #5340. #6311 is covered by the Markdown table, which already passes because #6405 removed the closure chain.

What changed

Guards (written first; each failed on main for the past case named):

One owner, copies deleted:

  • lib/app-navigation-host.tsx gains AppNavigationSurfaceProvider. Each surface now registers its resolved navigation host while it has focus: the thread view, New thread, plugin page and Plugins. getFocusedAppPanelController is derived from that registry. The panel-only focusedControllers registry and the isFocused argument to useAppPanelController are deleted.
  • ThreadActionCollectors wraps collectors in FocusedAppNavigationSurfaceProvider. Thread actions' navigate.open* now reaches the same focused surface as their experimental_panel. When no surface has focus, it falls back to the app-level host.
  • includePluginMessageActions is deleted end to end: ThreadScreenTimelineHost, ThreadTimelineSurface, ThreadTimelineRows, PluginThreadChat and ThreadDetailView.
  • keepsSinglePane is deleted from SplitThreadArea: any single pane stays in WorkspacePaneContent.
  • The duplicate PLUGIN_MARKDOWN_THREAD_MENTIONS and ASSISTANT_THREAD_MENTIONS constants are merged into one AUTHORED_MARKDOWN_THREAD_MENTIONS exported from markdown-preview.tsx.

Follow-up from the independent review: missing host fields and untested panel contexts.

  • Required host fields. Every ThreadScreenTimelineHost and ThreadScreenComposerHost field is now required (ThreadScreen.tsx), so each surface must state each handler or an explicit null. A host field a surface leaves out now fails typecheck.
  • Shared title actions and environment rules. New thread-screen-hosts.ts owns the timeline title-action resolver and the thread environment rules (context environment, reusable environment). ThreadDetailView and plugin ThreadChat both use it.
  • What plugin ThreadChat newly gets, matching the thread page:
    • Clicking a tool title opens the diff or file, a local file, or a side chat. On main, onTitleAction was missing, so these clicks did nothing.
    • The context row above the composer still receives no environment (contextEnvironmentId: null), as on main, so a side chat does not repeat its parent thread's changed-files row. An opt-in prop for it was dropped because no plugin used it.
    • "New thread in this environment" is available.
    • The unread divider is shown. It now uses the same useThreadUnreadDividerState as the page, and read tracking waits for the divider, as on the page.
  • ThreadScreen table. The page row now mounts the real ThreadDetailView, not a hand-built ThreadScreen. Two rows were added: opening a changed file from its timeline title, and the composer receiving the new-thread action and each surface's expected context environment (the thread's on the page, none in embedded chats). On main's PluginThreadChat, these fail 5 of 11 rows.
  • Panel table. New rows for thread message actions, command palette commands and thread new-tab plugin actions, alongside the existing surface rows. CommandPalette now builds plugin commands through one buildFocusedSurfacePaletteActions, which the table also uses. The table gains actionTabs and navigation support flags, because those three contexts receive only a panel. The Plugins view gets a test that its panel declines every plugin tab without changing its tabs.
  • Panel tab renderers. ThreadTerminalPanel's onOpenLink and onSelectionAddToChat are required, so each of the three panel tab renderers must state them. The plugin page's terminal had no onOpenLink; its links now route through that page's in-app browser, as on the thread and New thread surfaces. I did not merge the three renderers into one. Their file-preview cases depend on different surface scopes, and the shared parts are now enforced by types.

SDK (backward compatible):

  • The JSDoc for PluginMessageActionRegistration and ThreadChatMessageAction no longer says embedded ThreadChat hides slot actions.
  • ComposerCustomization.actions documents where actions render: the expanded composer, not the collapsed single-line one.
  • defaultProjectId documents the remembered-project default.
  • New optional PluginMessageActionRegistration.experimental_surfaces (type ExperimentalMessageActionSurface): "thread-view" is bb's thread view and "embedded-chat" an embedded ThreadChat, matching the SDK docs' wording ("thread" alone already means any thread composer in the composer host's surface). Omitted, an action shows on both. The collector fills that default and rejects an empty or unknown list. It has an entry in docs/api_to_audit.md, on the Plugin Guide's message actions card (whose stale "main timeline only" bullet is replaced) and in the bb-plugin-authoring skill, which no longer says embedded ThreadChat hides slot actions.
  • @get-bb/plugin-sdk is set to 0.6.161, above main's 0.6.160.
  • No wire changes and no CLI changes.

Message action surfaces (review follow-up):

  • With decision 2, Side chat's own "Reply in side chat" also showed inside a side chat and in other plugins' embedded chats. Its side chat tab only exists in the thread view's panel, so on a plugin page it would create a side chat thread and then fail to open it.
  • Each ThreadScreen host now states messageActionSurface (ThreadDetailView "thread-view", PluginThreadChat "embedded-chat"). The timeline reads slots through one hook, useSurfaceMessageActionSlots (lib/message-action-surface.tsx), so every surface filters the same way. This is a filter the registration owns, not a per-surface switch.
  • Side chat registers experimental_surfaces: ["thread-view"]. Every other message action keeps showing in embedded ThreadChat.
  • The ThreadScreen table gains a row: an action limited to one surface shows only there, on all four surfaces. An SDK collector test covers the default and the validation.

Not deleted: PluginNewThreadComposer's selectionScope="component-local". That switch decides whether SDK seeds (defaultProviderId, defaultModel, defaultEnvironment, …) beat core's remembered picks. Switching to the "new-thread" scope would override third-party plugins' seeds and write plugin picks into core's New thread preferences, and an existing test pins that separation. This PR fixes only the #5340 project fallback. The seeded-but-unknown project id case resolves to personal exactly as a stale remembered id does in core's New thread view, so it is parity and left unchanged.

Decisions for review

  1. Thread actions route open* to the focused pane. This applies to header actions and to thread actions run from menus for other threads (a sidebar row's menu, the New thread screen's recents on a phone, or a plugin's experimental_ThreadActionsMenu). It matches how experimental_panel was already routed. Run from thread A's menu while thread B has focus:
    • experimental_openTerminal with A's terminal returns false, because B's panel accepts only B's terminals (acceptsThreadTerminal).
    • experimental_openFilePreview and openUrl open in B's panel. A file preview is addressed by environment and path, not by thread.
    • On main, all three returned false from every thread action, the header included. Opening A first and then the tab in A's panel would need a new "open a thread with a panel tab" path (see decision 7).
  2. Embedded ThreadChat shows every slot-registered message action, including compact side chats. Actions that need a thread-context tab receive the embedding page's panel. That returns false where the tab does not exist, as Embedded ThreadChat should inherit compatible provider features #2967 asks.
  3. The collapsed single-line composer still leaves plugin actions out, as on main. It leaves out bb's own + menu and model picker too; all of them show once the composer expands. An earlier version of this PR showed plugin actions in the collapsed composer for Render plugin composer actions in compact layouts #3358, but even with a scrolling strip it crowded the one-line composer on phones, so that change was reverted and Render plugin composer actions in compact layouts #3358 stays open.
  4. An unseeded plugin NewThreadComposer starts on the remembered New thread project. It reads that project but never writes it.
  5. A single plugin page or Plugins pane is no longer remounted at the compact breakpoint. On compact it renders through the workspace pane, with the same close button as before.
  6. "Reply in side chat" stays out of embedded ThreadChat, including side chats. Side chat limits its action to bb's thread view with experimental_surfaces: ["thread-view"]. Embedded ThreadChat cannot open its side chat tab, and a side chat inside a side chat is not wanted. Other plugins' message actions still show in embedded ThreadChat.
  7. A side-chat title on a surface whose panel can't host the side chat opens the side chat thread itself. Opening the source thread with the side chat tab would need a new "open a thread with a panel tab" path; this uses the existing thread navigation instead.
  8. Plugin ThreadChat's thread-info button is left off (onOpenThreadInfo: null). Thread info is a fixed tab in the thread page's side panel. From a plugin page, the button would open nothing, so it is left off.
  9. The standalone plugin model picker keeps commandShortcutsEnabled={false}. ⇧⌘M toggles the focused composer's picker, and every composer, plugin composers included, gets it through ExecutionControls. A form-control picker that also grabbed ⇧⌘M would make the shortcut ambiguous.
  10. The plugin page's new tab keeps showFileSearch={false} and a no-op onSelect. A plugin page has no project, environment or thread, so there is nothing to search and no recents to select; onSelect cannot fire.
  11. The Plugins view's panel accepts no plugin tabs. It has no plugin tab destinations, so a plugin command run there gets a panel that declines every tab. The new test pins this.
  12. Embedded ThreadChat now shows the unread divider and marks the thread read once the divider is ready, the same order as the thread page. Before, it marked read immediately and showed no divider.

How you verified

Live verification (isolated source dev instance, verify-bb)

These ran on the source dev web app at this branch, before the rebase, with a fresh data directory and the connected local host. A probe plugin registered three header thread actions (open a terminal, a file and a URL), a slot message action, three composer actions, and a page holding ThreadChat full and compact plus an unseeded experimental_NewThreadComposer. A Claude Code Haiku thread produced the assistant messages. Screenshots and measurements are kept locally.

  1. Header thread actions. Pass in the web client; the in-app browser case was not run.
    • 1400×900 with the right panel closed: "Probe open terminal" returned true, the panel opened, and a zsh terminal tab was selected.
    • With the panel closed again, "Probe open file" returned true, the panel opened, and the README.md preview was selected.
    • "Probe open URL" returned true and opened https://example.com/probe externally. The web client has no in-app browser, so the Electron in-app browser path was not run live; the contract table covers it.
  2. Plugin message actions in embedded ThreadChat. Pass.
    • On the probe page, both ThreadChat full and compact show "Probe message action" on the user and assistant messages.
    • In a real side chat (compact ThreadChat, opened with "Reply in side chat"), after one reply the assistant message shows "Probe message action" next to "Send to main thread". After the surfaces follow-up, a rerun on the rebased branch shows 0 "Reply in side chat" inside the side chat; the thread page still shows it on both messages. See decision 6.
  3. Plugin actions on a phone (375×812, touch). The collapsed composer shows no plugin actions, as on main. After tapping it, the expanded composer shows all three probe actions before the mic.
  4. Remembered project in an unseeded plugin composer. Pass.
    • After picking Fixture in bb's New thread view, the plugin composer showed "Project: Fixture", and it still did after a reload.
    • After picking No project in New thread, the plugin composer showed "Project: No project".
  5. Single plugin page across the compact breakpoint. Pass.
    • I typed into the page's input and selected characters 2–6, then resized 1024 → 767 → 768 → 700 → 1024.
    • Throughout, the same input and page nodes stayed, with the same mount id, the value "unsaved plugin form", focus, and the selection [2,6]. The compact page shows the close button.

Live verification of the review follow-up (second run, isolated dev instance and desktop app)

The second run used a fresh dev instance from this branch (ae6db4b0d34 plus the side-chat fix below). The URL check also used the source desktop app (Electron) attached to the same instance and driven over CDP. Each check compares plugin ThreadChat on the probe plugin's page with the thread page. The fixtures were Claude Code Haiku threads:

  • an "Edits" thread that changed a workspace file (README.md) and a file outside the workspace (/tmp/.../outside-note.txt);
  • a side chat whose reply was sent back to the main thread;
  • two threads that were marked read and then got an unread reply.
  1. Tool title opening a changed workspace file. Match.
    • On the thread page, clicking README.md opened a README.md preview tab in the thread's panel.
    • In plugin ThreadChat, it opened the same preview in the plugin page's panel.
    • On both, the git Diff tab declines this file target, so both fall back to the file preview.
  2. Tool title opening a file outside the workspace. Match. outside-note.txt opened a host-file preview in each surface's own panel.
  3. Side-chat title ("Message from side chat"). Mismatch found and fixed.
    • On the thread page, clicking it opened the side chat in the thread's panel.
    • In plugin ThreadChat, it did nothing: the plugin page's panel has no thread side-chat tab.
    • Fix: the shared resolver now opens the side chat thread itself when the surface's panel declines the tab. After the fix, plugin ThreadChat navigates to the side chat thread; the thread page is unchanged and still opens it in its panel. Covered by thread-screen-hosts.test.tsx.
    • Related finding, already on main and not caused by this PR: both surfaces label the row "Message from Agent", with no link, until the hidden side-chat thread is in the query cache. Sender metadata is read only from cached threads. After a reload with the side chat tab closed, the thread page shows the same unlinked label. Not changed here.
  4. "New thread in this environment". Match.
    • The thread page opened New thread with project Fixture and "Reuse" selected.
    • Plugin ThreadChat, about 920 px wide, did the same.
    • In a probe column about 250 px wide, the composer's environment row is clipped. This comes from the narrow container; the side chat tab at about 520 px shows the row.
  5. Unread divider.
    • Thread page (thread C): the "NEW" divider sits above the unread second reply.
    • Plugin ThreadChat full and compact (thread B): the divider sits in the same place.
    • On both, the thread stayed unread until there was user activity (mouse and keyboard input), then lastReadAt advanced and the divider stayed on screen. Read timing matches.
  6. Plugin-page terminal link (desktop app). Match.
    • On the plugin page, ⌘-clicking https://example.com/terminal-link in a panel terminal opened an in-app browser tab ("Example Domain") in the plugin page's panel. On main this link had no handler on the plugin page.
    • On the thread page, the same click opened the same in-app browser tab in the thread's panel.

Tests and checks

  • After rebasing onto main (28cdd915db4) and dropping experimental_environmentContext: typecheck lint pass for @bb/app, @get-bb/plugin-sdk, side chat and plugin-api-docs; the 15 changed app test files pass (533 tests, 16 skipped); plugin SDK (439), side chat (27) and plugin-api-docs (75) tests pass; the plugin SDK version check passes. A live rerun on the rebased build showed "Probe message action" in both the thread page and embedded ThreadChat, with "Reply in side chat" only on the thread page.

  • Each guard was run against main's version of the changed component and failed as described above. All guards pass with the fix.

  • A targeted run of the 35 affected test files passed after the review follow-up: 1,112 tests, with 16 skipped.

  • pnpm exec turbo run typecheck lint --filter=@bb/app: pass. The composer plugin lint shows 4 warnings, all of which were already there.

  • node apps/app/scripts/check-bundle-budget.mjs after the rebase: the boot payload is 418.6 KB brotli against a 419.1 KB budget.

  • The first CI run's other failures were 15 s timeouts in @bb/logger (Windows) and @bb/db resolved-item pruning. This PR touches neither package.

  • Not run on a native iOS or Android device, and not in the Electron in-app browser.

  • After rebasing on main and adding message action surfaces: the 15 affected app test files pass (651 tests, 16 skipped); @get-bb/plugin-sdk typecheck, lint and tests pass (39 files); side-chat and plugin-api-docs tests pass; typecheck lint pass for @bb/app and both plugins; the boot bundle budget passes.

Fixes #7065
Part of #2967. Gaps 1 and 2 are covered; gap 3, the per-chat identity seam for content scripts, is not in this PR.
Fixes #7277
Part of #5340. The unseeded-project half is fixed; the unknown-seed half is kept as parity, as explained above.

🤖 Generated with Claude Code

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva branch from 49d56bc to 09633eb Compare November 17, 2026 20:36
@ymichael ymichael closed this Nov 17, 2026
@ymichael ymichael reopened this Nov 17, 2026
@ymichael
ymichael force-pushed the bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva branch from d90c7e9 to ae6db4b Compare November 18, 2026 00:12
@ymichael
ymichael force-pushed the bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva branch 2 times, most recently from 47d4561 to 32087d3 Compare November 18, 2026 19:47
@ymichael ymichael changed the title Make plugin surfaces prove they use core's path and delete four plugin-only switches Make plugin surfaces prove they use core's path and delete plugin-only switches Nov 18, 2026
ymichael and others added 11 commits November 18, 2026 14:42
…n-only switches

Extend the view-level panel contract table to openTerminal, openFilePreview
and openUrl on every surface, including a header thread action. Add surface
tables for ThreadScreen consumers, Markdown, compact composer actions and
single-pane breakpoint crossings. Fix what they caught:

- Thread actions now route navigate.open* to the focused surface through one
  focused-surface registry, which also replaces the panel-only registry (#7065).
- Embedded ThreadChat shows slot-registered message actions (#2967).
- A single plugin pane stays mounted across the compact breakpoint (#7277).
- Compact composers render plugin composer actions (#3358).
- An unseeded plugin NewThreadComposer starts on the remembered New thread
  project (#5340).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…panel contexts

ThreadScreen's timeline and composer host fields are now required, so a
surface must state each handler or a deliberate null. Plugin ThreadChat
gets the thread page's title actions, context environment, new-thread-in-
environment action and unread divider through shared code. The ThreadScreen
table drives its page row through the real ThreadDetailView. The panel table
gains rows for message actions, palette commands and new-tab plugin actions,
and the Plugins view gets a panel test. Terminal tabs must state their link
and add-to-chat handlers, which routes plugin page terminal links through the
in-app browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…host it

On a plugin page, the embedded ThreadChat's panel has no thread side-chat
tab, so clicking a "Message from side chat" title did nothing. The shared
title-action resolver now opens the side chat thread itself when the panel
declines the tab; the thread page still opens it in its panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Embedded ThreadChat now shows slot-registered message actions, so Side
chat's own "Reply in side chat" appeared inside a side chat and in other
plugins' embedded chats, where its side chat tab cannot open. A message
action can now name the timelines it shows in with
experimental_surfaces ("thread" for bb's thread view, "thread-chat" for
an embedded ThreadChat); omitted, it shows on both. Each ThreadScreen
host states its surface, and the timeline filters slots through one hook.
Side chat declares ["thread"].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"thread" already means any thread composer in the composer host's
surface, embedded ThreadChat included, and "thread-chat" did not say what
set it apart from bb's thread view. The values now match the SDK docs'
"thread view" and "embedded ThreadChat".

Also fixes the two CI failures from the surfaces commit: the collected
registration test now expects the filled default, and the
bb-plugin-authoring skill documents experimental_surfaces and no longer
says embedded ThreadChat hides slot message actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… plugin opts in

ThreadChat now passes the thread's environment to the context row above
its composer only with experimental_environmentContext, so side chats no
longer repeat the changed-files row their parent thread already shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The collapsed composer leaves out bb's own + menu and model picker, so
plugin actions stay out of it too and show once the composer expands,
as on main. This restores the composer files and their test to main's
and documents where actions render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No plugin passes it: Side chat leaves it off and no other first-party
plugin embeds ThreadChat away from its thread. Embedded ThreadChat keeps
main's behavior of passing no environment to the composer's context row,
and the ThreadScreen contract table now states that per surface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael force-pushed the bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva branch from 9fd57b9 to 0a0217d Compare November 18, 2026 22:46
@ymichael
ymichael merged commit 9ab1d42 into main Nov 18, 2026
53 checks passed
@ymichael
ymichael deleted the bb/class-fix-view-level-plugin-surface-contract-tab-thr_j3gude4cva branch November 18, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant