Repository navigation
Poll archived worker PRs and wake their lead; never reclaim a running worktree (#1431) - #1607
Conversation
… worktree (#1431) sweepCrew archives finished workers while their PRs are still open, and the PR refresher skipped archived threads, so worker PRs stayed OPEN in the store forever and their worktrees were never reclaimed. - isPrRefreshCandidate keeps archived threads; terminal states still drop out. - prWatch.wakeTarget: an archived worker never wakes itself. Its live lead gets the [pr watch] line naming the worker, with a thread_send hint and merging left to the user. Archived non-workers, or workers whose lead is archived/trashed, refresh state only. - maybeCleanupMergedWorktree refuses while the thread is working or quota-wait and queues the id; the next refresher pass retries it without gh. Covers both the refresher and the in-app merge path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5de8ff284
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * @returns {string | null} | ||
| */ | ||
| function wakeTarget(store, thread) { | ||
| if (!isWatched(thread)) return null; |
There was a problem hiding this comment.
Skip deleted workers when choosing a wake target
When an auto-archived worker is subsequently moved to Recently deleted, trashThread preserves its archived, orchWorker, and handoffFrom fields, so this still returns the live lead because only the lead's trashedAt is checked. A later PR failure can therefore start an unsolicited turn on the lead instructing it to contact a worker that thread_send will reject as deleted (electron/crossThread.js:95). Treat a trashed source worker as having no wake target.
Useful? React with 👍 / 👎.
Fixes #1431.
Why
sweepCrewarchives finished workers while their PRs are still open, and the background PR refresher skipped archived threads (if (t.archived) return false). Worker PRs therefore stayedOPENin the store forever, their worktrees were never reclaimed, and the PR watch never saw them. In the live store, 23 archived rows with a PR number are still non-terminal, and every Solenta PR I checked among them is actually merged on GitHub.Separately,
maybeCleanupMergedWorktreechecked for a dirty tree but not for a live run. A worker with a clean tree could lose its checkout mid-run when its PR merged.What
Most of the issue's design had already shipped as
electron/prWatch.js(#1493 D), so this PR is small.Poll archived threads.
isPrRefreshCandidatekeeps archived threads. Terminal states still drop out, so each one costs polls only until it merges or closes.Wake the lead, not the archived worker. New
prWatch.wakeTarget()decides who a PR alert goes to:The relayed line names the worker and ends with "Send it the fix with thread_send (threadId …); merging stays with the user." Wake state and the 3-wake cap stay on the worker.
Never reclaim a running worktree.
maybeCleanupMergedWorktreerefuses while the thread isworkingorquota-waitand queues it. The next refresher pass retries it without callinggh, because a MERGED thread has already left the candidate set. The guard covers the refresher and the in-app merge path alike.Checked
src/threadSettle.ts), not from a message timestamp.[pr watch]turns can't block settling.prWatchState, so on first sight they record a baseline and wake nobody;Left out
Tests
pr-refresh: an archived row refreshes to MERGED with plain fields and no wake.pr-watch: unit coverage of the relay wording and targets, plus an end-to-end refresher test that wakes the lead.worktree-cleanup: a running thread defers, the retry needs nogh, and the worktree is reclaimed once the run ends.Each new test fails when the old behaviour is restored. The three suites pass 69/69 on this branch. The full electron suite in a CI-like env (all
CODER_*vars unset) gives 4660 pass / 2 fail, and both failures (automation-create-mcpGitHub trigger shape,storeround-trip) reproduce on clean main.🤖 Generated with Claude Code