diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f33c59f..b611f3b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,23 @@ and listed with their assets on the ## [Unreleased] +### Added + +- **Open a tree in GitHub Desktop** (Windows, ADR-0046): the path's menu + in the stack header lists it when it is installed, in a group of its own + for Git clients. A repository it does not know yet is added to its list. + ### Fixed - **Serving the main ports refuses a stack of Compose containers only** (#184): it answered that the lane served them and moved nothing, as a container's published port is Docker's, not devstack's. It now says so (`409`), in the dashboard too. +- A link to a service or container of a lane shared with you (its port, in + the list and on its page) opens it: a click opens the forward to it on + your machine, as **Open** in the pool area does, and keeps the link's + path. Before, it pointed at `localhost:` of the lane's node, where + nothing on your machine listens. - **A tree opened in a program comes to the front on Windows** (ADR-0046): Explorer, the terminals, the editors, the agents and Orca opened behind the browser, as the hub runs in the background. The hub takes the @@ -128,11 +139,6 @@ share switch is gone: it never let a lane run (see Removed). ### Fixed -- A link to a service or container of a lane shared with you (its port, in - the list and on its page) opens it: a click opens the forward to it on - your machine, as **Open** in the pool area does, and keeps the link's - path. Before, it pointed at `localhost:` of the lane's node, where - nothing on your machine listens. - A lane's failed start on a node no longer stays on its start page after the lane or the stack stopped: stopping the lane, stopping the main tree (`devstack down`) or starting the lane here clears it, and the dashboard diff --git a/crates/devstack-hub/src/open.rs b/crates/devstack-hub/src/open.rs index b356aba4..352567cb 100644 --- a/crates/devstack-hub/src/open.rs +++ b/crates/devstack-hub/src/open.rs @@ -4,19 +4,20 @@ //! A fixed list. Each program is found the way it makes itself known: an //! editor or agent by the URL scheme it registered (`vscode`, `claude`, ...), //! started by a link of that scheme, as the shell opens it; a terminal and -//! Orca by their program on `PATH`. The page never names a program or a +//! Orca by their program on `PATH`; GitHub Desktop by its install folder. The page never names a program or a //! command line, only one of the ids found here. use serde::Serialize; use std::path::{Path, PathBuf}; -/// What a program is for, to group the menu. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +/// What a program is for, to group the menu, in menu order. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)] #[serde(rename_all = "snake_case")] pub enum Kind { Files, Terminal, Editor, + Git, Agent, } @@ -52,6 +53,10 @@ enum How { Terminal(PathBuf), /// Orca's CLI. Orca(PathBuf), + /// GitHub Desktop: `--cli-open=`, what its own `github` command + /// runs. + #[cfg_attr(not(windows), allow(dead_code))] + GitHubDesktop(PathBuf), } /// The programs found by their registered scheme, in menu order. @@ -66,7 +71,7 @@ const LINKS: &[(&str, &str, Kind)] = &[ ]; /// What this machine can open a folder with, in menu order: files, -/// terminals, editors, agents. Nothing without a desktop. +/// terminals, editors, Git clients, agents. Nothing without a desktop. pub fn found() -> Vec { let mut out = imp::files_and_terminals(); if out.is_empty() { @@ -84,6 +89,16 @@ pub fn found() -> Vec { }); } } + if let Some(exe) = imp::github_desktop() { + out.push(Found { + opener: Opener { + id: "github-desktop", + label: "GitHub Desktop", + kind: Kind::Git, + }, + how: How::GitHubDesktop(exe), + }); + } if let Some(orca) = imp::orca() { out.push(Found { opener: Opener { @@ -94,6 +109,8 @@ pub fn found() -> Vec { how: How::Orca(orca), }); } + // Stable: within a kind, the order above. + out.sort_by_key(|f| f.opener.kind); out } @@ -125,6 +142,7 @@ pub fn open(id: &str, tree: &Path, repo: &Path, stack_file: &Path) -> Result<(), How::Console(exe) => imp::console(exe, tree), How::Terminal(exe) => imp::terminal(exe, tree), How::Orca(exe) => orca(exe, &path, &display(repo), stack_file), + How::GitHubDesktop(exe) => imp::github_desktop_open(exe, &path), } .map_err(OpenError::Failed) } @@ -310,6 +328,27 @@ mod imp { } } + /// Its launcher in its (per-user) install folder, which starts the + /// version installed last with the arguments it is given. + pub fn github_desktop() -> Option { + let p = PathBuf::from(std::env::var_os("LOCALAPPDATA")?) + .join(r"GitHubDesktop\GitHubDesktop.exe"); + p.is_file().then_some(p) + } + + /// The repository at `path` in GitHub Desktop, added to its list if it + /// is not there yet. + pub fn github_desktop_open(exe: &Path, path: &str) -> Result<(), String> { + std::process::Command::new(exe) + .arg(format!("--cli-open={path}")) + .stdin(std::process::Stdio::null()) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .spawn() + .map(drop) + .map_err(|e| format!("start GitHub Desktop: {e}")) + } + pub fn orca() -> Option { on_path("orca").or_else(|| { let p = PathBuf::from(std::env::var_os("LOCALAPPDATA")?) @@ -451,6 +490,15 @@ mod imp { on_path("orca") } + /// GitHub publishes no Linux build. + pub fn github_desktop() -> Option { + None + } + + pub fn github_desktop_open(_exe: &Path, _path: &str) -> Result<(), String> { + Err("no GitHub Desktop on Linux".into()) + } + /// Start `cmd` and let it go; a thread waits for it, so it leaves no /// zombie behind. fn detach(mut cmd: std::process::Command, what: &str) -> Result<(), String> { @@ -515,6 +563,12 @@ mod imp { pub fn orca() -> Option { None } + pub fn github_desktop() -> Option { + None + } + pub fn github_desktop_open(_exe: &Path, _path: &str) -> Result<(), String> { + Err("not supported on this platform".into()) + } pub fn shell_open(_target: &str) -> Result<(), String> { Err("not supported on this platform".into()) } @@ -560,6 +614,12 @@ mod tests { assert_eq!(l, "vscode://file/x%3FwindowId%3D_blank%23y"); } + #[test] + fn git_clients_come_after_the_editors_before_the_agents() { + assert!(Kind::Editor < Kind::Git && Kind::Git < Kind::Agent); + assert_eq!(serde_json::to_value(Kind::Git).unwrap(), "git"); + } + #[test] fn display_drops_the_verbatim_prefix() { if cfg!(windows) { diff --git a/docs/adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md b/docs/adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md index f771726a..4bc85103 100644 --- a/docs/adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md +++ b/docs/adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md @@ -1,6 +1,6 @@ # ADR-0046: The hub opens a stack's worktree in the user's own programs, from a fixed list -- **Status:** Accepted (2026-10-21), amended 2026-10-21 (the program opens in front on Windows) +- **Status:** Accepted (2026-10-21), amended 2026-10-21 (the program opens in front on Windows; GitHub Desktop) - **Date:** 2026-10-21 - **Deciders:** project owner - **Related:** [ADR-0011](0011-platform-windows-native-first.md), [ADR-0019](0019-control-api-security.md), [ADR-0021](0021-a-hub-serves-the-dashboard.md), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md), [ADR-0040](0040-a-shared-lane-can-be-watched-like-ones-own.md) @@ -40,6 +40,7 @@ Windows Terminal is the `wt.exe` app alias on `PATH`. | `powershell` | PowerShell | always (Windows); `pwsh` before `powershell` | a new console in the folder | | `terminal` | Terminal (Linux) | `$TERMINAL`, `x-terminal-emulator`, then common ones | the terminal in the folder | | `vscode`, `vscode-insiders`, `cursor`, `windsurf`, `zed` | the editor | its scheme is registered | `://file/` | + | `github-desktop` | GitHub Desktop (Windows) | `%LOCALAPPDATA%\GitHubDesktop\GitHubDesktop.exe` | `GitHubDesktop.exe --cli-open=` (added 2026-10-21, see below) | | `claude` | Claude (desktop, Code) | `claude` is registered | `claude://code/new?folder=` | | `claude-cli` | Claude Code (terminal) | `claude-cli` is registered | `claude-cli://open?cwd=` | | `orca` | Orca | `orca` on `PATH` or in its install folder | `orca file open --worktree path: --focus` (the repository added to Orca first, if Orca does not know it) | @@ -78,6 +79,15 @@ Windows Terminal is the `wt.exe` app alias on `PATH`. - **The file manager by `explorer.exe `.** It exits with 1 when it worked; the shell's `open` verb says what happened. +*Amended 2026-10-21: GitHub Desktop.* The commits, branches and pushes of +a tree are a Git client's, not devstack's; the menu offers the one most +installed on Windows, in a group of its own (`kind: "git"`, between the +editors and the agents). It registers `x-github-client`, but that scheme's +only action for a repository (`openRepo/`) clones from a remote. A +folder is opened by the program itself with `--cli-open=`, as its own +`github` command does, through the launcher in its install folder, which +starts the version installed last. GitHub publishes no Linux build. + ## Consequences - The hub starts programs on request of the page. Narrowed by point 3: a diff --git a/docs/adr/README.md b/docs/adr/README.md index b4f58cc4..e6867f3b 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -94,5 +94,5 @@ stay. | [0043](0043-a-dev-servers-fixed-port-is-devstacks.md) | A dev server's fixed port is devstack's, forwarded to its instance | Accepted | | [0044](0044-a-lanes-prepared-directories-can-be-linked-into-its-worktree.md) | A lane's prepared directories can be linked into its worktree | Accepted | | [0045](0045-the-hub-notifies-the-desktop.md) | The hub notifies the desktop of what needs attention, without a tray | Accepted, amended 2026-10-21 (`guest_lane`) | -| [0046](0046-the-hub-opens-a-worktree-in-the-users-programs.md) | The hub opens a stack's worktree in the user's own programs, from a fixed list | Accepted | +| [0046](0046-the-hub-opens-a-worktree-in-the-users-programs.md) | The hub opens a stack's worktree in the user's own programs, from a fixed list | Accepted, amended 2026-10-21 (the program opens in front on Windows; GitHub Desktop) | | [0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) | The dashboard makes a lane from a branch; the main tree's checkout stays the user's | Accepted | diff --git a/docs/dashboard-api.md b/docs/dashboard-api.md index 384a9230..fbd7688b 100644 --- a/docs/dashboard-api.md +++ b/docs/dashboard-api.md @@ -54,7 +54,7 @@ and `Referrer-Policy: no-referrer`. The dashboard has no inline script. | `POST /hub/update/check` | cookie + Origin | look for a newer release now: `{"current", "newer": string\|null}`, the same as the next `release` event; asked again within 30 s, the last answer (GitHub allows 60 unauthenticated requests an hour). `409` with `DEVSTACK_NO_UPDATE_CHECK`, `502` when GitHub cannot be asked, `504` after 30 s | | `POST /hub/stacks/scan` | cookie + Origin | `{"path", "add"?, "depth"?}`: every repository with a `devstack.toml` below a folder (default three levels, `depth` is clamped to 1 to 6; a repository only at its root, linked worktrees skipped), `[{repo, id, name, error, registered, added}]`; with `add` the valid new ones are registered | | `POST /hub/pick-folder` | cookie + Origin | the operating system's folder dialog, shown by the hub (Windows: Explorer picker, Linux: XDG portal): `{"path": "..."}`, `{"path": null}` when cancelled, `501` without a desktop, `409` while one is open | -| `GET /hub/openers` | cookie | what this machine opens a stack's folder with ([ADR-0046](adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md)), in menu order: `[{id, label, kind}]`, `kind` one of `files`, `terminal`, `editor`, `agent`. Ids: `files`, `wt`, `powershell` (Windows), `terminal` (Linux), `vscode`, `vscode-insiders`, `cursor`, `windsurf`, `zed`, `claude`, `claude-cli`, `orca`; only those found (a scheme registered, a program on `PATH`). Empty without a desktop | +| `GET /hub/openers` | cookie | what this machine opens a stack's folder with ([ADR-0046](adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md)), in menu order: `[{id, label, kind}]`, `kind` one of `files`, `terminal`, `editor`, `git`, `agent`. Ids: `files`, `wt`, `powershell` (Windows), `terminal` (Linux), `vscode`, `vscode-insiders`, `cursor`, `windsurf`, `zed`, `github-desktop` (Windows), `claude`, `claude-cli`, `orca`; only those found (a scheme registered, a program on `PATH` or in its install folder). Empty without a desktop | | `POST /hub/open {"stack", "path", "with"}` | cookie + Origin | open `path` with the program `with`: `204`. `path` must be the stack's repository or one of its worktrees (`git worktree list`), `with` an id `GET /hub/openers` lists now; `400` otherwise, `404` for an unknown stack, `502 {"error"}` when the program could not be started | | `GET /hub/inspect?path=` | cookie | `{repo, is_dir, has_stack_file, valid, registered, id}` for an absolute folder path (the "Add a stack" dialog). `valid` is `null` without a stack file, `{"Ok":null}` when it loads, `{"Err":""}` when not; `registered` is the id or `null`. Every route that takes a `path` takes a local one only: `400` for a network path (`\\host\share`, `//host/share`; on Windows anything but a drive, `C:\` or `\\?\C:\`) | | `POST /hub/stacks/add {"path"}` | cookie + Origin | registers a folder that has a `devstack.toml`; `{id, name}` | diff --git a/ui/src/api/mock/index.ts b/ui/src/api/mock/index.ts index e27e2789..9e35663a 100644 --- a/ui/src/api/mock/index.ts +++ b/ui/src/api/mock/index.ts @@ -439,6 +439,7 @@ export class MockTransport implements Transport { { id: 'wt', label: 'Windows Terminal', kind: 'terminal' }, { id: 'powershell', label: 'PowerShell', kind: 'terminal' }, { id: 'vscode', label: 'VS Code', kind: 'editor' }, + { id: 'github-desktop', label: 'GitHub Desktop', kind: 'git' }, { id: 'claude', label: 'Claude Desktop', kind: 'agent' }, { id: 'claude-cli', label: 'Claude Code', kind: 'agent' }, { id: 'orca', label: 'Orca', kind: 'agent' }, diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 07caa670..b7bb5ef8 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -449,7 +449,7 @@ export type CapacityPoint = { }; /** A program this machine can open a stack's folder with (`GET /hub/openers`, ADR-0046). */ -export type Opener = { id: string; label: string; kind: 'files' | 'terminal' | 'editor' | 'agent' }; +export type Opener = { id: string; label: string; kind: 'files' | 'terminal' | 'editor' | 'git' | 'agent' }; /** A kind of desktop notification and whether it is on (ADR-0045). */ export type NotifyKind = { kind: string; label: string; on: boolean; default: boolean }; diff --git a/ui/src/components/StackHeader.vue b/ui/src/components/StackHeader.vue index e80aa25b..fee7f13d 100644 --- a/ui/src/components/StackHeader.vue +++ b/ui/src/components/StackHeader.vue @@ -104,7 +104,7 @@ const pathTrigger = ref(null); const { open: pathOpen, close: pathClose } = usePopover(pathRoot, pathTrigger); const canOpen = computed(() => !hubAway.value && !stack.sharedLane && !!stack.id); const openers = computed(() => (canOpen.value ? (hub.openers ?? []) : [])); -const openerIcon = { files: 'folder', terminal: 'terminal', editor: 'file', agent: 'zap' } as const; +const openerIcon = { files: 'folder', terminal: 'terminal', editor: 'file', git: 'gitBranch', agent: 'zap' } as const; function togglePath() { pathOpen.value = !pathOpen.value; if (pathOpen.value && canOpen.value) void hub.loadOpeners();