Repository navigation
fix(worktrees): refresh cleanup scans and stabilize integration waits - #482
Merged
Merged
Conversation
Bypass cached Git output for ScanWorktrees so cleanup previews immediately reflect external file changes. Preserve process admission and safety checks. Wait for automation turns and commands to settle before delete or archive. Allow thread revision recovery and release fixture holds before parent question turns start; compare completed desktop and phone state. Fixes: #124 Related: #473, #478
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
The alias-checkout test can observe `threadReady` / `idle` before the `createThread` command acknowledgment is persisted. Its final branch switch can therefore correctly fail with “A thread is using this directory.” This is a fixture readiness race: holding that acknowledgment reproduced `idle` with a pending command and the exact refusal; releasing it allowed the switch. No product lock remained held after settlement. Add a shared fixture wait for idle, terminal turns and acknowledged admission commands, including checkout aliases without a worktree ID. Also wait for the worktree inventory to stop reporting busy and, for managed worktrees, provide a scan status. Reuse it in tree setup, branch switching, lifecycle/automation cleanup and local/linked external-worktree adoption. Poll only observations; branch-switch and post-delete/settings cleanup assertions remain direct, with no sleeps or mutation retries. Validation: - `thread-branches.test.ts`, sequential file runs: unchanged baseline 30/30; final version 30/30 (8 tests per run). The natural flake did not reproduce in the baseline; the acknowledgment-gated diagnostic reproduced its failure window. An earlier implementation also passed 30/30 before the external-worktree scan condition was corrected. - All 67 tests in 11 other fixture-consumer files passed, one file at a time, on the final version. - `bun run typecheck`, `bun run lint`, `bun run format:check` and `git diff --check` passed. - Full-suite `check:tmp`, generation checks and web build were not run locally in this focused verification scope. Based on `dev` after #482 merged. CI evidence: https://github.com/itsoltech/canopy/actions/runs/42792779962/attempts/1 Related: #481 Related: #482
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.
Cleanup previews could reuse Git output cached for one second by the process governor, showing a dirty checkout immediately after external changes were removed, or a clean checkout immediately after files were added.
ScanWorktreesnow uses the existingfreshGitboundary while preserving process admission, background priority and removal safety checks. The automation test warms the scan, changes files outside Canopy, and asserts immediate dirty → clean → dirty → clean results before cleanup. The worktree documentation describes this freshness guarantee.The worktree fixture also waited only for
thread.status === idle.threadReadycan set that before the automation turn or its command has settled. It now waits for the worktree's actual busy state before deleting or archiving; preview assertions immediately after delete/settings changes remain direct assertions, without retries. A controlled delayed-ack run reproduced the original refusal with clean Git state, a cancelled turn and a pendingstartTurn. The original CI log reports onlywouldRemove, so it cannot distinguish that refusal from stale scan state.The desktop/phone CI failure in run 42786085102, attempt 1, rejected a valid transient
syncingupdate after both clients' items and turns already matched. The test now waits for completion of the specific reply turn and convergence after recovery, with 100 ms revision probes exercising resubscriptions. Local baseline runs exposed another fixture race: after the parent interruption, its queued question turn could start whileholdTurnswas still enabled and block the final reply forever. Releasing the hold before ending the parent, then observing the question turn complete, removes that race. A controlled run reproduced the stuck interaction turn and queued final message. No production subscription behavior changes.Validation:
worktree-automation.test.tsthread-multiclient.test.tsEach file ran 30 times before and after, one file at a time. All 30 final phone runs exercised revision resubscription. The local baseline phone failure was the held-question timeout, distinct from CI's invalid no-syncing assertion. An intermediate readiness-only revision failed 8/8 worktree runs and exposed the cached Git result; those failures are excluded from the final counts.
bun install,bun run typecheck,bun run lint,bun run format:check, andgit diff --checkpassed. Verification was scoped to the requested integration files and static checks under the supplied execution limits; the full suite, generation check and web build were not run. Scratch logs and fault-injection diagnostics remain outside the repository and are not committed. No schema, proto, UI copy or UI test changes; copy audit is not applicable.Fixes: #124
Related: #473, #478