Skip to content

About

Live radar for git worktrees: list every one wt/coppice know about, jump into an editor on Enter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

79 Commits

Folders and files

Repository files navigation

understory

A live radar for git worktrees: every worktree of every repo it knows about (see "Worktree discovery" below), most recently committed first. Enter opens or focuses Ghostty, and x removes with confirmation.

understory is the always-on counterpart to wt/coppice, which do the actual worktree work; see Ecosystem below for how all the pieces fit together. It stays read-only except for two triage actions: removing worktrees, delegated to wt remove with a confirmation prompt, and parking/unparking them, one git config key per branch (see Actions below).

Ecosystem

understory is one of four tools that split "what's running, and where, on this machine" into two independent radars over two independent lifecycle tools, one pair for git worktrees, one pair for agent sessions:

Tool Layer Job
wt (worktrunk) engine creates/removes worktrees, runs lifecycle hooks (post-start, pre-remove, ...), maintains the shared registry
coppice lifecycle CLI cross-repo new/list/remove/clean worktrees, on top of wt, from anywhere on disk
understory (this repo) worktree radar live dashboard of every worktree in the registry; open-or-focus a Ghostty window on Enter, remove with confirmation on x
canopy agent radar live, read-only dashboard of every agent CLI session on the machine; open or focus Ghostty on Enter
flowchart LR
    wt["wt (worktrunk)<br/>engine + hooks"]
    coppice["coppice<br/>cross-repo worktree CLI"]
    registry[("~/.cache/wt/known-repos")]
    understory["understory<br/>worktree radar"]

    coppice -- new/remove/clean, via --> wt
    wt -- post-start hook writes --> registry
    coppice -- also writes, on first touch --> registry
    registry -- read only --> understory
Loading

canopy doesn't appear in that diagram: it's fully independent of wt's registry and of the other three tools here, discovering agent processes directly via ps/lsof and AppleScript for Ghostty, rather than reading anything worktree-related. It's included in the table above because the two dashboards (canopy, understory) are meant to run side by side, each a single-view radar over one kind of thing, rather than one tool trying to cover both. That's not an accident of scope, it's the reason this repo exists: understory started as a second view inside canopy itself (agent-to-worktree matching, jump-to-worktree), and was pulled out into its own tool specifically so canopy's job could stay "agent sessions," nothing else, and this one's could stay "worktrees," nothing else. See What this deliberately doesn't do for the one piece of that old view intentionally not carried over.

What it looks like

understory — worktrees on this machine
2 worktrees

Repo                  Branch          Created   Modified   Worktree  Merge     Ghostty  Path
luiul/understory      hide-main-wt    12s       12s        dirty     unmerged   open     ~/worktrees/.../understory
hellofresh/isa-orch…  fix-writeback   3d        8h         clean     unmerged   -        ~/worktrees/.../isa-orchestration

↑/↓ move · enter open/focus · x remove · / filter · ? help · q quit

(the currently selected row also gets a full-width grey highlight in the real terminal output, not shown here since it's just a background color)

Each repo's main worktree (Entry.IsMain: the base-branch checkout wt/coppice created the others alongside, not necessarily a branch named "main") is hidden by default, since it rarely has anything to do (its Merge column is always -, nothing to merge it into) and would otherwise take the first row of every repo's block whether or not there's actually any work going on there. Pass --show-main to include it; a repo with no other worktrees at all shows nothing without that flag.

The currently selected row is highlighted with a subtle grey background spanning the full width of the table, rather than a leading marker glyph: with rows grouped by repo, most of a block's rows look alike (blank Repo cell, similar Branch/Worktree/Merge text), so a highlighted row is much easier to keep track of while scrolling than a single character off to the side. Path shortens a leading home-directory prefix to ~, same as your shell prompt, and when the column is too narrow it truncates the head (…speed-up-ci/global-ops), because the tail is what identifies the worktree — the head is the same ~/worktrees/… prefix on nearly every row. Columns use the full terminal width. Repo, Branch, and Path first receive space for their displayed text. Repo and Branch have higher content priority than Path. Once that text fits, these columns share spare space with weights of 1:2:2. Created, Modified, Worktree, Merge, and Ghostty stay compact. On narrow terminals, text columns shrink before compact fields. Every column keeps a hard minimum. Below 70 terminal columns, a clear warning asks you to widen the window. No columns disappear. Text filtering does not change column widths.

Branch appends @ <segment>/ when wt reports the worktree as a branch_worktree_mismatch: the directory was created for another branch (the <segment> in its path) and later git switched by hand, so the row is keyed by its checked-out branch while the path names a different one, and without the flag that branch would look like it has no worktree at all. The suffix renders with a dim @ and a magenta segment, the same colors coppice gives it, so it reads as context next to the plain branch name. Created is the worktree directory's own age; Modified is when someone last worked in it: the later of its last commit and the newest uncommitted or untracked file's mtime, clamped up to Created so a worktree branched from an older base never reads as modified before it was created, so a worktree with fresh edits never reads as stale just because its HEAD is old (a clean worktree takes its commit time directly, so the steady-state poll stays cheap). Worktree/Merge are plain-word renderings of wt's own compact status glyphs (dirty/ahead/behind), rather than the glyphs themselves. Worktree also shows parked when the branch carries coppice's parked mark (cop park, a branch.<branch>.parked-at git config timestamp) and no commit has landed since: task complete, kept on disk for follow-up. The whole row greys out around the still-blue word, the same treatment cop list gives its parked rows, so a parked worktree reads as set aside at a glance while the signal itself stays legible. A newer head commit flips the row back to active on its own, the same read-time rule cop list applies, so a stale mark never needs cleaning up. The Ghostty column tells you whether a Ghostty window is already open on the worktree (open, -, or ? when the window listing couldn't be read, or came back empty while Ghostty is running): it answers with the exact same already-open check Enter's open-or-focus runs (see below), so open means Enter would focus that window rather than open a new one.

Each internal column border can be dragged with the mouse. The two neighboring columns trade width, so the table's total width stays unchanged. Visible dividers on the header row show where to grab. The shared trellis and loam packages handle these gestures and dividers for both understory and canopy.

A changed drag saves your desired proportions for this session. Repo, Branch, and Path then keep those proportions across polls instead of growing to fit new text. Longer labels truncate with an ellipsis. Compact columns stay compact unless you deliberately widen one into the proportional pool. Each column can shrink to its hard minimum. Worktree keeps six cells so parked still fits. Terminal width changes preserve your preferences and project them onto the new width. A wide, narrow, wide cycle restores the same layout without drift. Height-only changes keep the columns and active gesture unchanged.

Polls still update rows during an active drag, but column geometry stays frozen until release. A terminal width change cancels the gesture before it resizes the table. Preferences live in memory only. Restart understory to return to automatic sizing.

Enter opens or focuses Ghostty at the selected worktree path through github.com/luiul/dashkit/mycelium's existing title matcher. It passes an empty tty because worktree rows have no agent identity. Mycelium matches window titles by path and opens a new Ghostty window when none matches. Repeated presses reuse a matching window. Canopy uses the same Ghostty matcher, with tty-preferred title matching and cwd fallback for agent rows. Neither tool uses host discovery to select an editor.

Actions

Everything other than removal and parking is read-only. Parking (p) is the non-destructive one: it sets or deletes the branch's parked mark (coppice's branch.<branch>.parked-at git config timestamp), nothing else, so it never asks unless the worktree has uncommitted changes (parking marks a worktree task-complete, and dirty and complete contradict each other, the same question cop park asks). Pressing p on a parked row unparks it. The removal keybindings all ask for confirmation first (y confirms, n/esc/enter cancels, and an unanswered prompt cancels itself after 10 seconds, since rows keep repolling and reordering underneath it), then delegate to wt remove (git worktree remove --force for stale registrations), the same commands cop remove wraps. When the poll's Ghostty snapshot reports a window currently open on a removal target, the prompt says so and asks you to close it first, since deleting a directory out from under an open window strands that window on a path that no longer exists. That check uses mycelium's strict window match (a window counts only when one of its folders is the worktree itself or sits inside it), not the column's open-or-focus one: a false "open" on a destructive prompt would cry wolf.

Key Action
x Remove the selected worktree. wt refuses one with uncommitted changes and deletes the branch only if merged; the prompt says which applies to the selected row.
X Force remove: discards uncommitted changes and deletes the branch even if unmerged.
P Prune every stale worktree registration (directories already gone; drops only the git metadata).
M Remove every merged worktree of the selected row's repo, branches included.
p Park the selected worktree (task complete, kept for follow-up), or unpark a parked one. Parking a dirty one asks first.
y Copy the selected worktree's full path to the clipboard (vim's yank).
m Show or hide each repo's main worktree (same as --show-main, at runtime).
/ Filter the rows fuzzily (a subsequence match over repo, branch, status, merge state, and path), the same gesture jira-today's fzf picker uses. enter still opens while typing; esc leaves the input with the filter applied, and a second esc clears it.
? Full keybinding list.

Conventions

understory and canopy share one set of keybinding conventions, so muscle memory transfers between the two dashboards: lowercase keys act on the selected row or are reversible (x, p, y, m), uppercase keys are the bulk or stronger form (X, P, M), every destructive action asks for confirmation first, and ctrl+c always quits: from the table, from a confirmation prompt, from the help overlay. The full set of shared decisions (keybindings, the modal discipline, phrasing, rendering, testing, releasing) is written down once in dashkit's CONVENTIONS.md.

A removal's result (including wt's own refusal reason, with a hint at X when it refused a dirty worktree) shows on the status line, and a successful removal refreshes the view immediately rather than waiting for the next poll.

Worktree discovery

understory reads the same shared ~/.cache/wt/known-repos registry wt's own post-start hook (see worktrunk) and coppice already populate, read only: understory never writes to it. It also folds in the repo containing whatever directory understory itself was launched from, if any and not already listed, so the view isn't empty by default for a repo that's never gone through wt/coppice. Requires wt on PATH for any data at all; without it, understory says so instead of showing an empty list.

The view polls on a slow interval (worktree state barely changes). Between polls, an in-process membership probe keeps detection nearly live (issue #10). Every three seconds, and again whenever the terminal window regains focus, understory reads each known repo's .git/worktrees admin directory itself: no subprocess, so none of the per-spawn cost that makes wt list slow to notice changes (issue #9). A repo whose membership changed gets a skeleton row right away (branch, path, and age from the admin dir; the status columns read "…"), and a targeted wt list over just that repo replaces it with full data seconds later, instead of the new worktree waiting out a full-registry fan-out. A removed worktree's row drops on the same probe. The typical flow is creating a worktree in another window (cop new, jira-worktree) and switching here to check it: the skeleton is on screen before you can read it. A focus that finds no membership change still runs a full poll, so dirty/merge statuses refresh on window switch the way they always have. The probe answers membership only; everything else still comes from the streamed poll.

Startup is stale-while-revalidate (issue #8). Every wt list is a subprocess fan-out, so a cold first poll takes seconds to tens of seconds. Instead of sitting on "loading worktrees…" for that wait, understory renders the last completed poll's merged view from ~/.cache/understory/poll-cache.json immediately (marked "refreshing…" until the first poll lands), and the poll then streams in repo by repo: each repo's rows update the moment its own wt list finishes rather than all at once when the slowest one does, with the repo you launched from polled first. A worktree removed since the last run lingers as a stale row for one poll at most, and the first completed poll rewrites the cache. The cache is best-effort: delete it and the next launch is simply a cold start.

What this deliberately doesn't do

There's no notion of "live" (an agent currently working inside a given worktree, the way canopy's own Worktrees view once had): that would require the same process-discovery machinery canopy already owns for its own dashboard, and duplicating it here would recouple two tools that are otherwise fully independent. If you want to know whether something is actively running in a given worktree, that's canopy's job, not understory's.

Why Go, not Python (like coppice)

Same reasoning as canopy: this is 100% subprocess orchestration (wt list, Ghostty AppleScript) and a polling TUI, no real computation, so a single compiled binary with instant startup fits better than a Python interpreter + venv. coppice stays Python because its job (new, list, remove, clean) is closer to a scriptable CLI than a long-running dashboard.

Architecture

  • internal/worktree: shells out to wt list --format json. Reads the shared ~/.cache/wt/known-repos registry (read only) to find every repo to ask about.
  • internal/tui: the Bubble Tea dashboard (table, polling timer, open-on-Enter via github.com/luiul/dashkit/mycelium's shared Ghostty open-or-focus logic, the same package canopy uses for agent working directories, notifications, the confirmed-removal modal behind x/X/P/M, and the ? help overlay, the modal's state machine and the overlay's renderer shared with canopy via github.com/luiul/dashkit/confirm and github.com/luiul/dashkit/loam's HelpView).
  • cmd/understory: the CLI entry point (flags, version).

Install

cd understory
scripts/install.sh   # builds, installs to ~/.local/bin, code-signs with a
                     # stable local identity so the macOS Automation
                     # permission (needed by mycelium's System Events
                     # window listing and raise on every poll and Enter)
                     # survives future rebuilds instead of resetting
                     # every time -- see the script's own comment for
                     # why and how to set up that signing identity once

Or, without the stable signature (works, but expect to re-grant Automation after every rebuild):

cd understory
go build -o /tmp/understory-build ./cmd/understory
install -m 0755 /tmp/understory-build ~/.local/bin/understory   # or anywhere on PATH

Or, if $(go env GOPATH)/bin (usually ~/go/bin) is on your PATH:

go install ./cmd/understory

Requires wt (worktrunk) on PATH; without it, understory has nothing to show and says so.

Development

go build ./...
go vet ./...
go test ./...
gofmt -l .   # should print nothing

Limitations

  • Same machine, same user only.
  • Navigation only opens or focuses Ghostty. It does not move or reconnect an agent from another host. Ghostty title matching cannot select an Orca or herdr pane. Those panes are not supported navigation targets.
  • No "live" agent awareness (see above) — by design, not a gap to fill.
  • Mouse click-to-select isn't implemented (keyboard only: arrow keys + Enter); Bubble Tea's table widget doesn't ship row-click handling out of the box the way Textual's DataTable does.

About

Live radar for git worktrees: list every one wt/coppice know about, jump into an editor on Enter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages