Skip to content

Add Linux permission flow handling and utility functions#2

Open
matedev01 wants to merge 1 commit into
OpenCoven:mainfrom
matedev01:feat/linux-x11-wayland-support
Open

Add Linux permission flow handling and utility functions#2
matedev01 wants to merge 1 commit into
OpenCoven:mainfrom
matedev01:feat/linux-x11-wayland-support

Conversation

@matedev01
Copy link
Copy Markdown

@matedev01 matedev01 commented May 5, 2026

Closes #1

  • 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).

- 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).
@BunsDev
Copy link
Copy Markdown
Member

BunsDev commented May 11, 2026

@copilot resolve the merge conflicts in this pull request

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 thread src/plugin-tool.ts
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 thread src/main.rs
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 thread src/main.rs
Comment on lines +559 to +563
let missing: Vec<String> = tools
.iter()
.filter(|t| !t.found)
.map(|t| t.name.to_string())
.collect();
Comment thread src/main.rs
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 thread src/main.rs
Comment on lines +1047 to +1049
let app = value(args, "--app");
let title = value(args, "--window-title");
let target = title.or(app);
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 thread src/plugin-tool.ts
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 thread src/main.rs
Comment on lines +1126 to +1128
// Allow XKeysym names through unchanged (e.g. "ctrl+c", "F5", "shift+Tab").
other => other.to_string(),
}
Comment thread src/main.rs
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 thread src/main.rs
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 thread src/main.rs
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);
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.

Add Linux (X11 + Wayland) support to coven-desktop-use

3 participants