Skip to content

feat(control-ui): give composer actions the pane draft - #200467

Merged
obviyus merged 1 commit into
mainfrom
composer-action-draft
Nov 17, 2026
Merged

obviyus merged 1 commit into
mainfrom
composer-action-draft

Conversation

@obviyus

@obviyus obviyus commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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:

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 8f0d03fe9c46, 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.

Head: draft before Shout draft

Head: draft uppercased by the composer action

Base: draft before Shout draft

Base: action has no composer context; draft unchanged

  • pnpm plugin-sdk:api:diff --base 8f0d03fe9c46 --head 10fca91ed4a6: one reachable declaration changed, ControlUiAction.run context gains optional composer (acknowledgement digest 19061910, consumed at release time). No exports added or removed.

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S labels Nov 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Composer 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.

  • Before: The action receives no composer context and leaves the draft unchanged.
  • After: The action changes the draft to “PLEASE FIX THE FLAKY LOGIN TEST”.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused implementation, direct before/after browser evidence, meaningful lifetime coverage and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The supplied isolated-Gateway Chromium scenario exercises a real registered composer action through the Control UI: inspected screenshots show the head rewriting the draft and the base reporting the absent composer context.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Plugin authors must replace the entire composer to offer a button that reads or rewrites its draft.
Reason: The maintainer-authored extension removes that unnecessary replacement requirement while preserving core draft ownership and existing action behavior.

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
Reviewed head: 10fca91ed4a636c80d33afa1c1173b9b214e421c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change: The pinned introduction diff adds an optional composer context and forwards the existing pane draft operations without introducing another draft store. (ui/src/plugins/control-ui-actions.ts:99, 10fca91ed4a6)
  • Current main still lacks the capability: The current-main action runner supplies session identity, host and signal, while draft operations remain available through composer replacements. (ui/src/plugins/control-ui-actions.ts:93, 8e8203f07607)
  • Browser behavior evidence: Inspected all four downloaded screenshots linked in the PR body: the isolated head build uppercases the entered draft, while the base build displays “run context has no composer” and retains the original text. (10fca91ed4a6)
  • Existing lifetime contract preserved: The new handle checks the existing invocation signal before each draft operation; pane session, agent and presentation changes already retire that signal. The added integration test exercises live reads, writes and rejection after session replacement. (ui/src/plugins/control-ui-contributions.test.ts:407, 10fca91ed4a6)
  • SDK direction and compatibility: The collaborator-authored PR explicitly proposes one optional field on the experimental action context, documents its lifetime, and records successful SDK surface checks; existing action implementations remain source-compatible. (src/plugin-sdk/control-ui.ts:213, 10fca91ed4a6)
  • Feature ownership history: History across the original contribution renderer and its Solid successor identifies Peter Steinberger’s original feature-plugin implementation and subsequent lifecycle and presentation refactors as the central ownership trail. (ui/src/plugins/control-ui-actions.ts:42, 6a97159ececb)

PR surface

Source +34, Tests +25, Docs +17. Total +76 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 35 1 +34
Tests 1 25 0 +25
Docs 1 17 0 +17
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 77 1 +76

Preflight source

Source 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

Metric Value Why it matters
Public SDK extension 1 optional action-context field Adds composer access without requiring existing plugins to change their action implementations.

Labels

Label changes:

  • add P2: A useful plugin extension with limited scope and no demonstrated urgent regression.
  • add merge-risk: 🚨 compatibility: Extends the public experimental Plugin SDK; the maintainer-authored direction accepts an additive optional field that preserves existing callers.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A useful plugin extension with limited scope and no demonstrated urgent regression.
  • merge-risk: 🚨 compatibility: Extends the public experimental Plugin SDK; the maintainer-authored direction accepts an additive optional field that preserves existing callers.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 17, 2026, 2:14 AM ET / 07:14 UTC.

@obviyus
obviyus merged commit f1d40db into main Nov 17, 2026
140 checks passed
@obviyus
obviyus deleted the composer-action-draft branch November 17, 2026 13:25
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in f1d40db.

  • Gap: a Control UI composer action could not read or replace the pane's draft, so a plugin had no way to put text into the input box.
  • Fix: composer actions now receive composer: { draft, setDraft } for the pane they run in.
  • Proof: control-ui-contributions.test.ts and the before/after Control UI run in the PR; the local review of this exact head was clean, and CI was green.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
## 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.

![Head: draft before Shout draft](https://github.com/user-attachments/assets/a5c61072-dd0b-4181-bd14-ecbfdc5d120d)

![Head: draft uppercased by the composer action](https://github.com/user-attachments/assets/0e269c2b-bc9b-4da1-852a-dcf8f35c8976)

![Base: draft before Shout draft](https://github.com/user-attachments/assets/f83d4e90-d614-44c6-b64e-76b0d2daaa2a)

![Base: action has no composer context; draft unchanged](https://github.com/user-attachments/assets/2493c9c4-b25a-4458-a7df-01fbfe666692)

- `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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant