Skip to content

Studio: keep the chat composer typing after a send on WebKitGTK Wayland - #13222

Merged
danielhanchen merged 3 commits into
mainfrom
studio-fix-10012-webkitgtk-ime-commit
Oct 10, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-fix-10012-webkitgtk-ime-commit

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Fixes #10012

Problem

On Unsloth Desktop under a Wayland session (WebKitGTK), the chat composer stops taking typed characters after the second send in a conversation. Paste still works and brings typing back, and so does switching conversations. GTK_IM_MODULE=gtk-im-context-simple or GDK_BACKEND=x11 avoid it.

The cause is the sent-text guard added in #8849. After a send it refuses an IME composition write that lands on an empty composer until a keydown or a compositionstart shows the user is typing again, so that a composition still open at the send cannot finalise and put the sent prompt back.

WebKitGTK breaks the assumption behind that rule. When the GTK input method commits text outside its key filter (the Wayland text-input path), WebKit delivers each keystroke as a confirmed composition:

  1. a synthesized keydown with key: "Unidentified", keyCode: 229 (NativeWebKeyboardEventGtk.cpp, handledByInputMethod = true)
  2. Editor::confirmComposition(text) via WebEditorClient::didDispatchInputMethodKeydown, which fires input with inputType: "insertFromComposition" and isComposing: true, then compositionend

There is never a compositionstart, and the 229 keydown takes the IME branch of onKeyDown, which returns before it records user input. So every typed character is refused as a stale composition. A paste is a deliberate write and retires the guard, which is why paste restores typing.

The first send in a new chat is unaffected because the chat has no thread id yet when the guard is armed, so the guard does not own the thread afterwards. From the second send on it does, which matches the report.

Fix

The guard now records whether an IME composition was actually open when the message was sent (imeSessionOpenRef, set by compositionstart and cleared by compositionend / blur). A composition write is only treated as a stale finalise when one was open. With none open, it can only be the user typing, so it is applied and the guard retires. That includes retyping a one-character prompt such as ?, which the equality rule would otherwise swallow on every press.

Unchanged:

  • A plain (non-composition) write carrying the sent text is still refused.
  • An autocorrect commit (insertReplacementText) on an empty composer is still refused.
  • A composition that was open at the send (for example after the stuck-IME watchdog let a send through) is still refused until the user types again.
  • Draft restore suppression is untouched.

No UI or flow changes.

Verification

I used a local vite harness rendering the real Thread composer with a local runtime that replies straight away, and drove it in Playwright. Each keystroke replays the WebKitGTK sequence above, and the runtime's composer.text is read back after each step.

step before (Chromium / WebKit) after (Chromium / WebKit)
new chat, IM typing before any send abc abc
after 1st generation, IM typing hello hello hello
after 2nd generation, IM typing hello empty (keys dropped) hello
paste P, then IM typing xy P, Pxy (paste restores, as reported) helloP, helloPxy
after a 3rd generation, ordinary key events plain plain
send y, then IM typing yy empty yy
sent text written back after a send (#8849) refused refused
composition open at the send finalising afterwards (#8849) refused refused

Before and after match on Chromium and Playwright WebKit.

  • tests/composer-send-guard.test.ts gains 4 tests. 3 of them fail on main (a composition write with none open at the send is applied, retyping a one-character prompt applies with no composition open at the send, the composer arms the guard with whether an IME session was open).
  • The full frontend suite passes: 11229/11229 with the change, 11225/11225 on main.
  • tsc is clean. eslint and biome report the same counts as main on the touched files.

Not verified: a real Fedora Wayland session with WebKitGTK and an IBus input method. The event sequence comes from WebKit's source and was replayed in the browser rather than produced by a real input method.

@danielhanchen danielhanchen self-assigned this Oct 10, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T11:09:37.795683Z 18f38f1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 18f38f19c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

[Bug] Chat Composer stops accepting keyboard input after second generation (Wayland + WebKitGTK)

1 participant