Repository navigation
fix(worktrees): recover failed checkouts and report the cause - #982
Merged
Merged
Conversation
nixuuu
enabled auto-merge (squash)
November 18, 2026 17:37
nixuuu
disabled auto-merge
November 18, 2026 17:38
nixuuu
enabled auto-merge (squash)
November 18, 2026 17:40
nixuuu
disabled auto-merge
November 18, 2026 17:46
nixuuu
enabled auto-merge (squash)
November 18, 2026 17:48
nixuuu
added a commit
that referenced
this pull request
Nov 19, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 19, 2026
## What changed - Reserve the checkout folder before Git starts. Verify its filesystem identity, exact registration, attempt-specific lock, branch reflog and base commit before rollback. On Windows, compare directory identity when Git and Bun use different 8.3 and long spellings of the path. - Recover a stopped checkout with an empty `index.lock` and no index or checkout `.git`. Require confirmation that termination completed before rollback on a timeout. Check the remaining files against Git blobs without invoking repository filters. - Remove only verified files and the attempt's registration. Compare the branch tip before deleting the unused attempt ref. Preserve unrelated and stale registrations, changed or untracked files, links, and an index lock containing data. ## Verification - Verified final PR head `b0098b9e` on nix-pc (Linux, Git 2.56.0, Bun 1.4.4). `check:tmp` passed 37 tests across checkout failures, process termination, folder allocation, thread creation progress and worktree automation. There were no remaining temporary fixtures. Affected package typechecks, edited-file lint and `git diff --check` passed. The local test run allowed 20 s per test after an earlier combined automation run exceeded its 5 s test budget. - An earlier local scale simulation used real Git and 56,757 tracked paths with small CRLF files and no LFS. The fixture removed the backlink and deliberately stalled after 22,067 files appeared. The attempt directory, registration and ref were removed. Git returned the original timeout in 8.76 s with a 6 s test checkout limit. - [Windows 2025 regression](https://github.com/itsoltech/canopy/actions/runs/44524227418/job/135560760665) passed in a temporary job on `54e04f85` with Git 2.56.1.windows.1 (6 passed, 4 POSIX-only cases skipped). Native Git creates the registration and the fixture then models the reported stopped state. The test verified removal, an immediate retry, and protection of unrelated registrations, files, junctions and a populated index lock. An MSYS filter in the initial runner attempts outlived the configured checkout deadline. Linux tests cover the full timeout-to-cleanup sequence. The reporter's Windows 11 desktop and original repository were not used. The final head removes the temporary job. The worker code, test code and pinned dependencies are identical to the Windows-verified revision. - Copy audit (§8). Existing warning and timeout wording is retained. Reservation failures use fixed sentences and omit paths, credentials and raw Git output. Fixes: #982
nixuuu
added a commit
that referenced
this pull request
Nov 21, 2026
Report the applied checkout limit and measured time at the interruption request. Preserve sanitized refusals for other worker errors. Related: #982
nixuuu
added a commit
that referenced
this pull request
Nov 21, 2026
## What changed - Show the effective checkout limit and the measured time when the Git timeout triggers. The measurement ends when Canopy requests interruption, before it waits for process exit or starts cleanup. - Carry the detail through the existing thread preparation errors and `spawn_thread`. The gateway accepts only the fixed timeout wording and numeric durations for `spawn_thread`. Unmeasured timeouts, output limits, other Git errors and worker RPC deadlines keep their existing messages. - The checkout limit policy and cleanup logic stay as before. Thanks @janek-normalnie for reporting the interrupted Windows checkout and suggesting both values. Related: #982 ## Verification - Local on nix-pc after rebasing onto #1071, at `86fa1f0685dedbc1871251fb1d70ebdc923ba288`: 53 tests passed with `check:tmp` across process governor, worktree creation failures, worktree automation, thread creation progress and worktrees. This covers 1.5 s and 3.5 s limits, a deliberately delayed timeout callback, a real checkout timeout through the worker link to the UI stream, saved failure and `spawn_thread`, redaction and distinct failure messages, and a successful checkout past the old 90-second worker deadline. - Integration test typecheck, lint and formatting of edited TypeScript, and the Git diff check passed. - Chromium, before the rebase: started a new worktree in an isolated dev stack and confirmed both values under **Show details**. Checked short, typical and long durations at 390 and 800 px in both themes, plus the actual flow at desktop width. The existing composer intercepted a pointer click at 1280 × 577. Keyboard activation opened the disclosure. - Native mobile receives the same failure through `CreateThreadWithProgress` and renders its detail in **Show details**. Verified the stream and traced the native code path. Manual Android verification was unavailable because device automation could not establish ownership of the emulator. - GitHub CI owns the full gate. ## Copy audit “Git exceeded its time limit.” → “Git timed out after 60.012 s while creating the worktree. The limit was 60 s.” Two short sentences name the operation and the limit. The existing failure instructions and **Return to draft** action stay available. The detail uses the existing disclosure, worktree terminology and spaced time units. All durations wrap in the checked widths, and no meaning depends on color or icons.
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.
What changed
spawn_thread.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
dc73d853onnix-pc(Linux, Bun 1.4.4, Git 2.56.0). Rancheck:tmpon 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.git diff --checkpassed. Full verification runs in CI.Fixes: #74
Fixes: #90
Fixes: #124