Repository navigation
feat(worktrees): create threads in git worktrees - #74
Merged
Merged
Conversation
nixuuu
force-pushed
the
feat/worktrees-1
branch
from
November 4, 2026 18:59
efe85a9 to
32a06ab
Compare
nixuuu
marked this pull request as ready for review
November 4, 2026 19:02
nixuuu
added a commit
that referenced
this pull request
Nov 4, 2026
…ead (#82) Stage 2 of git worktree support (on top of #74). - Cleanup policies in Settings → Worktrees with the stage 1 scopes: with deleted threads, merged branches (git ancestry after fetch), inactive for N days, settled threads, only unchanged worktrees vs. keeping those with local changes. Dirty or unpushed worktrees are never removed without explicit confirmation. - Cleanup engine on the gateway schedule, executed on the owning worker; dry-run preview in Settings; every removal audited; durable retries when the worker is offline; path containment (never the main checkout or anything outside worktree roots). - Per-worktree status (branch, ahead/behind, dirty files, last activity) and actions (copy path / reveal, remove) from the thread and a Worktrees list in Settings. - Composer picker row now wraps as a group with aligned controls at desktop and phone widths. - Migration `0065` (both worktree migrations will be renumbered after #75's `0064` before the stack merges). Known gap: squash-merged branches are not detected as merged by git ancestry; handled in the next stage. Checks: install, gen:check, typecheck, lint, format:check, check:tmp (972 pass, 152 skip, 0 fail), web build. Browser checked light/dark at desktop and phone widths. Draft until the whole stack is done.
nixuuu
added a commit
that referenced
this pull request
Nov 4, 2026
…109) Settings → Worktrees: changing **Branch naming** and pressing **Reset** showed `cannot encode enum canopy.ui.v1.BranchNaming to JSON: expected number, got undefined`. Reset sends `undefined` to inherit a field. That works for the `optional` fields, but `branch_naming` and `default_mode` are plain proto enums: inheriting means their unspecified value (0), and `undefined` can't be serialised. Resets of these two fields are now written as `UNSPECIFIED`; every other field is unchanged. No other settings page uses this reset pattern. Checks: web typecheck, lint, format. Fixes: #74
nixuuu
added a commit
that referenced
this pull request
Nov 6, 2026
Stage 3 of 4, mobile parity round 2: where a thread runs.
**Changed**
- **Linked computers:** the overview state keeps `computers` and handles
`computer`, `computer_removed` and `computer_snapshot`. The phone's
snapshot already carries the linked computers' workers, projects and
threads.
- **Worker picker** of a new thread, as on the web:
- workers grouped by computer: "This computer" first, then linked
computers by name;
- a worker on a linked computer this one cannot reach is greyed out with
its status ("Unreachable") and reason ("Studio Mac is unreachable since
6:45 AM.");
- the worker pill shows "worker · computer" for a linked one, and the
blocker uses the same reason.
- The presence rules (`computerName`, `sharesThreads`, `awayReason`, …)
move from the web to `@canopy/domain/computer-presence`, and the web
imports them from there. The web formats times with its own clock
settings.
- **Worktrees** (as #74, #82, #90): when the worker offers worktrees and
the folder is a git repository (`ListGitRefs`), the new thread shows:
- a workspace pill: Current checkout, New worktree, or a previous
worktree;
- the branch: read-only for the checkout and earlier worktrees, a base
ref picker (Branches, Remote branches) for a new worktree.
- The worktree settings' default mode applies until you pick.
`CreateThread` gets `workspace_mode`, `base_ref` and `worktree_id`.
**Checked**
- Gates clean, as in stage 1. Web typecheck covers the moved presence
rules.
- Android emulator, light and dark, unfolded and phone width:
- workspace and base ref pickers with a long branch name, against a
scripted worker that lists refs;
- the worker picker grouped by computer, with one reachable and one
unreachable linked computer. These came from overview data injected
locally for the check; no real link between two gateways.
- **Not checked on the device:** creating a thread in a new worktree end
to end (the scripted worker reports no agents for new threads).
**Copy audit (§8)**
- "This computer", "Unreachable" and the reasons ("‹Name› is unreachable
since 7:42 PM."): the web's text.
- "Workspace", "Current checkout", "Works in the project's directory",
"New worktree", "A new branch in its own directory", "Previous
worktrees", "Created 2 days ago", "Base ref", "Branches", "Remote
branches", "Default", "Current": from the web pickers.
This was referenced Nov 13, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 17, 2026
## Change Creating a thread with a new worktree can fail with “git exceeded its time or output limit” when checking out a large repository, especially on Windows. Give `git worktree add` a dedicated 60-second limit instead of the 15-second limit for Git metadata reads. Quiet mode suppresses progress output while preserving errors. The optional fetch keeps its 20-second limit, within the gateway's existing 90-second wait. Update the worktrees documentation and add a real gateway–worker regression test with a 16-second checkout hook that verifies the resulting thread, files, and HEAD. ## Verification - `bun run check:tmp ./tests/integration/worktrees.test.ts`: 16 passed, including the slow checkout; no temporary files left. Used a separate temporary directory because the system temporary directory reached its quota. - `bun run lint -- apps/worker/src/git/worktrees.ts tests/integration/worktrees.test.ts`: passed. - Edited TypeScript files formatted; `git diff --check`: passed. - Local verification ran on Linux. Windows confirmation and the full verification gate remain with CI. - No UI text changed; copy audit does not apply. Fixes: #74
nixuuu
added a commit
that referenced
this pull request
Nov 18, 2026
## What changed - Report Git timeouts, output-limit failures and nonzero checkout exits separately. Keep raw command output out of the new checkout errors and map worker and link failures to fixed messages in `spawn_thread`. - Mark the new branch and the temporary Git worktree lock with the same attempt ID. After a failed checkout, remove only a matching worktree and the unchanged, unused branch created by this attempt. Preserve the original failure and report when cleanup is incomplete. - Verify that rollback waits for the process to close and for the attempt to stop its descendants to finish. Keep the 60 s checkout and 90 s gateway budgets. A gateway deadline or disconnect can still leave the outcome unconfirmed, so the agent prompts the caller to check before retrying. The report involved a Windows 11 checkout of about 58,000 tracked files with CRLF conversion and Git LFS. Both reported nightly.70 and the edited report's nightly.74 already include the 60 s checkout limit. The original error alone cannot distinguish elapsed time from excess output. The fixtures reproduce those failure paths with real Git on Linux. The original Windows checkout and its initiating cause remain unverified. A longer checkout budget would need corresponding worker, gateway and client deadline changes based on that evidence. ## Verification - Verified PR head `dc73d853` on `nix-pc` (Linux, Bun 1.4.4, Git 2.56.0). Ran `check:tmp` on the worker worktree tests and five integration files covering worktrees, creation progress, creation failures, automation and the process governor. Also ran the worker's device preview key tests. In all, 51 passed, zero failed, and no temporary test files were left. - The tests exercise a checkout filter that times out before completing, a hook that exceeds output capture, a hook that exits nonzero, a successful retry with the same branch name, a ref modified during checkout, preservation of pre-existing worktrees and refs, both gRPC callers, and an older worker that reports the two limits under one code. - A generated 58,000-file CRLF checkout completed and unlocked in 2.14 s on Linux. The fixture used small files and had no LFS filters. - The prior CI run failed in [Tests (6/8)](https://github.com/itsoltech/canopy/actions/runs/44361247730/job/135003276782) because device preview depended on the shared process error text. The runner now preserves that text and exposes the precise reason to Git. The existing device preview assertions passed locally. - Affected worker, gateway and process-governor typechecks, edited-file lint and formatting, and `git diff --check` passed. Full verification runs in CI. - Copy audit (§8). The ambiguous limit message now identifies time or output, checkout failure names Git settings and filters, and an incomplete rollback tells the user what to check. New messages use static sentence-case text without dynamic paths or names. The creation step and retry were tested through the UI's gRPC API. No browser or Windows runtime verification. Fixes: #74 Fixes: #90 Fixes: #124
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.
Stage 1 of git worktree support (modelled on T3 Code).
0064_worktrees. Design and stage plan:docs/worktrees.md.Next stages: cleanup policies; status/open/remove actions; worktrees for agent spawning, bots and schedules; linked-computer support.
Checks: install, gen:check, typecheck, lint, format:check, check:tmp (954 pass, 152 skip, 0 fail; 15 worktree integration scenarios), web build. Browser checked light/dark at desktop and phone widths.
Draft until the whole stack is done.