Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<port>` 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
Expand Down Expand Up @@ -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:<port>` 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
Expand Down
68 changes: 64 additions & 4 deletions crates/devstack-hub/src/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -52,6 +53,10 @@ enum How {
Terminal(PathBuf),
/// Orca's CLI.
Orca(PathBuf),
/// GitHub Desktop: `--cli-open=<path>`, 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.
Expand All @@ -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<Found> {
let mut out = imp::files_and_terminals();
if out.is_empty() {
Expand All @@ -84,6 +89,16 @@ pub fn found() -> Vec<Found> {
});
}
}
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 {
Expand All @@ -94,6 +109,8 @@ pub fn found() -> Vec<Found> {
how: How::Orca(orca),
});
}
// Stable: within a kind, the order above.
out.sort_by_key(|f| f.opener.kind);
out
}

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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<PathBuf> {
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<PathBuf> {
on_path("orca").or_else(|| {
let p = PathBuf::from(std::env::var_os("LOCALAPPDATA")?)
Expand Down Expand Up @@ -451,6 +490,15 @@ mod imp {
on_path("orca")
}

/// GitHub publishes no Linux build.
pub fn github_desktop() -> Option<PathBuf> {
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> {
Expand Down Expand Up @@ -515,6 +563,12 @@ mod imp {
pub fn orca() -> Option<PathBuf> {
None
}
pub fn github_desktop() -> Option<PathBuf> {
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())
}
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion docs/adr/0046-the-hub-opens-a-worktree-in-the-users-programs.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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 | `<scheme>://file/<path>` |
| `github-desktop` | GitHub Desktop (Windows) | `%LOCALAPPDATA%\GitHubDesktop\GitHubDesktop.exe` | `GitHubDesktop.exe --cli-open=<path>` (added 2026-10-21, see below) |
| `claude` | Claude (desktop, Code) | `claude` is registered | `claude://code/new?folder=<path>` |
| `claude-cli` | Claude Code (terminal) | `claude-cli` is registered | `claude-cli://open?cwd=<path>` |
| `orca` | Orca | `orca` on `PATH` or in its install folder | `orca file open <stack file> --worktree path:<path> --focus` (the repository added to Orca first, if Orca does not know it) |
Expand Down Expand Up @@ -78,6 +79,15 @@ Windows Terminal is the `wt.exe` app alias on `PATH`.
- **The file manager by `explorer.exe <path>`.** 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/<url>`) clones from a remote. A
folder is opened by the program itself with `--cli-open=<path>`, 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
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
2 changes: 1 addition & 1 deletion docs/dashboard-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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":"<why>"}` 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}` |
Expand Down
1 change: 1 addition & 0 deletions ui/src/api/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
2 changes: 1 addition & 1 deletion ui/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/StackHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const pathTrigger = ref<HTMLButtonElement | null>(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();
Expand Down