Commit 6d663a2
authored
* [refactor] Thread context.Context through parallel.Collect (#288)
Extend the Collect signature to accept a ctx and fn(ctx, i) so callers
can enforce per-item deadlines without reaching into captured variables.
All 7 production callers and the test suite updated; the two long-running
sites (deps install, mcp sync) pass ctx through without a deadline.
* [fix] Add git.WithItemTimeout to bound per-item git queries (#288)
Introduces a 10s per-item deadline helper that callers can apply to each
fan-out slot so a stalled worktree (e.g. NFS mount) cannot occupy a
parallel.Collect worker slot indefinitely.
* [fix] Add Unknown sentinel to WorktreeStatus for timed-out git queries (#288)
A worktree whose git queries time out (or fail due to a stalled NFS mount)
previously rendered as clean (✓) — indistinguishable from a healthy worktree.
Now CollectWorktreeStatus sets Unknown=true on any error, FormatStatus returns
"unknown", and colorStatus renders it gray. AheadBehind is updated to propagate
context.Canceled/DeadlineExceeded instead of silently swallowing it.
* [fix] Make fsutil.DirSize cancellable via context (#288)
DirSize now accepts a context.Context and runs the WalkDir in a goroutine
so a stalled syscall (NFS mount) cannot block past the deadline. Callers
in status_dashboard.go updated to thread ctx through; all existing tests
updated for the new signature, plus a cancellation path test.
* [fix] Apply per-item 10s timeout to all git status fan-out queries (#288)
Five parallel.Collect sites that query git per worktree now derive a bounded
context via git.WithItemTimeout before any git call. A stalled worktree
(NFS mount, hung git process) times out in ≤10s and renders as "unknown"
instead of hanging the fan-out indefinitely.
The two long-running sites (deps install, mcp sync) pass ctx through
unchanged — they must not get a 10s cap.
* [fix] Set context.Background() on test cobra commands (#288)
git.WithItemTimeout panics when passed a nil parent context. Test commands
created by newTestCmd() had no context set, so cmd.Context() returned nil.
* [fix] Address review feedback: clarify queryPRInfo ctx + test MCP unknown (#288)
Add comment explaining that queryPRInfo receives outer ctx (not itemCtx) because
it is a gh network call with its own prQueryTimeout, not a git query.
Add TestStatusToolUnknownWorktree to verify that a stalled NFS mount (all
runInDir calls failing) results in Unknown=true in the MCP status response
and is not miscounted as Dirty or Behind.
* [chore] Simplify and fix code comments from review feedback
- dirsize.go: clarify goroutine continues until OS returns (not cancelled)
- branch.go: condense AheadBehind context-propagation note to one line
- timeout.go: shorten itemQueryTimeout and WithItemTimeout comments
- status.go: shorten CollectWorktreeStatus doc to one line
- list_worktrees.go: condense queryPRInfo ctx comment to one line
* [fix] Address review feedback: ctx-aware semaphore, errors.Is, mcp filterDirty timeout
- parallel: make semaphore acquire ctx-aware (select on sem/ctx.Done) so
goroutines waiting on a full semaphore exit on cancellation rather than
blocking forever; add TestCollectCancelledContextDoesNotHang
- git/branch: switch AheadBehind ctx check to errors.Is(err, Deadline/Canceled)
so wrapped context errors are correctly propagated
- mcp/tool_exec: migrate filterDirty to parallel.Collect + git.WithItemTimeout,
closing the sixth unguarded parallel git fan-out site (#288)
* [fix] Address follow-up feedback: Unknown pass-through + Collect doc contract
- FilterDetailsByStatus: keep Unknown-status rows regardless of --dirty/--behind
filter flags so stalled worktrees are never silently excluded from list output;
add TestFilterDetailsByStatusUnknownPassthrough
- parallel.Collect: document that goroutines cancelled at the semaphore leave
the zero value of T at their result index
* [fix] Use ctx.Err() for timeout detection in AheadBehind (#288)
errors.Is(err, context.DeadlineExceeded/Canceled) never fires when
exec.CommandContext kills the process: CombinedOutput returns *exec.ExitError
(signal killed), not the context sentinel. Check ctx.Err() directly instead.
Also fix TestDirSizeCancelledContext (racy select assertion) and add omitempty
to Dirty/Ahead/Behind for consistent WorktreeStatus JSON schema.
1 parent fa2e69b commit 6d663a2
23 files changed
Lines changed: 350 additions & 80 deletions
File tree
- cmd
- internal
- deps
- fsutil
- git
- mcp
- operations
- parallel
- resolver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
270 | 272 | | |
271 | | - | |
| 273 | + | |
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | | - | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
13 | 36 | | |
14 | 37 | | |
15 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | | - | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
105 | 121 | | |
106 | 122 | | |
107 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments