Skip to content

feat(conversation): show a page's header actions in the workspace toolbar - #4072

Open
gilgtm wants to merge 2 commits into
mainfrom
needs-you/workspace-header-slot
Open

gilgtm wants to merge 2 commits into
mainfrom
needs-you/workspace-header-slot

Conversation

@gilgtm

@gilgtm gilgtm commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A plugin page that embeds ui.Workspace can now put its own buttons in the Workspace toolbar. Today that toolbar holds only the host's menu and pane toggle, so a page has to add a second bar above the Workspace for its own toggles. This PR adds one optional prop, headerActions, and a flag so a plugin can tell whether the running host supports it.

flowchart LR
  W["Plugin page<br/>ui.Workspace headerActions={buttons}"]
  W --> A1
  W --> A2
  subgraph Closed["Side pane closed"]
    direction LR
    A1["Page buttons<br/>(headerActions)"] --> M1["⋯ Conversation actions"] --> T1["Pane toggle"]
  end
  subgraph Open["Side pane open"]
    direction LR
    A2["Page buttons<br/>(headerActions)"] --> M2["⋯ Conversation actions"] ~~~ T2["Pane toggle<br/>(moved to the pane's header)"]
  end
Loading

The host draws the page's buttons first, then its own menu. The page owns the buttons and their pressed and badge states. With the side pane open, the host already moves its pane toggle into the pane's header; this PR does not change that.

Screenshots

Fixture plugin, test data only. The page passes one dashboard toggle (pressed, with a "3" badge) as headerActions.

Toolbar close-ups:

Light Dark
Side pane closed Light theme toolbar: the page's dashboard toggle sits left of the Conversation actions menu Dark theme toolbar: dashboard toggle, then the Conversation actions menu, then the host's pane toggle
Side pane open Light theme toolbar with a thread open: toggle and menu stay in the main header; the pane toggle sits in the pane header Dark theme toolbar with a thread open: same layout

The host shows its pane toggle only after the pane has held a tab, so the first light close-up has none.

Full window, side pane open:

Light Dark
Full light window with the plugin page, the toolbar toggle and a thread in the side pane Full dark window with the same layout

Video

header-20261123-175917-annotated.mp4

The packaged macOS app, run against a local relay (56 s, annotated). It shows the toolbar with no page buttons, then adds a toggle and presses it. Next it opens a thread in the side pane, narrows the window to 1000 px, closes the pane and removes the toggle.

API

  • ConversationWorkspaceProps.headerActions?: ReactNode. It renders in the main tab's toolbar, before the Conversation actions menu, while that tab is selected.
  • ctx.conversation.workspaceSlots?.headerActions === true when the host renders it. workspaceSlots is a frozen object that names each optional ui.Workspace prop the host renders.
  • The authoring guide asks for compact icon buttons with aria-label and title, plus aria-pressed or aria-expanded on a toggle.

How

  • PageTabs.tsx passes headerActions into the main tab's existing toolbar item, which PanelWorkspace already draws before the pane toggle. Most of that diff re-indents the existing menu into a fragment.
  • With neither headerActions nor menu actions, the toolbar stays absent, as before.
  • contracts.ts and service.tsx (both FOUNDATION files) change only by the prop, the flag and their doc comments.
  • PanelWorkspace and the pane toggle are unchanged. The slot names no plugin.

Risk

Low. The prop is optional and only plugin pages that pass it see a change. An older host has no workspaceSlots, so the flag reads undefined and React ignores the unknown prop. Plugins should check the flag and keep their own chrome as a fallback.

Testing

Native macOS run of head 86733c2dd: packaged debug app, local relay, throwaway fixture plugin (not committed). The video and screenshots above come from that run. For each step, the run checked the DOM: the page button sits inside the main header, left of the Conversation actions menu, on the same row, and aria-pressed follows the page's state. With the side pane open, the pane toggle sits in the pane's header, not the main one. At 1000 px the order holds and nothing leaves the header.

New unit tests cover the DOM order with and without a menu, and the flag a plugin sees. Both fail against main. No browser case was added: jsdom checks the order, and the toolbar layout itself is unchanged.

Known limits

🤖 Generated with Claude Code

gilgtm and others added 2 commits November 23, 2026 11:27
…lbar

`ConversationWorkspaceProps.headerActions` renders in the main tab's
toolbar, before the conversation actions menu, so a page can offer its own
controls with pressed, expanded and badge states. Plugins detect the slot
with `conversation.workspaceSlots.headerActions === true`; an older host
ignores the prop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gil Birman <gil@squareup.com>
- Keep the main tab's toolbar empty, as before, when a workspace has
  neither header actions nor menu actions.
- Recommend plain icon buttons with `aria-pressed` or `aria-expanded`
  for header toggles; the plugin `ui.Button` forwards neither.
- Type `workspaceSlots` and its flag as optional, as other
  feature-detected capabilities are, so plugin code checks before use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gil Birman <gil@squareup.com>
@gilgtm
gilgtm force-pushed the needs-you/workspace-header-slot branch from 8de1d3f to 86733c2 Compare November 23, 2026 17:31
@gilgtm
gilgtm marked this pull request as ready for review November 23, 2026 17:46
@gilgtm
gilgtm requested a review from a team as a code owner November 23, 2026 17:46

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord reviewed 86733c2 from source and recommends fixing capability detection before merge. Core-team decision: should the workspace accept plugin-rendered controls, or provide typed actions that the host can render with its accessible toolbar controls?

private readonly chatIconEntries;
readonly ui: Conversation["ui"];
readonly workspaceSlots = Object.freeze({
headerActions: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Report support from the active workspace provider. Any plugin can register a workspace, and the first active provider wins. If that provider ignores headerActions, a caller following the documented flag check drops its fallback and the controls disappear. Have the selected provider declare support and leave the flag absent when the provider omits it.

@dr0uleau
dr0uleau requested a review from a team November 23, 2026 18:00

This branch has not been deployed

No deployments
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.

2 participants