Open a compose project in a terminal or editor #20

Closed
opened 2026-11-30 14:39:43 +00:00 by jfro · 1 comment
Owner

What

  • On a compose project: "Open in terminal" and "Open in editor", using the project's working directory from the com.docker.compose.project.working_dir label.
  • Use the desktop's default terminal/editor (xdg-open for the folder; a configurable terminal command).
  • Hide the actions when the folder isn't on this machine (remote engine).
**What** - On a compose project: "Open in terminal" and "Open in editor", using the project's working directory from the `com.docker.compose.project.working_dir` label. - Use the desktop's default terminal/editor (xdg-open for the folder; a configurable terminal command). - Hide the actions when the folder isn't on this machine (remote engine).
jfro added this to the v1.0 milestone 2026-11-30 14:47:14 +00:00
Author
Owner

Approach notes (Nye, review; tested on Docker 26 + rootless Podman 5.4.2)

#20 Open a compose project in terminal / editor

Reuse: WORKING_DIR_LABEL already in src/window/data.rs (com.docker.compose.project.working_dir); it's written by the compose client, so it's there on Podman too when using docker compose.
Tested here: terminals start in the spawning process's cwd: Command::new(term).current_dir(dir) opened xfce4-terminal and x-terminal-emulator (Debian wrapper) in /tmp/k20 dir (with a space). So no per-terminal flags are needed.
Terminal pick order: user setting (command string) > xdg-terminal-exec > $TERMINAL > x-terminal-emulator (Debian/Ubuntu) > first found of ptyxis gnome-terminal konsole xfce4-terminal kitty alacritty wezterm foot xterm.
Editor: there is no XDG "code editor" default (xdg-mime query default text/plain = mousepad here, which can't open a folder; inode/directory = file manager). So: user setting > first found of code codium zed subl kate (flatpak run com.visualstudio.code if the flatpak is installed), passing the dir as the argument. If none: hide "Open in editor" and offer "Open folder" via xdg-open <dir>.
Must-dos:

  1. Hide both when the label is missing, the engine isn't local (ssh://, tcp:// from #16), or Path::new(dir).is_dir() is false.
  2. Spawn detached: stdin/out/err null, don't wait on the UI thread, and reap (thread that wait()s, or setsid) so no zombies pile up.
  3. Pass the dir as a separate arg / current_dir, never through sh -c (paths with spaces/quotes).
  4. A configured command: split with shell-words rules or just take program + args fields; support {dir} if present, else rely on current_dir.
  5. Error toast if spawn fails (command not found), not a silent no-op.
  6. Mock: give mock projects a working_dir so the actions show in screenshots.
**Approach notes (Nye, review; tested on Docker 26 + rootless Podman 5.4.2)** ## #20 Open a compose project in terminal / editor Reuse: `WORKING_DIR_LABEL` already in `src/window/data.rs` (`com.docker.compose.project.working_dir`); it's written by the compose *client*, so it's there on Podman too when using docker compose. Tested here: terminals start in the **spawning process's cwd**: `Command::new(term).current_dir(dir)` opened xfce4-terminal and `x-terminal-emulator` (Debian wrapper) in `/tmp/k20 dir` (with a space). So no per-terminal flags are needed. Terminal pick order: user setting (command string) > `xdg-terminal-exec` > `$TERMINAL` > `x-terminal-emulator` (Debian/Ubuntu) > first found of `ptyxis gnome-terminal konsole xfce4-terminal kitty alacritty wezterm foot xterm`. Editor: there is no XDG "code editor" default (`xdg-mime query default text/plain` = mousepad here, which can't open a folder; `inode/directory` = file manager). So: user setting > first found of `code codium zed subl kate` (`flatpak run com.visualstudio.code` if the flatpak is installed), passing the dir as the argument. If none: hide "Open in editor" and offer "Open folder" via `xdg-open <dir>`. Must-dos: 1. Hide both when the label is missing, the engine isn't local (ssh://, tcp:// from #16), or `Path::new(dir).is_dir()` is false. 2. Spawn detached: stdin/out/err null, don't wait on the UI thread, and reap (thread that `wait()`s, or `setsid`) so no zombies pile up. 3. Pass the dir as a separate arg / current_dir, never through `sh -c` (paths with spaces/quotes). 4. A configured command: split with shell-words rules or just take program + args fields; support `{dir}` if present, else rely on current_dir. 5. Error toast if spawn fails (command not found), not a silent no-op. 6. Mock: give mock projects a working_dir so the actions show in screenshots.
jfro closed this issue 2026-11-30 19:31:02 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/krane#20
No description provided.