Make the workspace collector worktree-aware so in-flight agent work stays visible #117

Closed
opened 2026-07-27 15:52:56 +01:00 by vnprc-agent · 0 comments
Contributor

Once agent branch work moves into worktrees outside ~/work, work-diff stops showing it, so the cross-repo view of uncommitted work goes blind exactly when several agents are running. Teach the shared workspace collector about worktrees so in-flight agent work stays visible without putting non-registry directories into ~/work.

Part of allod/tools#115.

Primary goals:

  • Show worktree state in work-diff — uncommitted changes in an agent's worktree appear under the repo they belong to, attributed to their branch, alongside the shared checkout's own status.
  • Keep pull-all off worktrees — sync operates on registry checkouts only; a worktree is never treated as a repo to pull or switch.
  • Derive worktrees from git, not from the filesystem — enumerate with git worktree list per collected repo rather than globbing a directory, so the answer stays correct wherever worktrees are sited.
  • Leave the registry projection intact~/work continues to contain exactly the checkouts the inventory registry declares.

Current state

lib/workspace.sh workspace_collect_repos enumerates directories under WORK_DIR and returns anything that is a repo root; work-diff, pull-all, flake-status, and flake-update-cascade all consume it. Two consequences follow, both verified: a worktree placed under ~/work is collected as if it were an ordinary repo, so pull-all attempts git pull on a branch with no upstream and reports an error; and a worktree placed anywhere else is invisible to work-diff, which is the whole cross-repo status view.

Note that workspace_is_repo_root already accepts a linked worktree, since it tests [[ -e "$dir/.git" ]] and a worktree's .git is a file rather than a directory. Any fix therefore needs to distinguish a registry checkout from a linked worktree deliberately rather than relying on that test.

Suggested shape

Add a collector entry point that returns registry checkouts (today's behavior, used by pull-all, flake-status, and flake-update-cascade) and a second that returns each checkout's linked worktrees, used by work-diff. git -C <repo> worktree list --porcelain gives path, branch, and detached state in one call. Rendering worktrees indented under their repo keeps a repo's full state in one place in the output.

Scope

In: lib/workspace.sh, workspace/work-diff, and confirmation that pull-all and the flake tools keep operating on registry checkouts only, plus tests. Out: where worktrees are created, which is allod/tools#116.

Once agent branch work moves into worktrees outside `~/work`, `work-diff` stops showing it, so the cross-repo view of uncommitted work goes blind exactly when several agents are running. Teach the shared workspace collector about worktrees so in-flight agent work stays visible without putting non-registry directories into `~/work`. Part of allod/tools#115. Primary goals: - **Show worktree state in `work-diff`** — uncommitted changes in an agent's worktree appear under the repo they belong to, attributed to their branch, alongside the shared checkout's own status. - **Keep `pull-all` off worktrees** — sync operates on registry checkouts only; a worktree is never treated as a repo to pull or switch. - **Derive worktrees from git, not from the filesystem** — enumerate with `git worktree list` per collected repo rather than globbing a directory, so the answer stays correct wherever worktrees are sited. - **Leave the registry projection intact** — `~/work` continues to contain exactly the checkouts the inventory registry declares. ### Current state `lib/workspace.sh` `workspace_collect_repos` enumerates directories under `WORK_DIR` and returns anything that is a repo root; `work-diff`, `pull-all`, `flake-status`, and `flake-update-cascade` all consume it. Two consequences follow, both verified: a worktree placed under `~/work` is collected as if it were an ordinary repo, so `pull-all` attempts `git pull` on a branch with no upstream and reports an error; and a worktree placed anywhere else is invisible to `work-diff`, which is the whole cross-repo status view. Note that `workspace_is_repo_root` already accepts a linked worktree, since it tests `[[ -e "$dir/.git" ]]` and a worktree's `.git` is a file rather than a directory. Any fix therefore needs to distinguish a registry checkout from a linked worktree deliberately rather than relying on that test. ### Suggested shape Add a collector entry point that returns registry checkouts (today's behavior, used by `pull-all`, `flake-status`, and `flake-update-cascade`) and a second that returns each checkout's linked worktrees, used by `work-diff`. `git -C <repo> worktree list --porcelain` gives path, branch, and detached state in one call. Rendering worktrees indented under their repo keeps a repo's full state in one place in the output. ### Scope In: `lib/workspace.sh`, `workspace/work-diff`, and confirmation that `pull-all` and the flake tools keep operating on registry checkouts only, plus tests. Out: where worktrees are created, which is allod/tools#116.
vnprc closed this issue 2026-07-28 01:31:47 +01:00
Sign in to join this conversation.
No description provided.