Skip to content

feat(plugins): composer actions can need a draft and insert their result - #201898

Merged
obviyus merged 2 commits into
mainfrom
better-auto-insert
Nov 19, 2026
Merged

obviyus merged 2 commits into
mainfrom
better-auto-insert

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A composer action that rewrites the draft, like Better, has two rough edges with the task card from #201695:

  • It can be clicked with an empty composer, though it only works on text the user typed. The SDK gave resolve no way to see the draft.
  • Its result always waits behind Use. For an action whose result the user asked for and nearly always takes, that extra step is friction: they already pressed the button.

User Impact

  • A composer action's resolve receives the pane's current draft, and the host re-resolves as the user types. An action can return { disabled: !draft.trim() } and stay disabled until there is text, like the send button.
  • task.propose(text, { title, insert: true }) (and composer.propose) replaces the draft at once: the same single editor undo step and Draft replaced · not sent · Undo receipt as Use, never sent. While dictation or a pending goal locks the editor, or during IME composition, it falls back to the proposal card so Use writes it once the editor is writable.

Both are optional and additive; existing actions behave as before.

Why This Change Was Made

  • One owner: the pane's task owner does the insert through the same path as Use (apply: settle as accepted, one editor replacement, receipt). It reads the editor through an accessor that returns nothing mid-composition, so the lock rule stays the same as Use.
  • Resolve sees the draft where it already runs: the contributions renderer reads the handle's reactive draft, so a disabled state follows typing without a new subscription; the runner passes the same draft to resolve before running, so a stale click on a disabled action is refused.

Evidence

  • New e2e in ui/src/e2e/native-plugin-composer.e2e.test.ts: an icon action with resolve: ({ draft }) => ({ disabled: !draft?.trim() }) is disabled on an empty composer and enabled after typing; its insert: true result replaces the draft with no proposal card, resolves "accepted", Undo restores the draft, zero chat.send. All 10 composer-task e2e tests and the unit tests pass.
  • tsgo:ui, tsgo:core, oxlint, oxfmt, check:control-ui-controllers, line-cap and test-lines ratchets.
  • Real run with a real model on a source Gateway from this branch with the Better plugin: screenshots in the comments.

SDK impact. Additive: optional draft in a composer action's resolve context, optional insert on ControlUiDraftProposal. ControlUiAction has no ClawHub or bundled consumers besides Better (checked for #201695).

@clawsweeper

clawsweeper Bot commented Nov 19, 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 19, 2026
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Real run with a real model (Claude Sonnet 5.5) on a source Gateway from this branch with the Better plugin: Better is disabled on an empty composer, then its result replaces the draft at once with the Undo receipt (2,324 characters, nothing sent); Undo restored the draft.

Empty composer: Better disabled

Result inserted at once with the Draft replaced Undo receipt

Undo restores the draft

@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: 🐚 platinum hermit Good normal PR readiness with ordinary 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 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Composer actions can resolve against the current draft and optionally insert a proposed result immediately with Undo.

Example: A rewrite action transforms “first draft” into “A rewritten draft.”

  • Before: The action cannot disable itself based on the draft, and its result requires pressing Use.
  • After: The action can disable itself on empty text and insert its result immediately; Undo restores “first draft” without sending anything.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused implementation with real UI evidence and no concrete introduced defect; CI failure attribution remains unresolved.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected screenshots from the contributor's source-Gateway run with Better show empty-draft disabling, immediate insertion with the not-sent Undo receipt, and restoration of the original draft.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Draft-dependent actions remain clickable on empty input, and rewrite results require an extra Use click.
Reason: The feature owner supplies the direction, optional behavior preserves existing plugins, and Better provides a concrete consumer.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds useful composer capabilities through the existing owner, with inspected live screenshots and no concrete correctness finding.

Priority: P2
Reviewed head: a12a92a4b9026b3a259bcc7f2069a3de6a2be02c

Before merge

None.

Findings

None.

Agent review details

How this fits together

Control UI plugin actions receive pane context, invoke the pane's composer task owner, and produce editor replacements or proposal cards with an Undo receipt.

flowchart LR
  A[Pane draft] --> B[Action resolver]
  B --> C[Plugin action]
  C --> D[Composer task owner]
  D --> E[Writable editor]
  D --> F[Proposal card]
  E --> G[Undo receipt]
  F --> E
Loading

Technical review

Best possible solution:

Retain the optional SDK additions and shared task-owner insertion path while preserving existing proposal defaults and Undo.

Do we have a high-confidence way to reproduce the issue?

This is an additive feature request; current-main source confirms that resolve lacks draft context and proposals always await acceptance.

Is this the best way to solve the issue?

The implementation is appropriately small: reactive draft context reaches the existing resolver, and immediate insertion shares the existing acceptance operation without another state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 44267df6c5ea.

Provenance checked

  • Composer proposal acceptance changes intended behavior with a stated reason (a3d7e40: Centralize task presentation, explicit acceptance, editor Undo, and locked-editor handling in the host.)
  • Action resolution and pane draft binding keeps the original intent (feat(control-ui): give composer actions the pane draft #200467: Give actions live pane-bound draft access without requiring a replacement composer.)
  • Reactive contribution rendering keeps the original intent (939f740: Port plugin presentation to Solid while preserving SDK contracts and retained view ownership.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +42, Tests +32, Docs +5. Total +79 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 62 20 +42
Tests 3 35 3 +32
Docs 1 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 104 25 +79

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
Optional SDK fields 2 Adds resolve-context draft and proposal insert without removing existing fields or changing the default proposal behavior.

Labels

Label changes:

  • add P2: A useful, limited-scope improvement to optional plugin composer workflows.
  • add merge-risk: 🚨 compatibility: Extends the public plugin SDK; the maintainer-authored direction explicitly documents additive optional fields and retains existing defaults.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A useful, limited-scope improvement to optional plugin composer workflows.
  • merge-risk: 🚨 compatibility: Extends the public plugin SDK; the maintainer-authored direction explicitly documents additive optional fields and retains existing defaults.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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 19, 2026, 10:13 AM ET / 15:13 UTC.

@obviyus
obviyus merged commit 5aed410 into main Nov 19, 2026
116 checks passed
@obviyus
obviyus deleted the better-auto-insert branch November 19, 2026 15:54
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 5aed410. Composer actions can now stay disabled until there is a draft (resolve receives draft), and propose(..., { insert: true }) replaces the draft at once with the Undo receipt. Proof: new e2e (disabled on empty, inserted at once, Undo restores, zero chat.send), all composer and native plugin UI e2e green, clean local review and green CI on f93a77d, chat boot JS unchanged, and a real model run with the Better plugin (screenshots above).

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…ult (openclaw#201898)

## What Problem This Solves

A composer action that rewrites the draft, like Better, has two rough edges with the task card from openclaw#201695:

- It can be clicked with an empty composer, though it only works on text the user typed. The SDK gave `resolve` no way to see the draft.
- Its result always waits behind **Use**. For an action whose result the user asked for and nearly always takes, that extra step is friction: they already pressed the button.

## User Impact

- A composer action's `resolve` receives the pane's current `draft`, and the host re-resolves as the user types. An action can return `{ disabled: !draft.trim() }` and stay disabled until there is text, like the send button.
- `task.propose(text, { title, insert: true })` (and `composer.propose`) replaces the draft at once: the same single editor undo step and **Draft replaced · not sent · Undo** receipt as **Use**, never sent. While dictation or a pending goal locks the editor, or during IME composition, it falls back to the proposal card so **Use** writes it once the editor is writable.

Both are optional and additive; existing actions behave as before.

## Why This Change Was Made

- **One owner:** the pane's task owner does the insert through the same path as **Use** (`apply`: settle as accepted, one editor replacement, receipt). It reads the editor through an accessor that returns nothing mid-composition, so the lock rule stays the same as **Use**.
- **Resolve sees the draft where it already runs:** the contributions renderer reads the handle's reactive `draft`, so a disabled state follows typing without a new subscription; the runner passes the same draft to `resolve` before running, so a stale click on a disabled action is refused.

## Evidence

- **New e2e** in `ui/src/e2e/native-plugin-composer.e2e.test.ts`: an icon action with `resolve: ({ draft }) => ({ disabled: !draft?.trim() })` is disabled on an empty composer and enabled after typing; its `insert: true` result replaces the draft with no proposal card, resolves `"accepted"`, Undo restores the draft, zero `chat.send`. All 10 composer-task e2e tests and the unit tests pass.
- `tsgo:ui`, `tsgo:core`, oxlint, oxfmt, `check:control-ui-controllers`, line-cap and test-lines ratchets.
- Real run with a real model on a source Gateway from this branch with the Better plugin: screenshots in the comments.
- Chat boot JS is unchanged against main (the task owner reads the pane state itself, so no new wiring loads with a chat).

**SDK impact.** Additive: optional `draft` in a composer action's `resolve` context, optional `insert` on `ControlUiDraftProposal`. `ControlUiAction` has no ClawHub or bundled consumers besides Better (checked for openclaw#201695).

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: 🐚 platinum hermit Good normal PR readiness with ordinary 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