Repository navigation
Autocomplete on KDE Plasma: show suggestions in an overlay pill instead of preedit - #563
Merged
stevyhacker merged 1 commit intoNov 21, 2026
Conversation
…ad of preedit Putting an unaccepted suggestion into `zwp_input_method_context_v1.preedit_string` made `zwp_text_input_v3` clients such as Chromium, Electron, Firefox, and Thunderbird commit the suggestion into the document whenever the field lost focus on click or blur, because KWin bridges `preedit_string` without its reset-commit string and those toolkits finalize active IME compositions locally before notifying the compositor. - Draw KDE Plasma suggestions on a click-through `zwp_input_panel_v1` (`set_overlay_panel`) surface (`overlay_pill.rs`) anchored by KWin to the focused field's `cursor_rectangle`, rendered via `cosmic-text` into an anonymous `memfd` buffer with `wp_fractional_scale_v1` + `wp_viewporter` HiDPI scaling and light/dark theme tokens. - Bump `kwin_wire::VERSION` to 2, replacing `Request::Preedit` with `Request::Ghost` and an empty-preedit `Request::Nudge` for quiet fields, and keep suggestions out of `Core`'s `preedit` expectation via `Core::with_overlay_ghost()`. - Update `live_input_method` to assert zero non-empty preedit on the KWin route and add a focus-loss regression check (`commit_on_blur`), plus update `LinuxWindows/README.md`. Co-authored-by: Cursor <cursoragent@cursor.com>
SamLeatherdale
marked this pull request as ready for review
November 21, 2026 03:40
Owner
|
Thanks for the PR, will review now! |
stevyhacker
added a commit
that referenced
this pull request
Nov 21, 2026
Land #563: KDE autocomplete overlay pill, onto the comment-free master
stevyhacker
pushed a commit
that referenced
this pull request
Nov 21, 2026
Sway and Hyprland forward input method preedit to apps over zwp_text_input_v3 as KWin does, so Chromium, Electron, Firefox and Thunderbird commit an unaccepted suggestion into the field on blur (#562). The wlroots route now draws the overlay pill from #563 on a zwp_input_popup_surface_v2. Sway before 1.10 accepts the popup but never shows it, so the route keeps preedit there: the popup counts only once the compositor sends text_input_rectangle, and without one within 300 ms of the first suggestion the route falls back to preedit for the session. Also from the #563 review: - The KWin helper takes no keys when KWin offers no input panel, so a suggestion it cannot draw never eats Tab. - The pill loads the system font database on its own thread when the route starts, not on the first suggestion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QD3UkuaVf6PEtW1ptFCMB1
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.
Summary
On KDE Plasma (Wayland),
lokalbot --kwin-input-methodnow draws autocomplete suggestions on a click-throughzwp_input_panel_v1overlay pill instead ofzwp_input_method_context_v1.preedit_string. KWin bridgespreedit_stringto clients overzwp_text_input_v3without a reset-commit string, and Chromium, Electron, Firefox, and Thunderbird commit activezwp_text_input_v3preedit into the document onmousedownorblurbefore notifying KWin. Keeping unaccepted suggestions out ofpreeditprevents focus loss from inserting unaccepted text.Screencast_20261121_145247-00.00.07.147-00.00.22.033.mp4
Review guide
Reading order:
LinuxWindows/crates/lokalbot-platform/src/autocomplete/input_method/kwin_wire.rs— bumpsVERSIONfrom1to2and replacesRequest::PreeditwithRequest::GhostandRequest::Nudge.LinuxWindows/crates/lokalbot-platform/src/autocomplete/input_method/overlay_pill.rs— bindszwp_input_panel_v1(set_overlay_panel), rasterizes the pill withcosmic-textinto an anonymousmemfdwl_shmbuffer, and scales viawp_fractional_scale_v1+wp_viewporter.LinuxWindows/crates/lokalbot-platform/src/autocomplete/input_method/kwin_helper.rsandkwin.rs— drivesOverlayPillfrom the helper and hides it onActivate,Deactivate,Reset,drop_app, and passed-through keys.LinuxWindows/crates/lokalbot-platform/src/autocomplete/input_method.rs,autocomplete/mod.rs, andlokalbot-app/src/autocomplete/mod.rs— addsCore::with_overlay_ghost()andGhostStyle(next-Tabemphasis length and dark/light palette) without disturbing routes that still usepreedit.Decisions and focus areas:
zwp_input_panel_v1inkwin_helperinstead of clearingpreeditonDeactivateor opening a GPUI popup: Blink (InputMethodAuraLinux::ConfirmCompositionText) and Gecko (IMContextWrapper) commit activepreeditinside the client before sendingzwp_text_input_v3.disable()to KWin, so anyDeactivatecleanup arrives too late. Ordinary Wayland clients cannot read caret screen coordinates or bindzwp_input_panel_v1; KWin grants that interface only on theWAYLAND_SOCKETpassed to--kwin-input-methodand anchorsset_overlay_panelsurfaces to the focused text input'scursorRectangle.overlay_pill.rs:create_shm_filebackswl_shm_poolwithlibc::memfd_create(MFD_CLOEXEC), preservingPRIVACY.md's guarantee that--kwin-input-methodwrites no file on disk other than its runtime socket.cosmic-text0.19.0was already pinned inCargo.lockvia GPUI, so no new third-party crate or license entry is added.Request::Nudge: WhenCore::with_overlay_ghost()probes a silentzwp_text_input_v3field (such as Chromium focused mid-text),kwin_helpersendspreedit_string(serial, "", "")rather than suggestion text so KWin refreshessurrounding_textwithout starting a non-empty IME composition.Validation
Automated checks (from
LinuxWindows/and repo root on Kubuntu 26.04.1, KDE Plasma 6.6.6 / KWin 6.6.7):cargo fmt --all -- --check cargo clippy --workspace --all-targets --locked -- -D warnings TZ=UTC LC_ALL=C.UTF-8 cargo test --workspace --locked bash crates/lokalbot-platform/scripts/live-kwin.sh python3 -m unittest discover -s scripts/tests bash scripts/third-party-licenses.sh --check python3 ../Scripts/ci/check-sync-crate-notices.pyAll commands exited
0, includinglive_input_method::kwin_input_method_shows_accepts_and_stays_out_of_passwordsunder headlesskwin_waylandand the newoverlay_pillunit tests across dark/light themes and1.0x/1.5x/2.0xscales. Verified thatcommit_on_blurinlive_input_methodfails whenpreedit_stringis restored and passes with the overlay pill.Headless
kwin_waylandclient matrix (LOKALBOT_FAKE_AUTOCOMPLETE=" world", typinghelloand blurring via second input click, blank-area click, and window switch):Wayland):Tab→'hello world'; all three blur cases →'hello'(was'hello world').Wayland):Tab→'hello world'; all three blur cases →'hello'(intra-window clicks were'hello world').QLineEdit,QTextEdit):Tab→'hello world'; blur →'hello'.Manual desktop checks on a live KDE Plasma Wayland session (with on-device
LFM2.5-1.2B-Instruct):Tab) and full (`) acceptance,Escdismissal inside modals150%and200%displayszenity,gnome-text-editor), GTK 3 (mousepad), and LibreOffice WriterNot run: macOS Xcode targets and Windows desktop builds (CI covers these).
Changed test expectations
live_input_method::kwin_input_method_shows_accepts_and_stays_out_of_passwords: expectedpreedit ' up on it'andpreedit ' on it'on the GTKEntrywhile suggestions were visible → now asserts that no non-emptypreeditever reaches the field (assert_no_nonempty_preedit/expect_without_preedit) whileTab, replacement accepts, key passthrough,Esc, password refusal, and helper disconnect keep their expectedtextresults.Why the old expectation was wrong: putting unaccepted suggestions into
preeditassumed Wayland clients discardpreediton focus loss, whereaszwp_text_input_v3clients (Blink and Gecko) commit activepreeditinto the document onmousedown/blur.Linked issues
Fixes #562
Risk / rollout notes
kwin_wire::VERSION1→2): KWin startslokalbot --kwin-input-methodonce per desktop session. Updating the installed binary while av1helper is still running causeskwin.rs/kwin_helper.rsto log a version mismatch and disconnect cleanly rather than misparsing frames; autocomplete resumes once the user re-applies Virtual Keyboard in System Settings or logs in again.kwin/zwp_input_method_v1+zwp_input_panel_v1) toCore::with_overlay_ghost(). Sway/Hyprland (wlroots.rs, which needszwp_input_popup_surface_v2rather thanzwp_input_panel_v1) and GNOME (ibus.rs) still useCore::new(preedit).qt6/kf6VCL) caret-position bug: ConsecutiveTabchunk accepts in LibreOffice Writer keep the pill at the starting caret position until the next physical keypress (Kate and other Qt 6 apps update normally).commit_string, and confirmed this cannot be worked around safely from the input method:QWaylandTextInputv3::zwp_text_input_v3_donealready queriesQt::ImCursorRectangleright aftercommit_string, while LibreOffice'sQtWidget::commitTextdefers visual cursor layout (SalEvent::ExtTextInputPos) to idle without callingQInputMethod::update(Qt::ImCursorRectangle)afterward. A follow-up emptypreedit_string("")is ignored byQWaylandTextInputv3(m_pendingPreeditString == m_currentPreeditString), and sending non-emptypreeditwould reintroduce active IME composition in other clients.