Skip to content

fix(task): guard saveClineMessages against abandoned tasks (fixes #1021) - #32

Closed
easonLiangWorldedtech wants to merge 1 commit into
mainfrom
fix/abandoned-subtask-save-race-1021
Closed

fix(task): guard saveClineMessages against abandoned tasks (fixes #1021)#32
easonLiangWorldedtech wants to merge 1 commit into
mainfrom
fix/abandoned-subtask-save-race-1021

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Owner

Summary

Fixes Zoo-Code-Org#1021 (part of epic Zoo-Code-Org#1375).

Fire-and-forget saveClineMessages() calls could execute updateTaskHistory() after abandonSubtask's atomicUpdatePair() had already cleared parentTaskId/'rootTaskId`, silently reattaching the severed parent-child link.

Changes

  • src/core/task/Task.tssaveClineMessages() now checks this.abandoned before updateTaskHistory() and returns false when the task was abandoned. This catches both the explicit abort save and any in-flight fire-and-forget saves (the two un-awaited saveClineMessages().catch(...) call sites).
  • Per-task message persistence is unaffected: saveTaskMessages() still runs before the guard; only the (stale) history-item update is skipped, which is exactly the value that would reattach the severed link.

Provenance

This is the minimal upstream-main form of the fix developed on the feature/local-usage-stats branch (commit 1d1eb915e, "fix(task): guard saveClineMessages against abandoned tasks to prevent race in abandonSubtask"). That commit also carried formatting changes for usage-stats code that is not in main (the dashboard feature ships separately in Zoo-Code-Org#1225), so those hunks are deliberately excluded here — the behavioral fix is the guard itself.

Test

  • Regression test in Task.spec.ts (saveClineMessages abandoned guard (#1021)): an abandoned task's saveClineMessages() persists messages (saveTaskMessages called once) but never calls updateTaskHistory.
  • pnpm --dir src exec vitest run core/task/__tests__/Task.spec.ts → 101/101 passing.
  • ESLint clean; no suppression count changes.

…-Code-Org#1021)

Fire-and-forget saveClineMessages() calls could execute updateTaskHistory() after abandonSubtask's atomicUpdatePair() had already cleared parentTaskId/rootTaskId, silently reattaching the severed parent-child link.

Check this.abandoned before updateTaskHistory() to catch both the explicit abort save and any in-flight fire-and-forget saves. Per-task message persistence is unaffected: saveTaskMessages still runs, only the (stale) history-item update is skipped.

This is the minimal upstream-main form of the fix developed on the local-usage-stats branch (commit 1d1eb91); that commit's surrounding usage-stats changes are not part of main and are excluded. Regression test in Task.spec.ts: an abandoned task's saveClineMessages() persists messages but never calls updateTaskHistory().
@easonLiangWorldedtech

Copy link
Copy Markdown
Owner Author

opened as cross-repo upstream PR instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(task): guard saveClineMessages against abandoned tasks to prevent race in abandonSubtask

2 participants