Commit 28a6200
* fix: clear terminalEventSeen on task restart to prevent stuck-after-planning (#1828)
The terminalEventSeen Set in TaskStateManager was never cleared when a task
was restarted. When spec_runner.py emits PLANNING_COMPLETE, the taskId is
added to terminalEventSeen. If the subsequent coding process (run.py) fails,
handleProcessExited() returns early because terminalEventSeen.has(taskId)
is true, silently swallowing the PROCESS_EXITED event. The XState actor
never transitions, leaving the task permanently stuck in 'coding' state.
Additionally, lastSequenceByTask from the old process would cause events
from a new process (starting at sequence 0) to be dropped as duplicates.
Fix: Add prepareForRestart(taskId) method that clears both terminalEventSeen
and lastSequenceByTask without stopping the XState actor. Call it in all 4
locations where a new agent process is started:
- TASK_START handler
- TASK_STOP handler (so subsequent restart works)
- TASK_UPDATE_STATUS auto-start path
- TASK_RECOVER_STUCK auto-restart path
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add prepareForRestart to TASK_REVIEW rejection path
Add missing prepareForRestart(taskId) call before startQAProcess() in the
TASK_REVIEW rejection handler. This is the 5th location where a new agent
process is started for an existing task, but was missed in the original fix.
Without this, if the QA fixer process crashes after a review rejection,
terminalEventSeen would cause handleProcessExited() to swallow the exit
event, leaving the task permanently stuck.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fb3a3fb commit 28a6200
2 files changed
Lines changed: 27 additions & 0 deletions
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
| |||
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
363 | 371 | | |
364 | 372 | | |
365 | 373 | | |
| |||
529 | 537 | | |
530 | 538 | | |
531 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
532 | 543 | | |
533 | 544 | | |
534 | 545 | | |
| |||
703 | 714 | | |
704 | 715 | | |
705 | 716 | | |
| 717 | + | |
| 718 | + | |
706 | 719 | | |
707 | 720 | | |
708 | 721 | | |
| |||
1133 | 1146 | | |
1134 | 1147 | | |
1135 | 1148 | | |
| 1149 | + | |
| 1150 | + | |
1136 | 1151 | | |
1137 | 1152 | | |
1138 | 1153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| |||
0 commit comments