Skip to content

[codex] Fix Wework IME Enter submission - #1727

Merged
qdaxb merged 2 commits into
mainfrom
codex/fix-wework-ime-enter-send
Jul 5, 2026
Merged

qdaxb merged 2 commits into
mainfrom
codex/fix-wework-ime-enter-send

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix Wework chat composer Enter handling around IME composition.
  • Submit the latest textarea DOM value so fast Enter presses do not race controlled React state.
  • Add gated composer submit-flow debug logs behind localStorage['wework:debug-composer'] === '1'.
  • Add regression tests for IME confirmation and controlled-value timing.

Root Cause

The composer used a time-based compositionJustEnded guard. Depending on IME event ordering, the Enter key used to confirm composition could either be swallowed as a newline or treated as a send shortcut. The fix tracks the physical key boundary instead: composition completion suppresses Enter until keyup, and subsequent independent Enter presses can submit normally.

Validation

  • pnpm --filter wework exec vitest run src/components/chat/ChatInput.test.tsx
  • pnpm --filter wework typecheck
  • Pre-push hook: ESLint, TypeScript, and unit tests passed

Docs were checked; this is a behavior bug fix and does not require user-facing documentation updates.

Summary by CodeRabbit

  • New Features

    • Chat composer and send flows now submit the text that was actually entered, including when submission is triggered from keyboard input.
    • Enter/composition handling was improved to better respect IME input and prevent accidental submissions.
    • Additional debug logging is available for composer and pane send actions when enabled.
  • Bug Fixes

    • Fixed cases where the latest typed message could be missed if the input state updated after Enter was pressed.
    • Improved submission behavior so empty messages are not sent.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5664260b-35fb-4e13-8049-a8873b73e24e

📥 Commits

Reviewing files that changed from the base of the PR and between 783cac7 and d920227.

📒 Files selected for processing (7)
  • wework/src/components/chat/ChatInput.test.tsx
  • wework/src/components/chat/composer/CompactChatComposer.tsx
  • wework/src/components/chat/composer/ComposerTextarea.tsx
  • wework/src/components/chat/composer/ProjectChatComposer.tsx
  • wework/src/components/chat/composer/composerDebug.ts
  • wework/src/components/layout/BufferedChatInput.tsx
  • wework/src/components/layout/useWorkbenchPaneSession.ts

📝 Walkthrough

Walkthrough

Composer onSubmit callbacks now accept an optional submitted text value instead of taking no arguments. Form submit handlers read the textarea's current value and pass it through, alongside new debug telemetry via a new composerDebug helper. ComposerTextarea's Enter-key handling during IME composition is reworked with a suppress-until-keyup flag, replacing prior timer-based logic. Tests are updated accordingly.

Changes

Composer submit value and IME handling

Layer / File(s) Summary
Debug telemetry helper
wework/src/components/chat/composer/composerDebug.ts
New module exports debugComposerEvent (conditional console logging gated by localStorage flag) and textMetrics (length/trimmedLength/lineCount stats).
ComposerTextarea Enter/IME suppression
wework/src/components/chat/composer/ComposerTextarea.tsx
onSubmit prop now takes an optional submitted value; a suppressEnterUntilKeyUpRef flag suppresses Enter after composition ends until the next keyup; composition, keydown, change, and new keyup handlers emit debug events and call onSubmit(submittedValue).
Composer onSubmit wiring and pane telemetry
wework/src/components/chat/composer/CompactChatComposer.tsx, wework/src/components/chat/composer/ProjectChatComposer.tsx, wework/src/components/layout/BufferedChatInput.tsx, wework/src/components/layout/useWorkbenchPaneSession.ts
Form submit handlers read textarea value, emit debugComposerEvent with text metrics/counts, and pass the submitted value through onSubmit; BufferedChatInput.handleSubmit accepts an optional value override; pane send flow logs telemetry.
Enter/IME submission tests
wework/src/components/chat/ChatInput.test.tsx
Removes unused act import; adds tests verifying submission uses the latest textarea value and that Enter keydown after composition end but before keyup is suppressed, replacing prior fake-timer-based IME test.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

  • wecode-ai/Wegent#1334: Prior work reworking Enter/IME composition submission handling in ComposerTextarea and its tests, directly related to the suppression logic changed here.

Suggested reviewers: feifei325

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-wework-ime-enter-send

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…enter-send

# Conflicts:
#	wework/src/components/chat/ChatInput.tsx
#	wework/src/components/layout/useWorkbenchPaneSession.ts
@qdaxb
qdaxb marked this pull request as ready for review July 5, 2026 16:39
@qdaxb
qdaxb merged commit 24c2fbb into main Jul 5, 2026
18 of 20 checks passed
@qdaxb
qdaxb deleted the codex/fix-wework-ime-enter-send branch July 5, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant