Repository navigation
feat(control-ui): give composer actions the pane draft - #200467
Conversation
Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesComposer plugin actions gain live read and write access to the invoking pane’s draft. Example: Click “Shout draft” with “please fix the flaky login test” in the composer.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a useful, narrowly scoped plugin capability with convincing browser evidence and no actionable correctness findings; its maintainer-authored direction is already approved. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI passes its pane-owned draft operations through the plugin contribution bridge and action runner to trusted native plugins. flowchart LR
A[Pane draft owner] --> B[Chat footer]
B --> C[Plugin contribution bridge]
C --> D[Action runner]
D --> E[Scoped composer handle]
E --> F[Plugin action]
F --> A
Technical reviewBest possible solution: Merge the additive scoped handle through the existing action runner and pane draft owner. Do we have a high-confidence way to reproduce the issue? The missing capability is established by the current-main action context and the supplied base-build screenshot showing the action cannot access the draft. Is this the best way to solve the issue? This is the smallest complete extension: it reuses the pane’s existing draft reader, mutation callback and invocation lifetime instead of requiring a full composer replacement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8e8203f07607. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +34, Tests +25, Docs +17. Total +76 across 7 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 2:14 AM ET / 07:14 UTC. |
|
Landed in f1d40db.
|
## Problem
Control UI composer actions (`host.ui.registerAction({ placement: "composer" })`) cannot see or change the draft they sit next to. Their `run` context has `sessionKey`, `agentId`, `session`, `host` and `signal`, but no draft. Only a full composer replacement receives `draft`/`setDraft`, so a plugin that wants a "rewrite my draft" button must replace the whole composer.
## Solution
Composer actions now receive `composer` in their `run` context, bound to the pane that invoked them:
```ts
run: (context: BoardGetParams & {
session?: ControlUiSession;
host: ControlUiHost;
signal: AbortSignal;
/** Composer placement only: the invoking pane's live draft; retires with `signal`. */
composer?: { readonly draft: string; setDraft: (text: string) => void };
}) => void | Promise<void>;
```
- `composer.draft` reads the pane's draft at call time (`getDraft()`, falling back to the rendered `draft`), not a snapshot from the click.
- `composer.setDraft(text)` goes through the pane's existing `onDraftChange`, the same owner the composer replacement uses.
- Once the invocation retires (signal aborted, pane session/agent changed, pane no longer presented, or the registration withdrawn), both throw `This plugin UI view has ended.`, matching retired composer-replacement operations.
- Header and session actions are unchanged and get no `composer`.
The chat footer passes its props into `openclaw-plugin-contributions` as a new `composer` bridge property; `runControlUiPluginAction` wraps it into the scoped handle. Docs: `docs/plugins/feature-plugins.md` has the contract and an example.
## Impact
- Additive, optional field on an experimental SDK type; no export added or removed.
- No CSS, i18n or Gateway changes.
- Production delta: +~37 lines across 5 files; one focused test.
## Evidence
- Unit: `ui/src/plugins/control-ui-contributions.test.ts` "binds composer actions to the invoking pane's live draft until the pane retires": the draft read is live, `setDraft` updates the pane draft, and after the pane's session changes both `draft` and `setDraft` throw and the pane draft is not touched.
- Control UI e2e on real isolated Gateways (dist builds, Playwright Chromium), base = merge base `d0d35ab2a051`, head = this branch. A scratch local plugin (not committed) registers a composer action "Shout draft" that uppercases `context.composer.draft`. Draft typed: `please fix the flaky login test`.
- Head: the draft becomes `PLEASE FIX THE FLAKY LOGIN TEST`; the run context keys are `agentId,composer,host,session,sessionKey,signal`.
- Base: the draft is unchanged; the run context keys are `agentId,host,session,sessionKey,signal`, and the action reports "run context has no composer".
- Gates: `pnpm check:test-types`, `pnpm tsgo:core`, `pnpm tsgo:ui`, oxlint and oxfmt on the changed files, `ocx test ui/src/plugins/` (19 files, 154 tests), `pnpm plugin-sdk:check-exports`, `pnpm plugin-sdk:surface:check`: all pass.




- `pnpm plugin-sdk:api:diff --base d0d35ab --head 10fca91`: one reachable declaration changed, `ControlUiAction.run` context gains optional `composer` (acknowledgement digest `19061910`, consumed at release time). No exports added or removed.
Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Control UI composer actions (
host.ui.registerAction({ placement: "composer" })) cannot see or change the draft they sit next to. Theirruncontext hassessionKey,agentId,session,hostandsignal, but no draft. Only a full composer replacement receivesdraft/setDraft, so a plugin that wants a "rewrite my draft" button must replace the whole composer.Solution
Composer actions now receive
composerin theirruncontext, bound to the pane that invoked them:composer.draftreads the pane's draft at call time (getDraft(), falling back to the rendereddraft), not a snapshot from the click.composer.setDraft(text)goes through the pane's existingonDraftChange, the same owner the composer replacement uses.This plugin UI view has ended., matching retired composer-replacement operations.composer.The chat footer passes its props into
openclaw-plugin-contributionsas a newcomposerbridge property;runControlUiPluginActionwraps it into the scoped handle. Docs:docs/plugins/feature-plugins.mdhas the contract and an example.Impact
Evidence
ui/src/plugins/control-ui-contributions.test.ts"binds composer actions to the invoking pane's live draft until the pane retires": the draft read is live,setDraftupdates the pane draft, and after the pane's session changes bothdraftandsetDraftthrow and the pane draft is not touched.8f0d03fe9c46, head = this branch. A scratch local plugin (not committed) registers a composer action "Shout draft" that uppercasescontext.composer.draft. Draft typed:please fix the flaky login test.PLEASE FIX THE FLAKY LOGIN TEST; the run context keys areagentId,composer,host,session,sessionKey,signal.agentId,host,session,sessionKey,signal, and the action reports "run context has no composer".pnpm check:test-types,pnpm tsgo:core,pnpm tsgo:ui, oxlint and oxfmt on the changed files,ocx test ui/src/plugins/(19 files, 154 tests),pnpm plugin-sdk:check-exports,pnpm plugin-sdk:surface:check: all pass.pnpm plugin-sdk:api:diff --base 8f0d03fe9c46 --head 10fca91ed4a6: one reachable declaration changed,ControlUiAction.runcontext gains optionalcomposer(acknowledgement digest19061910, consumed at release time). No exports added or removed.