Add Linux permission flow handling and utility functions#2
Open
matedev01 wants to merge 1 commit into
Open
Conversation
- Implemented `linuxPermissionFlow` to manage permission requirements for Linux desktop usage. - Added helper functions: `readStringField`, `readObjectField`, `readArrayField`, and `collectSessionNotes` for structured data extraction. - Enhanced `permissionFlowForResult` to route Linux platform results to the new flow. - Updated permission summary and installation commands based on session type (X11 or Wayland).
Member
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
Pull request overview
Adds Linux desktop-use support alongside the existing macOS Peekaboo path, including session-specific helper tooling and plugin permission/setup guidance.
Changes:
- Routes Linux executions through new X11/Wayland backends with screenshot, input, scroll, focus, and doctor flows.
- Adds Linux setup guidance in the plugin response and README onboarding docs.
- Extends tests for Linux parsing, key mapping, redaction, and doctor envelopes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/plugin-tool.ts |
Adds Linux-specific permission/setup flow handling. |
src/main.rs |
Implements Linux platform/session detection, backend dispatch, tool inventory, actions, JSON envelopes, and tests. |
README.md |
Documents Linux X11/Wayland setup, limitations, and onboarding steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+410
to
+414
| installCommand: | ||
| readStringField(setupGuide, "installCommand") ?? | ||
| (session === "wayland" | ||
| ? "sudo apt install grim wtype ydotool" | ||
| : "sudo apt install scrot xdotool wmctrl"), |
| let has = |name: &str| tools.iter().any(|t| t.name == name && t.found); | ||
| match session { | ||
| LinuxSession::X11 => (has("scrot") || has("maim")) && has("xdotool"), | ||
| LinuxSession::Wayland => has("grim") && (has("wtype") || has("ydotool")), |
Comment on lines
+559
to
+563
| let missing: Vec<String> = tools | ||
| .iter() | ||
| .filter(|t| !t.found) | ||
| .map(|t| t.name.to_string()) | ||
| .collect(); |
Comment on lines
+1012
to
+1017
| if resolve_path_binary("wtype").is_none() { | ||
| return missing_tool_json( | ||
| "wtype", | ||
| "Install wtype (wlroots) or wlrctl for real scroll. Without one, scroll on Wayland is unsupported.", | ||
| "wayland-scroll", | ||
| ); |
Comment on lines
+1047
to
+1049
| let app = value(args, "--app"); | ||
| let title = value(args, "--window-title"); | ||
| let target = title.or(app); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/main.rs:1148
- The default branch returns the lowercased match value rather than the user-provided key name, which can corrupt case-sensitive XKB key names (for example function/media key symbols) before passing them to
wtype -k. Keep the original trimmed key for passthrough and use a lowercased copy only for known aliases.
other => other.to_string(),
Comment on lines
+410
to
+414
| installCommand: | ||
| readStringField(setupGuide, "installCommand") ?? | ||
| (session === "wayland" | ||
| ? "sudo apt install grim wtype ydotool" | ||
| : "sudo apt install scrot xdotool wmctrl"), |
Comment on lines
+1126
to
+1128
| // Allow XKeysym names through unchanged (e.g. "ctrl+c", "F5", "shift+Tab"). | ||
| other => other.to_string(), | ||
| } |
Comment on lines
+110
to
+113
| // No display variables set (headless / SSH session). Default to | ||
| // X11 because xdotool/scrot also fail loudly and `doctor` will | ||
| // make the missing display obvious to the operator. | ||
| Platform::LinuxX11 |
Comment on lines
+1049
to
+1074
| let target = title.or(app); | ||
| let target = match target { | ||
| Some(t) => t, | ||
| None => { | ||
| return linux_error_json( | ||
| "focus requires --app or --window-title on Linux.", | ||
| None, | ||
| ); | ||
| } | ||
| }; | ||
| match session { | ||
| LinuxSession::X11 => x11_focus(&target), | ||
| LinuxSession::Wayland => wayland_focus(&target), | ||
| } | ||
| } | ||
|
|
||
| fn x11_focus(target: &str) -> String { | ||
| if resolve_path_binary("wmctrl").is_some() { | ||
| let cmd_args: Vec<OsString> = vec!["-a".into(), target.into()]; | ||
| return run_linux_command("wmctrl", cmd_args, "wmctrl", false, &[]); | ||
| } | ||
| if resolve_path_binary("xdotool").is_some() { | ||
| let cmd_args: Vec<OsString> = vec![ | ||
| "search".into(), | ||
| "--name".into(), | ||
| target.into(), |
Comment on lines
+1086
to
+1090
| fn wayland_focus(target: &str) -> String { | ||
| if env::var_os("SWAYSOCK").is_some() && resolve_path_binary("swaymsg").is_some() { | ||
| // sway's IPC accepts `[title="…"] focus` selectors. | ||
| let escaped = target.replace('"', "\\\""); | ||
| let selector = format!("[title=\"{}\"] focus", escaped); |
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.
Closes #1
linuxPermissionFlowto manage permission requirements for Linux desktop usage.readStringField,readObjectField,readArrayField, andcollectSessionNotesfor structured data extraction.permissionFlowForResultto route Linux platform results to the new flow.