Skip to content

fix(ui): prevent Safari IME confirmation from submitting chat inputs - #161302

Merged
obviyus merged 3 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-161259-safari-ime-enter
Sep 30, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-161259-safari-ime-enter

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #161259

What Problem This Solves

Fixes premature message sends, annotation saves, and session renames when Enter confirms Japanese/CJK input in Safari.

User Impact

Users can confirm converted text without submitting it. A subsequent deliberate Enter or configured send shortcut still works, including immediately after releasing the confirmation key. No configuration change or migration is required.

Why This Change Was Made

Safari can deliver the committing Enter after compositionend, with both isComposing and the legacy IME key code cleared. The three affected inputs now share an input-local, 100 ms composition-end guard. It releases on key-up, blur, or a new non-composing key, and expires if release events are missed. It preserves the browser's native confirmation behavior and survives composer rerenders without blocking another input.

The timestamp comparison also covers native key events created just before the composition-end event. Existing active-composition and blur recovery behavior remains intact.

Evidence

  • Before the fix: eight initial regression cases failed through the rendered composer, annotation editor, and rename input.
  • After the fix: all 242 tests across four component files passed, covering negative/positive event timestamps, rerenders, separate inputs, modifier shortcuts, immediate key-up/blur/new-key recovery, and bounded expiry. Existing IME coverage moved into the narrow composer fixture without dropping cases.
  • Browser boundary: the production Control UI build and the modified Chromium/mocked-Gateway E2E passed. The test dispatches compositionend followed by a normal Enter, verifies that the Japanese draft remains and no chat.send occurs, then verifies normal sends, multiline input, active IME input, and changed send-shortcut settings.
  • Hosted validation: GitHub CI passed for 1c7375ad2eed4aa6052a4a245fbecfcf33017924, including openclaw/ci-gate, production/test types, lint, guards, all three UI test shards, all selected browser E2E shards, and real-Gateway E2E.
  • Independent review: fresh Codex autoreview completed with no accepted/actionable findings at the repository's default P0 threshold.
  • Limits: native macOS Safari with the Japanese OS input method has not been exercised. The browser proof reproduces the reported event contract in Chromium; it is not native Safari proof. The ClawSweeper review found no actionable patch defect and requests native Safari/WKWebView proof for all three inputs before merge; that merge prerequisite remains open.
Commands and measured test cost

Component suite:

node scripts/run-vitest.mjs \
  ui/src/pages/chat/chat-composer-ime.test.ts \
  ui/src/pages/chat/chat-view.test.ts \
  ui/src/pages/chat/components/chat-selection-popup.test.ts \
  ui/src/pages/chat/components/chat-pane-header.test.ts \
  --maxWorkers=1 --reporter=dot

242/242 passed: 7.69 s Vitest duration, 8.68 s runner wall time.

Each file was also measured with pnpm test <file> --maxWorkers=1 --reporter=dot (single-file wall time, on this host alongside type checking):

Test file Tests Local wall CI test execution CI module elapsed
chat-composer-ime.test.ts 10 10.09 s 0.076 s 0.529 s
chat-view.test.ts 167 20.18 s 12.366 s 33.856 s
chat-selection-popup.test.ts 19 6.92 s 0.098 s 0.164 s
chat-pane-header.test.ts 46 16.57 s 2.132 s 2.752 s

CI values come from the Vitest module diagnostics in UI shards 1/3 and 2/3. Module elapsed includes collection and setup; it is not total job time.

Browser proof, reusing the existing E2E suite and test case:

node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner \
  ui/src/e2e/chat-flow.messaging.e2e.test.ts \
  -t 'persists the chat send shortcut' --reporter=dot

Locally, 1 selected case passed, 18 unselected: 24.94 s including the production UI build (13.37 s). Hosted E2E shard 7/9 subsequently passed all 19 tests in this file in 24.725 s; the changed IME/shortcut case took 1.703 s. An initial version of the fix blocked an immediate modifier shortcut in this existing E2E; clearing the grace on new key intent fixed that defect, with three added recovery regressions failing before that correction and passing afterward.

git diff --check passed. The local changed-file command was interrupted during its test-type phase and is not counted as a complete local pass; the exact-head hosted type, lint, and guard checks above completed successfully.

Additional event-sequence verification (September 30)

Thanks to @stbtyx747 for the report and @NianJiuZst for the fix. Contributor commits are preserved. Added browser regression coverage for input-only beforeinput/input insertText commits, keyCode 229 with isComposing=false, and Shift+Enter. All three touched submit owners share the same IME helper; no additional production gap was established.

Secretless Linux Docker verification: 242/242 tests across the four affected component files passed (32.01s Vitest); the expanded built-Chromium E2E passed (14.99s including UI build). Against origin/main 670c2d0d6a0566e8e29191d70540f4aab8ff48a9, the same composer regressions failed 4/10 cases, and the identical browser case failed at the post-composition confirmation assertion (12.82s). The input-only sequence itself is a compatibility guard, not a claim that main sends without keydown.

A second proof used each actual built Gateway and Control UI with a scripted local Anthropic SSE model: synthetic confirmation cleared the baseline draft and produced a reply; candidate retained 日本語 until key release and deliberate Enter, then produced a reply. Both local servers are retained for manual Safari comparison. This remains synthetic Chromium evidence, not native IME evidence.

Sources: WebKit 165004 documents compositionend-before-keydown and false isComposing; MDN keydown recommends retaining the keyCode 229 guard. Importantly, that WebKit bug is now resolved via 311717, landed April 2026; it is not evidence that every current Safari version reproduces the historical order. MDN beforeinput documents OS/IME-dependent edit events. The 100ms fallback is a heuristic, not a native timing guarantee.

Still required before merge: native Japanese/Chinese IME confirmation and subsequent deliberate Enter in Safari/WKWebView for composer, rename and annotation. No native result is claimed; no macOS input settings were changed. Exact-head CI and review for the new test-only commit must be evaluated separately from the earlier green head.

No overlap with Pash/Sarah changes.

Actual Gateway comparison (synthetic Chromium IME replay)

Baseline prematurely submitted the Japanese draft and received the scripted local model reply:

Baseline: confirmation sent the draft

Candidate retained the Japanese draft on confirmation, before deliberate Enter:

Candidate: confirmation retained the draft

These inspected screenshots show built UI plus real isolated Gateway behavior, not native Safari or WKWebView IME. Final test-only repair head: fd42ff071d49e798d51bb6deb9e2c5ee4f9e4b8c; oxfmt, scoped type-aware lint, both UI type graphs and the relocated browser regression pass in Docker. The IME/send-shortcut regression now resides in chat-flow.composer-shortcuts.e2e.test.ts.

@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@NianJiuZst
NianJiuZst marked this pull request as ready for review September 29, 2026 17:27
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 30, 2026, 12:44 AM ET / 04:44 UTC (Revision 4).

ClawSweeper review

What this changes

The Control UI adds a short, input-local guard so an IME confirmation Enter does not send a chat draft, save an annotation, or commit a session rename.

Merge readiness

⛔ Blocked before merge - 3 items remain

The reported behavior remains possible on current main, and the branch offers a focused repair with no definite introduced code defect found. Synthetic browser and Gateway evidence supports the fix, but native Safari or WKWebView IME behavior remains the merge blocker.

Priority: P1
Reviewed head: fd42ff071d49e798d51bb6deb9e2c5ee4f9e4b8c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and boundary regressions provide useful evidence, while native proof for the reported platform is still missing.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR reports after-fix results through the built Control UI and Gateway using synthetic Chromium IME events, but the reported Safari or WKWebView conversion-confirm sequence and subsequent deliberate Enter remain unobserved for the composer, rename input, and annotation editor. A redacted native recording or diagnostic transcript would address that gap; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR reports after-fix results through the built Control UI and Gateway using synthetic Chromium IME events, but the reported Safari or WKWebView conversion-confirm sequence and subsequent deliberate Enter remain unobserved for the composer, rename input, and annotation editor. A redacted native recording or diagnostic transcript would address that gap; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current main still has the reported composer guard: The composer keydown handler on fetched main checks the composing flag, isComposing, and keyCode 229 before reaching its send path; it has no post-composition guard.
Introduced production behavior: The branch records composition-end timestamps per input and suppresses nearby Enter keydowns; the composer, rename input, and annotation editor call the shared guard.
Browser regression coverage: The introduced Control UI browser case checks that synthetic composition confirmation retains the draft without chat.send, then checks deliberate sending and shortcut behavior.
Findings None None.
Security None None.

How this fits together

The Control UI receives keyboard and composition events in its chat inputs. Its handlers turn deliberate shortcuts into chat sends, annotation saves, or session renames.

flowchart LR
  A[Keyboard and IME events] --> B[Chat inputs]
  B --> C[Input-local composition guard]
  C --> D{Deliberate shortcut?}
  D -->|No| E[Keep editing]
  D -->|Yes| F[Send, save, or rename]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR reports after-fix results through the built Control UI and Gateway using synthetic Chromium IME events, but the reported Safari or WKWebView conversion-confirm sequence and subsequent deliberate Enter remain unobserved for the composer, rename input, and annotation editor. A redacted native recording or diagnostic transcript would address that gap; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The 100 ms guard has only been exercised with synthetic IME events; native Safari or WKWebView may order or space confirmation events differently, leaving premature submission or suppression of a deliberate Enter unresolved.
  • Complete next step (P2) - Provide redacted native Safari or WKWebView IME confirmation and deliberate-Enter evidence for all three inputs before merge.
Agent review details

Security

None.

PR surface

Source +53, Tests +209. Total +262 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 6 56 3 +53
Tests 6 340 131 +209
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 396 134 +262

Review metrics

Metric Value Why it matters
Production and test growth production +53 net lines; tests +209 net lines Production growth is concentrated in the shared guard and its three input integrations, with regression coverage for those behaviors.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #161259
Summary: The PR explicitly targets the open Safari IME composer report and extends the repair to two inputs described in that report.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify native IME behavior (recommended)
    Capture confirmation and the next deliberate Enter for the composer, rename input, and annotation editor in Safari or WKWebView, then adjust the guard if the event timing requires it.

Technical review

Best possible solution:

Keep one input-local guard for the three submit paths, then verify conversion confirmation and the following deliberate Enter in native Safari or WKWebView before merging.

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

No native Safari reproduction was independently inspected. Current-main source exposes the reported fall-through, and the PR reports a failing baseline run with synthetic browser events.

Is this the best way to solve the issue?

The shared, input-local guard is a narrow repair for the three affected handlers. Its 100 ms timing needs native IME confirmation before the solution can be judged sufficient for Safari.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 91bcd2d68adc.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Premature Enter handling can send unfinished chat messages for affected IME users.
  • merge-risk: 🚨 message-delivery: The new key guard controls whether an Enter sends a chat draft, and native Safari timing remains unverified.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR reports after-fix results through the built Control UI and Gateway using synthetic Chromium IME events, but the reported Safari or WKWebView conversion-confirm sequence and subsequent deliberate Enter remain unobserved for the composer, rename input, and annotation editor. A redacted native recording or diagnostic transcript would address that gap; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main still has the reported composer guard: The composer keydown handler on fetched main checks the composing flag, isComposing, and keyCode 229 before reaching its send path; it has no post-composition guard. (ui/src/pages/chat/components/chat-composer-keydown.ts:53, 91bcd2d68adc)
  • Introduced production behavior: The branch records composition-end timestamps per input and suppresses nearby Enter keydowns; the composer, rename input, and annotation editor call the shared guard. (ui/src/lib/ime.ts:15, fd42ff071d49)
  • Browser regression coverage: The introduced Control UI browser case checks that synthetic composition confirmation retains the draft without chat.send, then checks deliberate sending and shortcut behavior. (ui/src/e2e/chat-flow.composer-shortcuts.e2e.test.ts:17, fd42ff071d49)
  • Prior review and contributor proof: The PR body reports failing baseline regressions and after-fix built Chromium and Gateway results, while explicitly acknowledging that no native Safari or WKWebView IME run has been captured. The prior ClawSweeper review requested native proof for all three inputs; the latest comment says that request remains outstanding. (fd42ff071d49)
  • Latest commit scope: The latest head changes test placement and browser coverage; the production IME helper and handlers have no diff from the previously reviewed head. One older test blob could not be fetched for a direct comparison because the Git object request returned HTTP 403. (ui/src/e2e/chat-flow.composer-shortcuts.e2e.test.ts:17, fd42ff071d49)
  • Feature-area history: History identifies earlier text-composition protection work and recent chat-input refactors, providing routing candidates without establishing who introduced this particular defect. (ui/src/pages/chat/components/chat-composer-keydown.ts, 0faba887bfd9)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show conversion confirmation and the subsequent deliberate Enter in native Safari or WKWebView for all three inputs, with private details redacted.

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 (3 earlier review cycles)
  • reviewed 2026-09-29T17:36:42.927Z sha 1c7375a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T17:51:37.887Z sha 1c7375a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T04:11:31.374Z sha 6998f3e :: needs real behavior proof before merge. :: none

@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

The added test at 6998f3e9 caused two CI failures: a missing HTMLTextAreaElement callback annotation and oxfmt formatting. These were not unrelated/main failures. Both are repaired at fd42ff071d49e798d51bb6deb9e2c5ee4f9e4b8c.

The shortcut/IME case now lives in the existing chat-flow.composer-shortcuts.e2e.test.ts suite to respect the messaging file's max-lines limit, with the suite-owned browser-context cleanup. No product behavior changed. In secretless Docker, both affected files pass oxfmt and type-aware oxlint (0 warnings/errors); the exact core-test-ui-e2e and core-test-ui-app graphs pass; the relocated built-browser regression passes. No hosted reruns were requested. The previous failed run had zero cancelled jobs.

Native Safari/WKWebView IME evidence remains outstanding. The actual Gateway/UI/local scripted-model comparison servers remain running for manual verification; synthetic Chromium proof must not be treated as native IME proof.

@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Maintainer landing on exact head fd42ff071d49e798d51bb6deb9e2c5ee4f9e4b8c.

Gates. ci-gate passed on run 36669814580, with no failing and no cancelled jobs, and the security-sensitive review passed. The ClawSweeper review has no findings and no security findings. Its only open items ask for native Safari/WKWebView IME evidence.

Why we're landing without native IME evidence. We have no native IME automation available: no Japanese or Chinese input source, no Accessibility permission, and no iOS Simulator on the proof host. We accept these instead:

  • Event-order replay tests that reproduce WebKit's sequences: Enter keydown after compositionend with isComposing false, legacy keyCode 229, and iOS input-only beforeinput/insertText with no keydown, plus Shift+Enter and a deliberate send. They fail on main and pass here, and all 242 component tests pass.
  • A real built Gateway and Control UI smoke with a scripted model. On main, confirming 日本語 sent the draft. Here, the draft stays until a deliberate Enter, which then sends and gets a reply. Screenshots are in the PR body.
  • The WebKit and MDN analysis linked in the PR body. It covers WebKit bug 165004 and its April 2026 resolution.

The residual risk is bounded. If native WebKit spaces these events differently, the worst cases are:

  • the premature send still happens, which is today's behavior;
  • an Enter pressed within 100 ms of confirming a conversion is ignored, and the next Enter sends.

Neither loses a draft or data. The three inputs share one helper, so a follow-up tuning would be a one-place change.

@obviyus
obviyus merged commit f48a9d3 into openclaw:main Sep 30, 2026
96 of 97 checks passed
@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

A follow-up correction to the landing note above. This merged while the review was still blocked on native IME evidence. Our landing policy only overrides a blocked review for the data-model checkbox, so this override was outside policy.

Native Safari/WKWebView verification is still outstanding. Could another maintainer please check it with a real Japanese or Chinese IME, on macOS Safari and on iOS Safari or the WKWebView app? Please test the chat composer, the session rename box and the annotation box:

  1. Type nihongo and press Space to get 日本語.
  2. Press Return once to confirm the conversion. The draft should stay.
  3. Press Return again. That should send.
  4. Shift+Return should insert a newline.

If native WebKit behaves differently, the shared helper in this PR is the one place to change. The bounded worst cases are listed in the landing comment.

@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @NianJiuZst for the shared IME guard and regression coverage! Merged in f48a9d3. The synthetic event-order and real-Gateway proofs passed; native Safari/WKWebView IME behavior remains explicitly unobserved.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…penclaw#161302)

* fix(ui): prevent Safari IME confirmation from submitting chat inputs

* test(ui): cover input-only IME commits and legacy Safari keys

* test(ui): type IME replay and keep shortcut coverage in its suite

---------

Co-authored-by: NianJiuZst <[email protected]>
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI chat composer sends the draft on IME conversion-confirm in Safari

2 participants