feat: open a compose project's folder in a terminal or editor #27

Merged
jfro merged 1 commit from feat/20-open-project into main 2026-11-30 19:31:02 +00:00
Owner

Closes #20

Stacked on #26 (#19 notifications); merge after it.

What

  • Open in Terminal and Open in Editor on a compose project, in its right-click menu and under the Overview on its Info tab. They use the project's com.docker.compose.project.working_dir label.
  • Terminal: the "terminal" setting, else xdg-terminal-exec, $TERMINAL, x-terminal-emulator, then ptyxis, gnome-terminal, kgx, konsole, xfce4-terminal, kitty, alacritty, wezterm, foot, xterm. It's started in the folder (current_dir), so no per-terminal flags are needed.
  • Editor: the "editor" setting, else the first of code, codium, zed/zeditor, subl, kate, or the VS Code flatpak, with the folder as its argument. There's no XDG default for a code editor (text/plain is often a plain text editor that can't open folders), so with none found the action becomes Open Folder (xdg-open, the file manager).
  • Settings: ~/.config/krane/settings.json, e.g. {"terminal": "kitty", "editor": "code --new-window"}. Split like a shell would; {dir} stands for the folder (otherwise editors get it appended, terminals just start in it). No UI for these yet; README documents them.
  • Hidden when the label is missing, the engine is remote (DOCKER_HOST other than unix:///npipe://), or the folder doesn't exist here.
  • Spawned with null stdio, folder passed as an argument or working dir (never through sh -c, so spaces and quotes are fine), and a thread wait()s on it so nothing is left as a zombie. A failed spawn shows a toast.
  • settings.rs now holds settings reading/writing (moved out of notify.rs).
  • Mock: projects already have working dirs; the actions show under --mock. New project screenshot scene; README features, screenshot table and layout updated.

Tested

  • Local CI (fmt, clippy -D warnings with and without mock, build, tests): 4 new unit tests (local vs remote engine, missing folder, {dir} and quoting, launch runs in a folder with a space and errors for a missing program).
  • Live on Xfce against Docker 29 (compose project shop): Open in Terminal opened xfce4-terminal in the project folder; with no editor installed the menu said Open Folder; with "editor": "thunar {dir}" it said Open in Editor and opened the folder. No zombie children left.

Known limit: the Info tab's buttons pick up a changed editor setting the next time the project is selected (the menu checks each time it opens).

Screenshots (mock data)

Project, dark
Project, light

Closes #20 Stacked on #26 (#19 notifications); merge after it. ## What - **Open in Terminal** and **Open in Editor** on a compose project, in its right-click menu and under the Overview on its Info tab. They use the project's `com.docker.compose.project.working_dir` label. - **Terminal**: the `"terminal"` setting, else `xdg-terminal-exec`, `$TERMINAL`, `x-terminal-emulator`, then ptyxis, gnome-terminal, kgx, konsole, xfce4-terminal, kitty, alacritty, wezterm, foot, xterm. It's started *in* the folder (`current_dir`), so no per-terminal flags are needed. - **Editor**: the `"editor"` setting, else the first of `code`, `codium`, `zed`/`zeditor`, `subl`, `kate`, or the VS Code flatpak, with the folder as its argument. There's no XDG default for a code editor (`text/plain` is often a plain text editor that can't open folders), so with none found the action becomes **Open Folder** (`xdg-open`, the file manager). - **Settings**: `~/.config/krane/settings.json`, e.g. `{"terminal": "kitty", "editor": "code --new-window"}`. Split like a shell would; `{dir}` stands for the folder (otherwise editors get it appended, terminals just start in it). No UI for these yet; README documents them. - **Hidden** when the label is missing, the engine is remote (`DOCKER_HOST` other than `unix://`/`npipe://`), or the folder doesn't exist here. - Spawned with null stdio, folder passed as an argument or working dir (never through `sh -c`, so spaces and quotes are fine), and a thread `wait()`s on it so nothing is left as a zombie. A failed spawn shows a toast. - `settings.rs` now holds settings reading/writing (moved out of `notify.rs`). - Mock: projects already have working dirs; the actions show under `--mock`. New `project` screenshot scene; README features, screenshot table and layout updated. ## Tested - Local CI (fmt, clippy -D warnings with and without `mock`, build, tests): 4 new unit tests (local vs remote engine, missing folder, `{dir}` and quoting, launch runs in a folder with a space and errors for a missing program). - Live on Xfce against Docker 29 (compose project `shop`): Open in Terminal opened xfce4-terminal in the project folder; with no editor installed the menu said Open Folder; with `"editor": "thunar {dir}"` it said Open in Editor and opened the folder. No zombie children left. Known limit: the Info tab's buttons pick up a changed `editor` setting the next time the project is selected (the menu checks each time it opens). ## Screenshots (mock data) ![Project, dark](https://git.knope.dev/attachments/2681af00-886a-4d2a-8b7c-5fe74463de31) ![Project, light](https://git.knope.dev/attachments/479db1ef-a95c-4ff4-9a1a-02588d253a25)
feat: open a compose project's folder in a terminal or editor
All checks were successful
CI / test (pull_request) Successful in 4m57s
fd8eb15185
Adds Open in Terminal and Open in Editor (Open Folder when no editor is
found) to a compose project's right-click menu and Info tab. The terminal
starts in the project's working directory; the editor gets it as an
argument. Both can be set in ~/.config/krane/settings.json ("terminal",
"editor", with {dir} for the folder). The actions are hidden when the
engine is remote or the folder isn't on this machine.

Settings reading/writing moves from notify.rs into settings.rs.

Closes #20
jfro force-pushed feat/20-open-project from fd8eb15185
All checks were successful
CI / test (pull_request) Successful in 4m57s
to 73ece6f001
All checks were successful
CI / test (pull_request) Successful in 5m14s
2026-11-30 18:02:31 +00:00
Compare
jfro force-pushed feat/20-open-project from 73ece6f001
All checks were successful
CI / test (pull_request) Successful in 5m14s
to ccd4fa0a53
All checks were successful
CI / test (pull_request) Successful in 5m12s
CI / test (push) Successful in 5m16s
2026-11-30 19:02:41 +00:00
Compare
Author
Owner

F10 fixed in ccd4fa0 (rebased on #26's 5838fb8): known terminals now get the folder explicitly: ptyxis --new-window -d DIR, --working-directory=DIR for gnome-terminal, kgx and xfce4-terminal, plus konsole --workdir, kitty --directory, alacritty --working-directory, wezterm start --cwd and foot -D. x-terminal-emulator (and a $TERMINAL path) is resolved to the terminal it links to, .wrapper stripped, so it gets those args. Nye's unit test passes, and a live ptyxis --new-window -d opens its shell in the folder.

F10 fixed in ccd4fa0 (rebased on #26's 5838fb8): known terminals now get the folder explicitly: `ptyxis --new-window -d DIR`, `--working-directory=DIR` for gnome-terminal, kgx and xfce4-terminal, plus konsole `--workdir`, kitty `--directory`, alacritty `--working-directory`, wezterm `start --cwd` and foot `-D`. x-terminal-emulator (and a $TERMINAL path) is resolved to the terminal it links to, `.wrapper` stripped, so it gets those args. Nye's unit test passes, and a live `ptyxis --new-window -d` opens its shell in the folder.
jfro changed target branch from feat/19-notifications to main 2026-11-30 19:30:56 +00:00
jfro merged commit ccd4fa0a53 into main 2026-11-30 19:31:02 +00:00
Sign in to join this conversation.
No reviewers
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!27
No description provided.