Skip to content

ui-kit: Composer shortcuts send or stop during IME composition #1810

Open

Description

@schlessera

Out of scope

Reconnect DOM continuity (#1013), shortcut redesign or changes to the data/state architecture.

Context

Package audit on 2026-10-14 found the following concrete root cause. The audit searched all-state brain-kit issue titles/bodies and read the closest candidate comments. Current open issues were rechecked before filing. Audit reproductions are observations, not passing full-suite or mutation receipts.

Composer executes application shortcuts during IME composition

Classification: correctness. Severity: medium (unintended message submission / cancellation). Confidence: high for source dispatch and the reproduced Chromium native-composition path; OS candidate UI and other-engine ordering remain unmeasured.

Evidence

  • (onKeyDown, packages/ui-kit/src/chrome/Composer.tsx:207-220) checks streaming Escape and ordinary Enter, prevents the native default, then calls onStop or onSend. It never checks event.nativeEvent.isComposing, composition lifecycle state, or a composing key-code fallback.
  • (onKeyDown={onKeyDown}, packages/ui-kit/src/chrome/Composer.tsx:318) attaches that handler directly to the textarea.
  • Contrast demonstrating an existing intentional composition guard within the same package: (keys, packages/ui-kit/src/chrome/Overlay.tsx:141-153) suppresses composing Escape; (registerOverlay, packages/ui-kit/src/internal/overlay-stack.ts:9-18) also rejects composing Escape.
  • Consumer trace checked only to establish impact, without expanding the audit ownership: (onSend, packages/ui-react/src/components/chat/composer.tsx:855-861) can run a slash command or handleSubmit and has no event/composition argument; (onKeyDown, packages/ui-react/src/components/chat/composer-view.tsx:113-123) is a bubbling wrapper handler that handles palette movement/recall, not a capture-phase composition guard. It cannot undo the kit callback already dispatched.

Concrete failing scenario and impact

Mount Composer with a nonempty editable draft and an onSend callback. While an input-method candidate is active, an Enter keydown with isComposing=true reaches the textarea to accept the candidate. The kit calls preventDefault() and onSend anyway. In the application this can submit the partial draft or execute a matching slash command. During a running turn, composing Escape intended to cancel an IME candidate instead calls onStop, cancelling the agent's work.

This follows directly from the event branches; it does not rely on layout or speculative caller behavior. The Chromium native-browser path is reproduced below. Any fallback for engines that end composition just before Enter needs its own measured ordering before inclusion in the complete fix.

Acceptance and verification sketch

  • A native IME candidate confirmation/cancellation does not invoke Send/Stop or execute a slash command, and does not suppress the input method's own default solely because of the application shortcut.
  • Ordinary Enter still sends once; Shift+Enter inserts a newline; ordinary streaming Escape still stops once.
  • Add callback-level regression controls with composing keyboard events, then real Chromium native IME/CDP input coverage for the actual Composer consumer; include any supported engine fallback justified by measured event ordering.
  • Show a failing-first callback/browser assertion and a guard-removal mutation that restores unintended submission/cancellation. Do not use a JSX text predicate as runtime proof.

Tracker coverage check

Searched all 989 snapshot issues, all states, titles and bodies, using IME, isComposing, compositionend, compositionstart, Japanese, Chinese, Korean, input method, and broader composition/Composer terms. Closest candidates:

No existing specific issue covering this root cause was found. This is suitable for an ordinary public issue; no security-advisory routing indicated.

Scope

Distinguish input-method candidate keys from application Send/Stop shortcuts in the actual Composer consumer.

Acceptance criteria

  • Composing Enter/Escape does not invoke Send/Stop or suppress the input method default for the app shortcut.
  • Ordinary Enter sends once, Shift+Enter inserts a newline and ordinary streaming Escape stops once.
  • Native/browser event ordering is measured, including any supported composing-key fallback; slash-command submission is covered.
  • A named behavioral test fails on the current code for the reported reason and passes after the correction; a restored semantic mutation demonstrates that the guard is effective. For pure unused-code cleanup, production-path proof and the caller/export inventory replace a fabricated behavior mutation.
  • Implementation updates relevant documentation/citations and supplies the required focused and hosted proof.

Verification

Use deterministic, keyless, offline fixtures and the real operation/runtime at the implicated boundary. Preserve the repository network guards. Source-only or operation-mirroring audit probes do not replace real browser/native-runtime proof where the behavior depends on it.

bun run test packages/ui-kit
bun run typecheck
bun run lint
bun run check:pr --base origin/main

For UI/render changes, run the relevant pinned browser/layout/accessibility project and inspect rendered output; retain named failing-first and restored mutation receipts. Existing audit module-load failures establish no behavioral failure or green suite. Any missing original-failure reproduction or policy choice is identified by the needs label and must be resolved before marking agent-ready.

Contract impact

Published behavior correction needs a changeset. Preserve existing CLI/MCP/wire/configuration and public signatures. Reassess the integration contract against the final implementation; any contract change needs the relevant documentation, label and CONTRACT: commit prefix, and a breaking change needs a maintainer ruling.

Unscheduled standalone repair. Severity in the audit describes impact, not a release commitment or assigned priority. Related issues are references unless their full epic outcome explicitly owns this repair.

Reproduction evidence — 2026-10-14

The initial synthetic-event receipt at main 4af7b2f20a43d23260c2ee5e3bac3896aee971bd observed sends=1, stops=1 and defaultPrevented=true. A later isolated native-browser follow-up at main 5cf1d548f7bd3a314eb36394dc5db0268db97da6 resolves the original-failure prerequisite: the existing keyless real-host continuity fixture mounts the actual AppShell/ChatPage/Composer consumer in Chromium 152.0.7977.82, Playwright 1.63.0 and lockfile-pinned React 19.3.0. CDP Input.imeSetComposition starts Chromium composition; Playwright keyboard input emits trusted composing keys rather than page-created KeyboardEvents.

With an enabled, nonempty Odysseus draft in a new conversation, trusted Enter (isTrusted=true, isComposing=true, keyCode=13) during that composition sends one real chat_message frame and clears the draft. The named assertion composing Enter must not send a chat_message fails with expected 0, received 1. During a scripted running turn, trusted composing Escape (keyCode=27) sends one cancel frame. Composing Enter on /search opens a dialog (0 before, 1 after) and clears the command draft. Ordinary controls show one chat_message for Enter, no chat_message and a newline for Shift+Enter, and one cancel for ordinary streaming Escape.

A pending-attachment scene was an initial negative control: its send-disabled Composer dispatched no message. The enabled-draft case above removes that condition and fails for the reported reason. The probe preserves the test network preload and the browser origin allowlist, uses only loopback/keyless fictional fixtures, and changes no implementation. Initial disk-quota/truncated-file and probe-recorder failures were tooling errors, not defect receipts; the final runtime assertion is independent of them.

Chromium CDP proves a native browser composition path with trusted composing keys. It does not measure an OS input-method candidate window, Safari/Firefox ordering, or a fallback for engines that end composition before Enter. The implementation must justify any fallback it adds and retain native/browser coverage; these platform limits do not negate the reproduced composing-key defect. Native default-prevention was not reliably measured by this follow-up's target listener; retain the earlier synthetic-event receipt without interpreting the follow-up logger's potentially pre-delegation value.

Updated 2026-10-14: folded native Chromium full-consumer Send/Stop/slash-command observations and ordinary-key controls into the brief. Original-failure reproduction is sufficient; no unresolved product/design/access prerequisite was found. No correction, complete suite, or mutation-after-fix result is claimed.

Activity

  1. added
    type: fix
    area: ui-kit
    needs: repro
    priority: p2
    area: ui-react
    on Oct 14, 2026
  2. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    2026-10-14 triage at main 4af7b2f20a43d23260c2ee5e3bac3896aee971bd: verified the named source anchors and scope. Priority p2 means wanted but unscheduled; the audit severity does not create a release commitment. The body now states the remaining repro prerequisite and the evidence/ruling that resolves it. Agent readiness remains absent.

  3. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    2026-10-14 browser follow-up: after correcting the isolated fixture listener, T3 preview mounted the unmodified kit Composer at main 4af7b2f20a43d23260c2ee5e3bac3896aee971bd with pinned React/ReactDOM 19.3.0 and lucide-react 0.460.0. A compositionstart followed by composing Enter/Escape yielded sends=1, stops=1 and defaultPrevented=true for both. This is real browser/React callback evidence from synthetic events; it is not a native IME candidate-ordering or full app-consumer receipt. Folded the result and its limits into the body, corrected the Overlay keys anchor, and retained needs: repro for native ordering. No implementation changed.

  4. added
    agent-ready
    and removed
    needs: repro
    on Oct 14, 2026
  5. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    2026-10-14 reproduction follow-up at main 5cf1d548f7bd3a314eb36394dc5db0268db97da6: reproduced in the actual consumer, using the existing offline/keyless real-host AppShell/ChatPage continuity fixture, Chromium 152.0.7977.82, Playwright 1.63.0 and React 19.3.0. This differs from the prior page-created KeyboardEvent probe: Input.imeSetComposition creates browser composition and Playwright keyboard input produces trusted composing Enter/Escape.

    Observed:

    • Enabled Odysseus draft + composing Enter: isTrusted=true, isComposing=true, keyCode=13, one outgoing chat_message, draft cleared. Named assertion composing Enter must not send a chat_message fails: expected 0, received 1.
    • Scripted streaming turn + composing Escape: trusted/composing keyCode=27, one outgoing cancel.
    • /search + composing Enter: dialog count 0 → 1, draft cleared.
    • Ordinary controls: Enter sends once; Shift+Enter sends nothing and inserts a newline; streaming Escape cancels once. A send-disabled pending-attachment scene dispatches no message.

    Command in the isolated inspected worktree (temporary probe inserted into the selected existing case; already-built isolated outputs reused on follow-ups):

    TMPDIR=/dev/shm BRAIN_REQUIRE_CHROME=1 bun run test packages/ui-react/tests/connection-continuity-runtime.test.ts --test-name-pattern '320 phone, dark: an IME'

    Final receipt: 0 pass, 1 fail, 14 filtered, 11 assertions, exit 1; failure is the message-count assertion above, not module loading. Network guards and browser origin restrictions remained active. No implementation changed.

    The initial disk-quota/truncated-file and intermediate probe setup errors prove no defect; the final bounded runtime run independently reaches the expected behavioral assertion. The target-level default-prevention logger may observe the event before React delegation; it is not treated as a reliable final-default receipt. OS candidate UI and non-Chromium fallback ordering remain unmeasured, explicitly stated in the body; the native Chromium path nevertheless supplies the missing original-failure proof. Folded these corrections into the body, removed needs: repro and added agent-ready; no other prerequisites, assignment, milestone or epic changes.

  6. schlessera commented on Oct 23, 2026

    @schlessera
    OwnerAuthor

    2026-10-24 restructuring: attached to #2576. Its outcome includes "Enter never submits half-composed IME text", #2579 explicitly assigns Composer IME handling to this issue, and the two together now cover the whole outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-kitarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions