Skip to content

Run bb's message actions on the public message action slot - #8091

Merged
ymichael merged 18 commits into
mainfrom
bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc
Dec 1, 2026
Merged

ymichael merged 18 commits into
mainfrom
bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

slots.messageAction had no way to say which messages an action works on, so every plugin action showed on every user and assistant message. Conductor's "Fork to new workspace" and Side chat's "Reply in side chat" showed on user messages, and Conductor's fork also showed on threads that cannot fork. ThreadChatProps.messageActions was a second shape for the same thing, with roles and a run(message) that got no thread, panel, composer or selection. bb's own Copy, Edit, Copy link, Add to chat and Fork could not have been built on the slot: they were hand-wired into MessageActionBar and TimelineSelectionMenu with their own role rules, availability, streaming state and placement. This closes audit finding a-thread F4 and core-contributions rank 10.

What changed

Message actions now use the model thread actions already use: an optional useData hook per timeline, and a pure item per message that returns the action or null. bb's five actions are ordinary registrations on that model, using only the public SDK.

Slot contract (packages/plugin-sdk/src/app-contract.ts, SDK 0.6.215):

  • PluginMessageActionRegistration<Data> adds:
    • experimental_useData?({ threadId }): Data. A React hook bb calls once per mounted timeline with that timeline's thread, never per message. Plugins read thread facts there with experimental_useThread and return only what item needs.
    • experimental_item?(input): pure and synchronous, called per message while rendering. Returns null or { label, icon?, disabled?, run({ invokedFrom, confirm }) }.
    • experimental_selectionItem?(input): the same for text selected in an assistant message. Its input adds selection: { text, markdown }.
    • experimental_placement?: "inline" | "menu" (default "inline").
    • experimental_group?: string and experimental_order?: number. The row, its overflow menu and the selection menu sort by group (string compare; unset sorts after every group), then order within the group (ascending; unset last), then registration order with bb's own first: the rule thread actions use with group and order. experimental_MESSAGE_ACTION_GROUPS exports bb's groups: copy (Copy link 10, Copy 20), edit (Edit 10), compose (Add to chat 10, row menu and selection menu) and branch (Fork 10). The group is optional, unlike other slots', because slots.messageAction is stable and its run-only form predates groups. Groups only order actions; the menus draw no separator.
    • run returns void like every other plugin action. Calling confirm() shows a check mark on the inline button for 2 s; it does nothing from a menu. bb's Copy calls it after a successful copy.
  • The item input (ExperimentalMessageActionItemInput<Data>) is the callback context plus message, requestEdit and data. composer is the composer of the message's thread on this surface. requestEdit opens bb's inline sent-message editor and is null where bb would not offer Edit. There are no fork flags: a fork action computes its availability in useData.
  • The original run-only form ({ id, title, icon?, experimental_surfaces?, run }) still works and shows where it always did. A registration mixing run with item or selectionItem fails registration.
  • New experimental_appendQuoteToDraft(draft, text, attachments?) on @get-bb/plugin-sdk/app: bb's Add to chat quoting, pure, for composer.replace. Its implementation moved from client-core into the SDK's composer draft transforms. bb's message Add to chat, the diff, file-preview and terminal Add to chat, root compose's quote, the retired composer.addQuote and the test harness all run that one copy.
  • ThreadChatMessageReference adds experimental_settled, experimental_attachments (ComposerAttachment[]) and experimental_imageUrls. ExperimentalClipboardContent adds imageUrl, copied through bb's own image clipboard writer.
  • ThreadChatProps.experimental_messageActions takes item-form registrations (without experimental_surfaces or experimental_useData) for one embedded chat.
  • ThreadChatProps.messageActions and ThreadChatMessageAction are removed from the types, docs and test harness. Compiled plugins that still pass the prop keep working: PluginThreadChat adapts each entry into an inline item that returns null outside its roles, and warns once per plugin.

Core on the shared path:

  • apps/app/src/core-contributions/message-actions.ts registers Copy link, Copy, Edit, Add to chat (row menu), Add to chat (selection menu) and Fork through definePluginApp, with public SDK imports only.
    • Add to chat is composer.replace((d) => experimental_appendQuoteToDraft(d, text, attachments)), then composer.focus().
    • Fork's useData reads experimental_useThread and experimental_useProviders and returns whether the thread has an environment, is not archived and its provider supports forking. Its item offers Fork on assistant messages when that is true and the surface has a composer. Running it is sdk.threads.fork({ sourceThreadId, sourceSeqEnd, origin: "app" }) then navigate.toThread, once per click, with bb's error toast on failure. It replaces useForkThreadFromMessage and client-core's isThreadForkable.
  • MessageActionCollectors (apps/app/src/components/plugin/) runs each registration's useData for the timeline. ThreadTimelineRows holds the values and passes them through a context. Rows hand MessageActionBar their action source, and the bar resolves its own actions. So a new useData value re-renders the action bars, not the message content.
  • lib/plugin-message-actions.ts buildMessageActions resolves items, placement and order for the row and the selection menu. MessageActionBar and TimelineSelectionMenu render only that list. TimelineSelectionMenu keeps its onAddToChat path for the diff, file-preview and terminal selection menus, which are not message actions.
  • ConversationMessageContent, ThreadTimelineRows, ThreadTimelineSurface, ThreadScreen, ThreadDetailView and PluginThreadChat drop the per-action props and the canFork / canSpawnChild plumbing.
  • The plugin-bound sdk.threads.fork puts the new thread in the app's cache before the caller navigates, as bb's button did. It imports the thread cache owner on demand to keep it out of the boot payload.
  • bb's message action registrations load with the timeline, as bb's hand-wired actions did on main: useSurfaceMessageActionSlots (lib/message-action-surface.tsx) puts them ahead of the plugin slots instead of the plugin slot store collecting them at boot. experimental_useProviders also moves from plugin-sdk-hooks.ts into its own provider-directory-state.ts; importing it from plugin-sdk-hooks.ts had pulled that whole module and its imports into the boot payload (32 KB raw over main).

Server fork changes (every caller of POST /api/v1/threads/fork):

  • A fork takes the model and reasoning level chosen in the source's model picker, falling back to its last turn's (thread-fork.ts resolves the source's next-turn execution plan).
  • A visible fork goes into the source's section, and is pinned if the source is. A hidden fork, such as Side chat's, gets neither, because it has no place in the sidebar. Before, only bb's button copied section and pin, so Conductor, the SDK and bb thread fork now do too.
  • A thread at the nesting limit can be forked. Thread forking + session-based side chats + timeline scroll preservation #85 ran the child-nesting depth check on fork sources so that forks and side chats would "consume the same spawn allowance" as canSpawnChild. But a fork has no parent, so it never deepens the tree. An agent at the limit can already create top-level threads with bb thread spawn. The check only stopped bb's Fork, Side chat and Conductor working in threads four levels deep. The other source checks (missing, other project, archived, deleted) stay.

Queued-message edit: message actions get the composer of the message's own thread on that surface, including the inline editor of one of its queued messages while that is open. So during a queued-message edit, Add to chat quotes into that edit instead of the main draft. Before, it disappeared while the edit was open.

First-party callers:

  • Side chat: "Reply in side chat" is an assistant-only item and selectionItem. "Send to main thread" moves to experimental_messageActions.
  • Conductor: "Fork to new workspace" is an assistant-only item, with the same fork check as bb's Fork in its own useData. Its run reads the source thread with sdk.threads.get.
  • Both raise engines.bbPluginSdk to >=0.6.215.

Docs:

  • docs/api_to_audit.md: the message-action entry (contract, core and plugin callers, the fork and Add to chat paths, the retired prop, audit questions) and a new experimental_appendQuoteToDraft entry.
  • The Plugin Guide message-actions card (plugins/plugin-api-docs/src/surfaces.ts).
  • The bb-plugin-authoring references frontend-renderer-slots.md and frontend-components.md.
  • The bb thread fork guide describes the model, section and pin a fork takes.

Visible differences from main:

  • Plugin actions now show only on the messages their item returns an action for. Side chat and Conductor are assistant-only, and Conductor's fork is hidden where the thread cannot fork.
  • Inline Edit and plugin buttons share Copy's hover transition and focus-visible opacity, because Copy is now an ordinary action button. No positions move.
  • bb's Fork is no longer greyed out in threads at the nesting limit; it works there.
  • Forks from the CLI, SDK and plugins follow the source's picker choice, section and pin (above).
  • Add to chat during a queued-message edit quotes into that edit (above).
  • The message "…" menu is non-modal, as thread action menus are. On main its focus trap pulled focus back from the composer that Add to chat had just focused, so focus fell to the page when the menu closed; now it stays in the composer, as it does from the selection menu.

Community callers (not edited):

  • slots.messageAction in the run-only form: brsbl timeline-comments; vburojevic handoff and linear; rebryk bookmarks; and about 20 more in the corpus. All keep today's behavior.
  • ThreadChatProps.messageActions: brsbl desktop, robdodson side-chat-links, xMinor-1 sticker-note, cristoslc focus-board and anirudhranganath thread-tabs. Their compiled code keeps working through the adapter and gets a one-time warning; rebuilding against SDK 0.6.215 needs experimental_messageActions.

How you verified

  • New or changed tests that fail on main:
    • ThreadTimelineRows.actions.test.tsx:
      • item runs per message with that message's input; its action runs with invokedFrom and confirm, and confirm() turns the inline button into a check mark
      • useData runs once for the timeline with its threadId; items re-evaluate when its value changes, and it unsubscribes on unmount
      • bb's Fork is offered only with a composer, on an unarchived thread with an environment whose provider can fork
      • bb's Fork calls sdk.threads.fork once at a time; a rejected fork stays on the source and can be retried, and the retry opens the fork
      • inline order and menu placement of plugin actions among bb's own
      • a selection-only action after bb's Add to chat, with the selection's Markdown
      • experimental_messageActions with the full item input, and retired messageActions filtered by role
      • message actions get only their own thread's composer, including its queued-message editor
      • Add to chat (row, for user and assistant messages with files, and selection) writes the quote into the draft and focuses the composer
    • MessageActionBar.test.tsx: an inline run that confirms shows a check mark and ignores clicks meanwhile; the menu invocation and disabled rows. Both check-mark tests fail if the bar stops passing confirm.
    • MessageActionBar.test.tsx: a menu row whose run focuses another element keeps that focus after the menu closes; fails with the modal menu (focus ends on <body>).
    • plugin-app-message-action.test.ts: defaults and validation for the item form.
    • public-thread-fork.test.ts: a fork takes the source's picker model and reasoning over its last turn's. A visible fork takes the source's section and pin and a hidden fork takes neither; the hidden half fails on the previous route with expected 'sec_…' to be null.
    • thread-create-seed-without-run.test.ts: a thread at the nesting limit forks into a top-level thread.
    • plugin-bound-sdk.test.ts: a plugin fork is in the thread cache before the caller navigates.
    • PluginThreadChat.test.tsx: a retired messageActions list still runs and warns once.
    • The existing row-isolation guard (ThreadTimelineRows.row-isolation.test.tsx) still sees each row render once on mount with per-timeline useData.
  • After rebasing on a6e31224a29:
    • pnpm exec turbo run typecheck lint --filter='...[origin/main]': 167 of 167 tasks pass.
    • Tests pass for app (7553), plugin SDK (512), Plugin Guide cards (76), Plugin Guide skill docs (15), Conductor (30) and Side chat (27).
    • public-thread-fork.test.ts and thread-create-seed-without-run.test.ts: 62 of 62 pass. Locally both files still fail at teardown on main's query-plan guard bug (below); with CI's BB_QUERY_PLAN_EXECUTED set they pass.
  • On the previous base (5be1d105359), pnpm exec turbo run test --filter='...[origin/main]' passed apart from two causes unrelated to this branch:
    • isThreadQueueAutoSendPaused (from Cache prepared statements for queue inspections #8367) trips the query-plan guard at file teardown in local runs only: the guard names the caller where the statement runs locally but where it is prepared in CI, and the allowlist names prepareIsThreadQueueAutoSendPaused. A clean origin/main checkout fails the same way. Every test in those files passes.
    • Timeouts and a temp-file race under the full parallel run (install-machine-script, the Guide's plugin-authoring-docs, storage-retention, the provider-literal ratchet, host-daemon injected-skills, 3 integration files) pass when re-run alone.
  • Live, on pnpm start:worktree with Codex turns and Side chat and Conductor installed:
    • In headed Chrome, Add to chat from the "…" menu (user and assistant messages) and from the selection menu each leave focus in the composer with the caret on a new line below the quote; before the menu change, the "…" path left focus on <body>.
    • bb's Fork into new thread from an assistant message opens the fork ("Forked from ok").
    • From a pinned source in a section: Conductor's "Fork to new workspace" creates a new worktree thread that is pinned and in that section. Side chat's "Reply in side chat" (from two different messages) creates hidden forks that are neither pinned nor sectioned.
    • Before "Copy the source's section and pin only into visible forks", a Side chat fork from that source came out pinned and sectioned.
    • The row, menu, selection-menu and 390 px touch-drawer parity checks from the first four commits (with real Claude Code turns) still describe what renders; the later commits change how actions are computed, not where they render.
  • check-bundle-budget.mjs on a local production build of b6a39273c9d: boot payload 1667.4 KB raw / 418.5 KB brotli against main's 1665.1 / 417.8 at a6e31224a29 (budget 1682.1 / 419.1). Against current main the boot payload grows only by this PR's registration validation (+2.7 KB raw), Add to chat's quoting with attachments (net +0.55 KB), the plugin fork's cache insert (+0.65 KB) and image copy (+0.1 KB).
  • Measured on a production build with a 32-row Codex thread, sending one turn: 80 message-row renders and 42 ms of timeline rendering. The thread's bookkeeping updates during the turn (turn start, turn end, mark-read) re-ran Fork's useData but re-rendered no rows. The branch's earlier design, which passed the thread in the item input, did 183 renders and 113 ms on a similar turn. I did not measure main.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael force-pushed the bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc branch 2 times, most recently from b4ed1ca to 8072e74 Compare November 25, 2026 00:19
@ymichael
ymichael force-pushed the bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc branch 2 times, most recently from c41b80d to 31f00f4 Compare November 26, 2026 05:05
@ymichael
ymichael force-pushed the bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc branch 2 times, most recently from 358d77b to 18e8e6c Compare December 1, 2026 05:42
ymichael and others added 13 commits November 30, 2026 21:43
bb's Copy, Edit, Copy link, Add to chat and Fork were hand-wired into the
action row and the selection menu, while slots.messageAction could not say
"assistant only" or "only when available", so plugin actions showed on
messages where they could not work. ThreadChat's messageActions was a second
shape with roles and a narrower run.

The slot now takes experimental_roles, experimental_placements ("inline",
"menu", "selection"), experimental_order and experimental_availability, and
its context carries experimental_invokedFrom, experimental_selectedMarkdown
and experimental_messageRequests (bb's own addToChat, edit and fork). The
message reference adds experimental_settled, experimental_attachments and
experimental_imageUrls, and experimental_copyToClipboard takes an imageUrl.
bb's five actions are registrations in core-contributions/message-actions.ts
and the action row and selection menu render only the resolved list.
ThreadChat takes experimental_messageActions in the same shape; the old
messageActions is deprecated and adapted. Side chat and Conductor declare
their roles and availability.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ExperimentalMessageRequests.addToChat was a second public way to edit the
thread draft beside the composer handle message actions already receive.
Drop it. The availability input now carries the same `composer` that `run`
gets, and bb's Add to chat (row menu and selection menu) is
`composer.replace` with the new `experimental_appendQuoteToDraft`, then
`composer.focus()`.

The quoting code moves from client-core into the SDK's composer draft
transforms so there is one copy: the public export, the test harness,
diff/file/terminal Add to chat, root compose and the retired addQuote all
use it. Message actions also bind to the inline editor of the thread's own
queued message while one is open, so Add to chat quotes into it instead of
disappearing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ExperimentalMessageRequests.fork handed bb's internal fork flow to message
actions even though plugins already fork with sdk.threads.fork. Drop it and
give the availability input a `canFork` flag instead. bb's Fork into new
thread is now sdk.threads.fork then navigate.toThread, the same path
Conductor uses.

The fork route takes over what only bb's button did: it resolves the
source's next-turn model and reasoning level (picker choice before last
turn) and copies the source's section and pin. The plugin-bound fork puts
the new thread in the app's cache before the caller navigates, as bb's
button did, and useForkThreadFromMessage is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
experimental_messageActions takes the same registrations as
slots.messageAction, so the old ThreadChatMessageAction shape was a second
way to declare the same thing. Remove it from the SDK types, docs and test
harness. Compiled plugins that still pass it keep working: PluginThreadChat
adapts each entry into an inline-only registration and warns once per
plugin to move to experimental_messageActions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
experimental_roles, experimental_placements and experimental_availability
gave message actions a decision function and a run function that received
different objects, flags with no reactive source, and a one-member
messageRequests bag. Thread actions already solve the same problem with an
app-wide useData hook and a pure item that returns the evaluated action.

messageAction now takes experimental_useData, experimental_item and
experimental_selectionItem, plus experimental_placement ("inline" or
"menu") and experimental_order. An item returns null or
{ label, icon?, disabled?, run({ invokedFrom }) }; its input is the callback
context plus threadId, message, composer, requestEdit, canFork,
canSpawnChild and data, and the selection input adds { text, markdown }.
MessageActionCollectors runs each useData once for the threads whose
timelines are on screen. The run-only form keeps working where it always
showed. bb's five actions, Side chat, Conductor and ThreadChat's
experimental_messageActions (now ExperimentalThreadChatMessageAction) use
the item form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fork is a top-level thread, but creation ran the child-nesting depth
check on its source, so a thread four levels deep could not be forked or
side-chatted. Fork sources keep their missing, cross-project, archived and
deleted checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The item input drops threadId, canFork and canSpawnChild for thread, the
timeline's thread as experimental_useThread reports it. experimental_useData
takes no input and its collectors run app-wide. bb's Fork and Conductor's
Fork to new workspace read experimental_useProviders through useData and
check the thread's environment, archive state and provider fork support in
item, so isThreadForkable and the hosts' canFork plumbing go away.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
experimental_useData now receives { threadId } and runs once per mounted
timeline instead of once for the whole app, so it runs only while that
thread's messages are on screen. ThreadTimelineRows mounts the collectors and
keeps their values in its own state, which replaces the app-wide store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The item input drops thread; message.threadId is the timeline's thread.
bb's Fork and Conductor read experimental_useThread and
experimental_useProviders in useData and return only whether the thread can
fork, so thread bookkeeping updates no longer re-derive every message's
actions. The action bar resolves a row's actions from the timeline's useData
values itself, so a new value re-renders the action bars, not the messages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Add to chat tests become one table over role, text and attachments.
The two fork-run tests become one sequence: a second click while a fork is
pending does nothing, a rejected fork stays on the source and can be
retried, and the retry opens the fork. The two ordering tests become one
covering inline order and menu placement. The retired ThreadChat role tests
merge, and a duplicate item test and a field-absence assertion go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fork route gave every fork its source's section and pin, so a Side chat
started from a pinned thread became a hidden thread that was pinned and
sectioned with no way to see or unpin it. A hidden fork has no sidebar place,
so it now gets neither; visible forks (bb's Fork, Conductor, bb thread fork)
still do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bb's Fork reads experimental_useProviders in its useData, and the core
message actions load at boot. useProviders lived in plugin-sdk-hooks, so
using it pulled that whole module and its imports (open-target hooks, the
RPC query host, composer effects) into the boot payload: 32 KB raw and
8 KB brotli over main, past the budget. It moves to its own
provider-directory-state module, whose only dependency is already in the
boot payload. The boot payload is now 1 KB brotli over main, which is bb's
message actions moving there from the thread page closure, which shrinks by
about as much.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc branch from 18e8e6c to dcbbcb8 Compare December 1, 2026 05:43
ymichael and others added 5 commits November 30, 2026 22:03
A message action's run showed a check mark on its inline button when it
resolved true, so the meaning of the return value lived only in a doc
comment, an action returning some boolean got a check mark it never asked
for, and it was the only plugin action whose run result drove UI. run now
returns void like every other action and gets confirm(), which shows the
check mark on an inline button and does nothing from a menu. bb's Copy
calls it after a successful copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Message actions sorted by experimental_order alone, with bb's raw order
values in a doc comment, so a plugin had to copy bb's numbers to sit
between its actions. They now sort by experimental_group, then
experimental_order within it, then registration order with bb's own first:
thread actions' rule. experimental_MESSAGE_ACTION_GROUPS exports bb's
groups (copy, edit, compose, branch). The group is optional, unlike other
slots, because slots.messageAction is stable and its run-only form predates
groups; an ungrouped action sorts after every group, where unordered
actions sorted before, so no action moves. Groups draw no separator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The core message action registrations were collected into the plugin slot
store at boot, which put them, Add to chat's quoting and the provider
directory hook in the boot payload, though only timelines use them. The
timeline's useSurfaceMessageActionSlots now puts them ahead of the plugin
slots, so they load with the timeline code as bb's hand-wired actions did
on main. The boot payload drops 0.6 KB brotli, back under its budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The message overflow menu was modal, so its focus trap pulled focus back
from the composer that Add to chat had just focused, and focus fell to
the body when the menu closed. Make it non-modal, as thread action menus
are, so an action that moves focus keeps it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 5926f6c into main Dec 1, 2026
97 of 98 checks passed
@ymichael
ymichael deleted the bb/message-actions-role-and-availability-filters-co-thr_zp3p6kd6tc branch December 1, 2026 18:37
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