Repository navigation
feat(worktrees): use worktrees for agents, bots and schedules - #90
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 4, 2026 19:02
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 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 3 (final for now) of git worktree support, on top of #82.
spawn_thread), bots running code tasks and scheduled tasks follow the scoped worktree settings, with an explicit option (current checkout / new worktree / inherit). Side threads inherit their parent's worktree by default. Cleanup policies cover them.0068_worktree_automation. The whole stack was rebased onto current dev with migrations 0066–0068.Known limitation: if thread creation fails after its worktree was created, the worktree stays on disk until cleanup.
Checks per stage: install, gen:check, typecheck, lint, format:check, shard check. Top: check:tmp (1,035 pass, 153 skip, 0 fail), web build; composer and Settings → Worktrees checked in light/dark at desktop and phone widths.