Skip to content

feat(hub): follow every stack's worktrees; start a stopped stack's lane (ADR-0078) - #374

Merged
7schmiede merged 13 commits into
mainfrom
feat/worktrees-live
Oct 30, 2026
Merged

7schmiede merged 13 commits into
mainfrom
feat/worktrees-live

Conversation

@7schmiede

Copy link
Copy Markdown
Member

Fixes two gaps the owner found in use:

  • Stale sidebar: a worktree made in a stack that was not shown appeared only after that stack was opened.
  • Stopped stacks: a stack whose daemon did not run showed no worktrees. A worktree the dashboard made for it could be neither opened nor started.

Review card

Approved by the owner in the conversation on 2026-10-29: all three points.

Category Point Beats Reversing costs
contract The hub follows .git/worktrees of every registered stack, running or not, as the daemon does, and tells /hub/events when one changes; the dashboard reads that stack's lanes again then. Reading lanes only when the list of stacks changes (before); following every running daemon's stream (a connection per stack, and nothing of a stopped one). An additive event; without it the behaviour before.
concept A stopped stack shows its worktrees in the sidebar as not started, read from git through the hub; a click opens the lane's start page. A stopped stack's worktrees invisible and unreachable. UI only.
contract POST /hub/stacks/{id}/lanes/start {path, on?}: the hub starts the lane of a stopped stack as devstack up in its worktree does: the daemon comes up, the main working tree's services stay stopped, the lane starts here or on the pool. "Start stack" first (the main tree's services), then the lane. A hub route less; the stack is started first again.

Decided on my own:

  • Event shape: a snapshot, {"type":"worktrees","worktrees":{"<id>":"<version>"}}, instead of one event per change as the card wrote it. Every hub event starts with a snapshot, so a dashboard that reconnects misses nothing.
  • What the hub watches: the daemon's own fingerprint, i.e. the entries and their HEADs. It asks git for each stack's git directory once and checks once a second. This reads a local folder and asks nobody, so it is not polling another party.
  • The worktree list:
    • GET /hub/stacks/{id}/worktrees gives lanes in the LaneView shape with active: false;
    • names follow the daemon's lane_name of the folder; two folders with the same name get -2 from the daemon but not here;
    • main_stack_file and not_in_pool are included.
  • Lane start:
    • without on the hub runs devstack up --on local, so a "default on" setting does not send the lane into the pool unasked;
    • on accepts [A-Za-z0-9-_.:] only;
    • the path must be a worktree that git lists for the stack, and not the main working tree;
    • the output goes to up-<id>-lane.log, and a failure before the daemon runs becomes the stack's start_error.
  • Dashboard:
    • a small start card for a stopped stack's lane, with "Start here" and "Start in the pool" (the latter disabled without a lane image); the full start page takes over once the daemon runs;
    • the branch picker finds these lanes too;
    • a lane the picker makes for a stopped stack opens on this card.
  • ADR number: 0078, checked against origin/main and the open PRs.

What changed

  • devstack-hub:
    • worktrees.rs: the watcher, the list, and the lane start;
    • lib.rs: the routes and worktrees on /hub/events;
    • branches::common_dir is now pub(crate).
  • devstack-daemon: lanes::fingerprint is now pub.
  • UI:
    • the sidebar lists every stack's worktrees, including stopped stacks, and rereads a stack on its worktrees version;
    • stack.ts: offlineLanes, offlineLane, startOfflineLane, and newLane for a stopped stack;
    • new OfflineLaneStart.vue;
    • BranchPicker.vue;
    • mock routes.
  • Docs: ADR-0078 and its index entry, dashboard-api.md, CHANGELOG.

Checked

  • cargo fmt, cargo clippy --workspace --all-targets: clean.
  • cargo test -p devstack-hub -p devstack-daemon -p devstack (Windows): green. New test: a stack's worktrees appear as lanes not started, with the daemon's names and their stack file, and a new worktree changes the version.
  • ui: typecheck, vitest (91) and npm run build green.
  • To try: with the real hub, on a stopped stack (croniq and its hi), and by adding a worktree with git worktree add while another stack is shown.

🤖 Generated with Claude Code

7schmiede and others added 7 commits October 29, 2026 21:04
…ne (ADR-0078)

The hub looks at <git common dir>/worktrees of each registered stack once
a second, as the daemon does, and tells /hub/events a version per stack;
the sidebar reads a stack's lanes again when it changes, so a worktree
made anywhere shows without opening its stack. A stack whose daemon does
not run lists its worktrees through GET /hub/stacks/{id}/worktrees as
lanes not started; one opens a start card, and POST
/hub/stacks/{id}/lanes/start runs `devstack up` in the worktree (here or
on the pool): the daemon comes up, the main tree's services stay stopped.
The branch picker finds those worktrees too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…one live

?mock=worktrees adds one to docs after four seconds, as git worktree add
elsewhere would; a lane the branch picker makes for a stopped stack is
listed at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ets a start card as a lane's

The sidebar took the last state seen for a stopped stack's main tree, and
a daemon's last, empty lane list over the hub's; both are the hub's now.
The main working tree of a stopped stack shows a start card above its last
known state: Start here, and that the pool runs a worktree's lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out tabs, below the banner

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lanes; the banner the same for both

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dle beside offline

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he mock starts a stopped stack's lane alone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7schmiede and others added 6 commits October 29, 2026 21:51
…ch; the tab shown carries over to other stacks and lanes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s the worst of its trees'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting a stopped stack's; a lane not started shows no failure of its main tree; gap only below a banner

LaneStart takes the lane of a stopped stack (started through the hub, now
with a profile) and its main working tree (null: Start here starts the
stack, the pool is off with why); the separate card is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit 390b807 into main Oct 30, 2026
13 checks passed
@7schmiede
7schmiede deleted the feat/worktrees-live branch October 30, 2026 10:38
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.

1 participant