Skip to content

fix(ui): keep composer textarea native undo and redo working - #131750

Merged
Patrick-Erichsen merged 9 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-131708-webchat-textarea-redo
Aug 29, 2026
Merged

Patrick-Erichsen merged 9 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-131708-webchat-textarea-redo

Conversation

@LiuwqGit

Copy link
Copy Markdown
Contributor

AI-assisted: yes

Closes #131708

What Problem This Solves

  • Fixes an issue where users typing in the WebChat/Control UI composer would lose native redo: after deleting drafted text, Cmd+Z restored it, but Shift+Cmd+Z (redo) did nothing, so content undone one step too far was unrecoverable.
  • The reporter traced this to the composer textarea being re-applied by a controlled binding after every native input, which resets the browser's undo/redo bookkeeping for the element.

Why This Change Was Made

  • Intended outcome: the composer stays state-backed, but the textarea's value binding is now hands-off whenever the DOM already holds the draft, so typing, native undo, and native redo all behave exactly like an uncontrolled textarea.
  • Out of scope: no changes to draft persistence, IME, dictation, slash menus, or any other composer behavior; the binding still replaces the textarea value whenever the host draft genuinely changes (send clear, session switch, history recall, dictation preview).
  • Highest-risk area: the value-binding write conditions; mitigated by a dedicated directive unit suite and the existing composer regression suite.

User Impact

  • Success criteria: in the composer, type → select all → delete → Cmd+Z restores the text → Shift+Cmd+Z re-applies the deletion, with zero programmatic value writes on the textarea during native input or undo/redo.
  • What should reviewers focus on: ui/src/pages/chat/components/chat-composer-draft-value.ts (the binding directive) and its write conditions; regression coverage in ui/src/pages/chat/components/chat-composer-draft-value.test.ts and ui/src/pages/chat/chat-composer-undo-redo.browser.test.ts.

Evidence

  • Real environment tested: full Control UI served by the Vite dev server (startControlUiE2eServer) in real Google Chrome 151 (Linux, headless via Playwright) with the mock gateway from ui/src/test-helpers/control-ui-e2e.ts; real keyboard events (typing, Ctrl+A, Backspace, Ctrl+Z, Ctrl+Shift+Z) against the composer textarea.
  • Exact steps or commands run after this patch:
    npx vitest run --config vitest.config.ts --project unit-node src/pages/chat/chat-composer-undo-redo.browser.test.ts
    npx vitest run --config vitest.config.ts --project unit src/pages/chat/chat-view.test.ts src/pages/chat/chat-pane.test.ts src/pages/chat/components/
    node scripts/run-tsgo.mjs -p tsconfig.ui.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/ui.tsbuildinfo
    npx oxlint --deny=warn --ignore-path=.oxlintignore <changed files> && npx oxfmt --check <changed files>
  • Evidence after fix: browser test outcome Tests 2 passed (2): "keeps native redo working after undo in the composer textarea" (type "hello world test" → Ctrl+A/Backspace → "" → Ctrl+Z → "hello world test" → Ctrl+Shift+Z → "") and "does not re-apply the textarea value after native input" (0 programmatic textarea value writes across the typing and undo/redo key sequences). Directive unit suite Tests 4 passed (4); composer regression suite Tests 1088 passed (1088).
  • Observed result after fix: native undo/redo in the composer behaves like a plain textarea, and the draft binding no longer writes the value back after native input.
  • Before evidence (optional, visual changes encouraged): on unpatched main the same browser run reports expected 16 to be +0 — 16 programmatic textarea value writes while typing a 16-character draft (one per keystroke, plus one after each native undo/redo), matching the per-input re-apply the issue describes. On the reporter's macOS Chrome that re-apply is what kills the redo chain; Chrome 151 tolerates equal-value writes, which is why the behavioral failure is asserted alongside the deterministic write-count root cause.
  • What was not tested: the reporter's exact macOS Chrome build (undo/redo stack semantics vary across Blink versions) and a live non-mock gateway session; the composer code path is identical and the mock-gateway harness exercises the real chat pane, composer, and draft-owner wiring.
  • Proof tier: L2
  • Proof limitations: none beyond the untested environments listed above.
  • Review state: Awaiting CI + maintainer review.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 9:58 PM ET / August 29, 2026, 01:58 UTC.

ClawSweeper review

What this changes

The PR changes the Control UI chat composer to avoid rewriting an unchanged textarea value during renders, with a real-browser regression test for native undo and redo.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer review: current main still performs the unconditional textarea value assignment, while this PR replaces it with a focused native-edit-safe binding and retains state-driven draft updates. No blocking defect was found in the introduced change.

Priority: P2
Reviewed head: f2112c7319c0762b9e5f8a724958526b17a8e115

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with meaningful browser evidence and no identified correctness or security defect.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (recording): The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (recording): The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.
Evidence reviewed 6 items Introduced binding change: The exact PR head wraps the textarea value binding in Lit guard and live directives, restricting re-evaluation to draft changes while retaining DOM-equality-aware value application.
Owner and caller path: The chat view calls the composer; its native input handler commits the textarea value to the draft owner and requests rendering, which is the render cycle the new binding targets.
Current-main comparison: Fetched current main still has the unconditional .value=${dictationPreviewDraft} assignment; the three-file PR delta is not already implemented on main.
Findings None None.
Security None None.

How this fits together

The Control UI chat composer renders the current draft into a native textarea and sends native edits back to the chat draft owner. The composer must preserve native browser editing history while still reflecting genuine external draft changes such as sends, history recall, and dictation.

flowchart LR
  A[Chat draft owner] --> B[Composer renderer]
  B --> C[Guarded live textarea binding]
  C --> D[Native keyboard editing]
  D --> E[Input handler]
  E --> A
  A --> F[External draft changes]
  F --> B
Loading

Before merge

  • Resolve merge risk (P1) - Direct inspection of Lit 3.3.3 directive source was infeasible in this partial checkout, so the dependency-contract portion of the review rests on the pinned version, in-repo use, and supplied browser proof.
  • Resolve merge risk (P1) - Production code grows by one net line to compose the required guard and live directives; this is a narrowly justified cost because using either directive alone would not protect both unrelated rerenders and genuine host-draft changes.
  • Complete next step (P2) - This active PR already owns the narrow repair; no separate ClawSweeper fix job is warranted.
Agent review details

Security

None.

PR surface

Source +2, Tests +118. Total +120 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 1 +2
Tests 1 118 0 +118
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 121 1 +120

Review metrics

Metric Value Why it matters
Production versus test delta production +2/-1 (net +1); browser test +118; test configuration +1 The small production increase is the two-directive composition needed to preserve both native history and external draft synchronization; the rest is focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #131708
Summary: This PR explicitly targets the open native-redo composer defect tracked by the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the guarded live binding and its browser regression coverage, then merge once exact-head checks complete and the Lit directive contract is available for final maintainer verification.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the guarded live binding and its browser regression coverage, then merge once exact-head checks complete and the Lit directive contract is available for final maintainer verification.

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

Yes—current main’s unconditional textarea assignment is directly identified, and the supplied real-browser sequence exercises typing, deletion, undo, and redo through the production composer path. The reviewer did not execute contributor code locally because this is an external PR.

Is this the best way to solve the issue?

Yes—the binding change repairs the render-time owner boundary without introducing an app-level undo stack, while live() preserves genuine external draft replacement. Direct Lit source inspection remains unavailable in this partial checkout.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against feb1161a1e64.

Labels

Label changes:

  • add proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.

Label justifications:

  • P2: This fixes a bounded Control UI composer editing regression without an availability, security, or data-loss impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The changed production owner is the composer textarea binding at ui/src/pages/chat/components/chat-composer-view.ts:412; supplied evidence runs the full Vite-served Control UI in real Chrome with native keyboard events and reports successful undo/redo plus zero programmatic writes after the fix. The contributor update also reports sanitized before/after recordings, though GitHub artifact inspection was unavailable in this review environment.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Composer-view history identifies his Control UI goals change as the most relevant current-main feature work near this binding. (role: recent Control UI feature contributor; confidence: medium; commits: 047470456ff2; files: ui/src/pages/chat/components/chat-composer-view.ts, ui/src/pages/chat/chat-view.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-28T11:50:48.222Z sha 038725e191d01f3a8f733d98d168b6308dba795c :: needs real behavior proof before merge. :: none
  • reviewed August 28, 2026, 8:30 AM ET / 12:30 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-28T15:16:49.316Z sha 055cd3a :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-28T16:08:39.333Z sha 055cd3a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T00:02:17.533Z sha 0f273b6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T01:50:09.959Z sha 86e38ac :: needs maintainer review before merge. :: none

@LiuwqGit
LiuwqGit force-pushed the feat/issue-131708-webchat-textarea-redo branch from 038725e to 055cd3a Compare August 28, 2026 15:08
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 28, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — PR body Evidence now links inspectable sanitized browser captures (before/after screenshots and screen recordings of the undo/redo key sequence with a programmatic-value-write HUD: 20 writes unpatched → 0 writes patched), and the branch is rebased onto latest main with all checks green.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 28, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: 🎥 video Contributor real behavior proof includes video or recording evidence. label Aug 29, 2026

@Patrick-Erichsen Patrick-Erichsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified at exact head f2112c7: the composed Lit guard()+live() binding preserves stale local DOM edits, applies genuine owner changes, and retains native Chromium undo/redo. Exact-head CI and fresh ClawSweeper are clean.

@Patrick-Erichsen
Patrick-Erichsen merged commit bf94ec5 into openclaw:main Aug 29, 2026
177 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…w#131750)

* fix(ui): keep composer textarea native undo and redo working

* fix(ui): preserve repeated composer host writes

* style(ui): normalize composer directive imports

* fix(ui): use Lit live binding for composer draft

* fix(ui): preserve uncommitted composer drafts

---------

Co-authored-by: Patrick Erichsen <[email protected]>
@LiuwqGit
LiuwqGit deleted the feat/issue-131708-webchat-textarea-redo branch September 22, 2026 14:47
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. 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.

WebChat textarea: native redo (Shift+Cmd+Z) broken — controlled re-rendering breaks the undo/redo chain

2 participants