fix(task): guard saveClineMessages against abandoned tasks (fixes #1021) - #32
Closed
easonLiangWorldedtech wants to merge 1 commit into
Closed
fix(task): guard saveClineMessages against abandoned tasks (fixes #1021)#32easonLiangWorldedtech wants to merge 1 commit into
easonLiangWorldedtech wants to merge 1 commit into
Conversation
…-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().
Owner
Author
|
opened as cross-repo upstream PR instead |
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.
Summary
Fixes Zoo-Code-Org#1021 (part of epic Zoo-Code-Org#1375).
Fire-and-forget
saveClineMessages()calls could executeupdateTaskHistory()afterabandonSubtask'satomicUpdatePair()had already clearedparentTaskId/'rootTaskId`, silently reattaching the severed parent-child link.Changes
src/core/task/Task.ts—saveClineMessages()now checksthis.abandonedbeforeupdateTaskHistory()and returnsfalsewhen the task was abandoned. This catches both the explicit abort save and any in-flight fire-and-forget saves (the two un-awaitedsaveClineMessages().catch(...)call sites).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-statsbranch (commit1d1eb915e, "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 inmain(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
Task.spec.ts(saveClineMessages abandoned guard (#1021)): an abandoned task'ssaveClineMessages()persists messages (saveTaskMessagescalled once) but never callsupdateTaskHistory.pnpm --dir src exec vitest run core/task/__tests__/Task.spec.ts→ 101/101 passing.