Repository navigation
feat(worktrees): list worktrees git already has - #294
Merged
Merged
Conversation
Discover repository worktrees on their worker and register external entries only when a thread uses them. Keep external directories read-only in lifecycle operations and expose the merged list on web, mobile and linked computers.
nixuuu
added a commit
that referenced
this pull request
Nov 6, 2026
## Root cause A shared project (#168) is one overview row with every linked computer's workspaces. The routed overview merged them only in `GetOverview` and in updates **from the partner**. When this computer republished its **own** row of a shared project, the overview stream sent it with local workspaces only. Triggers include `coreBroadcastWorkers` on any worker change, renames, `projectsChanged` after a config sync and origin refreshes. Web and mobile upsert by id, so the merged row lost the partner's workspaces. A project that lives only on a linked computer then had `workspaces: []`, and the new-thread picker showed "No worker" and "… is not on any worker yet". I reproduced it with two linked gateways. A's `WatchOverview` emitted the shared project with `workspaces: []` right after A republished it. ## Fix - `apps/gateway/src/api/routed-overview.ts`: every update of a shared project goes out with all computers' workspaces, whether it came from this computer or a partner. A burst (for example, a worker change republishing every project) reads the overview once, 50 ms coalescing. If that read fails, the local row still goes out. Mobile is fixed by the same change. - `WorkerPicker.svelte`: - linked workers stay listed until the gateway capabilities load (before, they were briefly hidden); - workers on an unreachable computer are greyed out and disabled, with the presence reason, as on mobile; - the empty state says "<project>'s workers are not connected." when the project has workspaces. "not on any worker yet" now appears only when it is true. - `docs/linked-computers.md`: notes the merged stream updates. ## Verification - New `tests/integration/linked-new-thread.test.ts` (two linked gateways, separate databases): - A's overview stream keeps B's workspace after A republishes the shared project. This test fails without the fix. - B's worker is in A's overview and online. - A thread created from A on B's worker lives on B, in B's project. - Passed, each file run on its own: `linked-projects`, `config-sync-projects`, `worktrees`, `worktree-automation` and the db schema test. - Clean: `bun install`, `gen:check`, `typecheck`, `lint`, `format:check` and the web build. - `check:tmp`: 1517 pass, 3 fail. All 3 failures are in files `dev` (#294) changed while the run was in progress; all 3 pass when rerun on the rebased branch. - Browser, against three linked test gateways and a vite dev BFF: - wrk-ai only on "Mac-Studio-of-the-team": the picker shows that worker and the composer is ready (light, desktop); - pinpoint on two computers: grouped "This computer" / "Mac-Studio-of-the-team"; - an offline "Mac mini": its worker is greyed out and disabled with "Offline since …" (dark, iPhone 12 Pro width). ## Not in scope New worktrees on a linked computer's checkout stay refused on purpose (docs/worktrees.md, "Połączone komputery", stage 1). Supporting them needs gateway capability negotiation and is a separate feature. ## Copy audit (docs/copy.md §8) - New: "{project}'s workers are not connected." It is short and factual, and it replaces a false claim. No other text changed. Fixes: #168
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Projects with worktrees created outside Canopy now show those directories in the new-thread workspace picker on web and mobile. The list merges the worker's real Git inventory with Canopy's registry, keeps Current checkout once, and shows branch or detached HEAD, directory, provenance, and unavailable states. Settings also lists external worktrees with read-only controls.
Discovery and adoption
git worktree list --porcelain -z, with a 2-second bounded cache and a 3-second discovery deadline. Opening the picker refreshes it; selecting an entry bypasses the cache.external = truewith fixed branch naming. Existing live HEAD tracking then follows branch changes. Cleanup, removal, movement, and generated branch naming never manage external directories; migration 0092 protects their provenance and removal state.Compatibility
Protobuf additions include generated code.
WORKER_LINK_PROTOCOLremains 1: the additivegit_worktree_discoverycapability enables discovery, while older workers retain their registry list. Previously adopted external entries require an updated worker. Linked gateways negotiateremote_worktrees; a home without it refuses placement instead of silently using Current checkout.Verification
bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:check, the web build, andbun run --filter @canopy/mobile lint(Expo lint).bun run check:tmp: 1,549 passed, 158 skipped, 0 failed (1,707 tests across 277 files), with no test temporary directories left. Temporary data stayed under the worktree;GIT_CEILING_DIRECTORIESisolates non-repository fixtures from the enclosing checkout.check:tmprun: 9 tests passed, 45 assertions, no temporary directories left. Real Git + worker/gateway/Postgres integration covers normal, detached, locked and prunable worktrees; fresh selection; actual thread cwd; live branch changes; cleanup/removal/renaming protections; owner/repository scoping; symlinked managed roots; and linked gateways including capability skew.Copy audit
Checked all ten items in
docs/copy.md§8: sentence case, glossary, action verbs, actionable discovery errors, concise empty states, no repeated provenance, explicit compatibility action, no added personality copy, short/long text at both widths, and textual state cues. Expanded the worktree glossary to include externally created worktrees.