Set viewId on the text input configuration (fixes dead keyboard input on Windows) - #231
Open
LarryHsiao wants to merge 1 commit into
Open
Set viewId on the text input configuration (fixes dead keyboard input on Windows)#231LarryHsiao wants to merge 1 commit into
LarryHsiao wants to merge 1 commit into
Conversation
CustomTextEdit built its TextInputConfiguration without a viewId, which Flutter's Windows embedder rejects outright: TextInput.setClient fails with "Could not set client, view ID is null", followed by "Set editing state has been invoked, but no client is set". The connection is never attached. That is fatal to input rather than merely noisy. CustomTextEdit has no hardware-key fallback for printable characters the way CustomKeyboardListener does, so with the connection dead, letters and digits have no route to the terminal at all. Keys that map to a TerminalKey (Enter, arrows, Ctrl-combos) still work through the Focus onKeyEvent path, which makes the failure look selective and puzzling: Enter responds, typing does not. macOS tolerates the omission via its implicit view, so this only ever surfaced on Windows. Fixed by passing View.of(context).viewId, matching how Flutter's own EditableText populates the field. Covered by a regression test asserting the viewId reaches TextInput.setClient. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Set
viewIdonCustomTextEdit'sTextInputConfiguration, without which text input is dead on Windows.Flutter's Windows embedder rejects
TextInput.setClientwhen the configuration carries noviewId:The connection never attaches. That is fatal rather than merely noisy, because
CustomTextEdithas no hardware-key fallback for printable characters the wayCustomKeyboardListenerdoes — so with the connection dead, letters and digits have no route to the terminal at all. Keys that map to aTerminalKey(Enter, arrows, Ctrl-combos) still work via theFocusonKeyEventpath, which makes the failure look puzzlingly selective: Enter responds, typing does not.macOS tolerates the omission through its implicit view, so this only surfaces on Windows.
lib/src/ui/custom_text_edit.dart— passView.of(context).viewId, matching how Flutter's ownEditableTextpopulates the field.test/src/terminal_view_test.dart— regression test asserting theviewIdreachesTextInput.setClient. It fails onmaster(Expected: <0>, Actual: <null>) and passes with the fix, on any platform.Verified end-to-end on Windows 11 with Flutter 3.38.7 in a real app embedding
TerminalViewover a ConPTY-backed shell: before, every printable keystroke was dropped; after, all input works and the exceptions are gone.One note for whoever runs this locally:
master'sdev_dependenciespindart_code_metrics: ^5.0.0, which cannot co-resolve with thetest_apithat currentflutter_testrequires, soflutter pub getfails on recent SDKs. I verified the suite on a branch with that dev-dependency dropped (112 passing; the only failures are the pre-existingtextScalergoldens, which are macOS-rendered and fail on Windows at any commit). That resolution problem is untouched by this PR.