Skip to content

feat: route press_key chords through the portal keyboard session#51

Merged
avifenesh merged 1 commit into
mainfrom
fix/press-key-portal-keyboard
Jul 17, 2026
Merged

feat: route press_key chords through the portal keyboard session#51
avifenesh merged 1 commit into
mainfrom
fix/press-key-portal-keyboard

Conversation

@avifenesh

Copy link
Copy Markdown
Collaborator

Closes #50 (thanks @maxburto for the detailed report).

What

press_key previously parsed the chord and unconditionally invoked ydotool, even when an XDG RemoteDesktop keyboard session was already active — the same session type_text already obtains and uses. On Plasma Wayland this meant installing ydotoold + /dev/uinput access solely for key combos.

How

  • New key_chord helper parses a chord (Ctrl+Shift+P) into evdev modifier codes + key code; key_sequence (the ydotool encoding) is now a thin wrapper over it, so both backends share one parser and the key grammar stays identical.
  • press_key sends the chord through the existing press_keycode_chord portal call when the new chord policy prefers the portal, with the result message identifying the backend ("Action sent through the remote desktop portal.").
  • Chord policy (should_prefer_portal_keyboard_for_chords): on any Wayland session — including Plasma, unlike the literal-text policy which routes KDE to the clipboard backend — the portal is used when a keyboard session is already cached (reusing the consent the user granted, even if ydotool is present), when ydotool is absent, or when COMPUTER_USE_LINUX_FORCE_PORTAL_KEYBOARD is set. COMPUTER_USE_LINUX_FORCE_YDOTOOL_KEYBOARD still pins ydotool.
  • Portal send failures clear the cached session and surface the error explicitly (no silent fallback after a failed portal send, matching type_text semantics). If no session can be established, ydotool remains the fallback.
  • Focus verification before input is unchanged, and focus/input-landing notes attach to the portal path too.

Acceptance mapping (from #50)

  • Plasma Wayland + keyboard-enabled session + no ydotool → press_key Ctrl+S goes through the portal. ✓ (policy prefers portal when ydotool socket is absent, and Plasma is no longer excluded for chords)
  • Consent absent / portal send fails → explicit error, cached session cleared. ✓
  • Focus verification preserved. ✓

Validation

  • cargo test --lib: 141 passed (adds key_chord_splits_modifiers_and_key).
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings: clean.
  • Not live-tested on Plasma hardware — @maxburto, if you can try this branch on your setup before it ships, that would be a great confirmation of the acceptance case.

On Wayland, press_key previously went straight to ydotool even when an
XDG RemoteDesktop keyboard session was already active (the path
type_text already uses). Plasma users therefore needed ydotoold and
/dev/uinput solely for key combos.

press_key now parses the chord into evdev codes (new key_chord helper,
shared with the ydotool key_sequence encoding) and sends it through the
portal via the existing press_keycode_chord when the chord policy
prefers the portal: any Wayland session where a keyboard session is
already cached (reusing granted consent even if ydotool is present),
where ydotool is absent, or where the portal is forced via
COMPUTER_USE_LINUX_FORCE_PORTAL_KEYBOARD. ydotool remains the fallback
and COMPUTER_USE_LINUX_FORCE_YDOTOOL_KEYBOARD still pins it. Portal
send failures clear the cached session and report the error explicitly.

Closes #50.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for sending key chords through an active remote desktop portal keyboard session on Wayland, falling back to ydotool when unavailable. It refactors key parsing by introducing a key_chord helper to split modifiers and keycodes, updates key_sequence to leverage this helper, and adds corresponding unit tests. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@avifenesh
avifenesh merged commit 652b579 into main Jul 17, 2026
20 checks passed
@avifenesh
avifenesh deleted the fix/press-key-portal-keyboard branch July 17, 2026 00:14
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.

press_key should use the active portal RemoteDesktop keyboard session

1 participant