fix(task): skip saveClineMessages when history task aborts before messages load - #1181
Draft
edelauna wants to merge 1 commit into
Draft
fix(task): skip saveClineMessages when history task aborts before messages load#1181edelauna wants to merge 1 commit into
edelauna wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Related GitHub Issue
Closes: #1180
Description
resumeTaskFromHistory()starts with an async disk read (getSavedClineMessages). Until that read completes,clineMessagesis[].evictCurrentTask()callsabortTask(), which calledsaveClineMessages()→taskMetadata(). With an empty array,taskMetadata()writes theno_messagesplaceholder as the stored title, permanently overwriting the real one.On Windows,
ui_messages.jsonfiles can reach 17–20 MB (read_file payloads stored in clineMessages). With Defender real-time scanning, the read can take hundreds of milliseconds — wide enough for rapid history navigation to hit this window reliably. This is the "Work #1 (no message)" / "工作 #1 (無訊息)" bug reported against v3.76.0.Fix: guard in
abortTask()— if the task is a history task andclineMessagesis still empty, skipsaveClineMessages(). The on-disk data is already the correct source of truth at that point.This bug first appeared in v3.74.0 (PR #1014, subtask navigation buttons). v3.72.0 is not affected.
Test Procedure
Unit test (
src/core/task/__tests__/Task.resume-eviction-race.spec.ts):startTask: falsereadTaskMessagesdisk read open via a deferred promisetask.run()fire-and-forget (mirrorscreateTaskWithHistoryItem)task.abortTask(true)while the read is still pendingupdateTaskHistorywas not called with a title containing"no_messages"E2E smoke test (
apps/vscode-e2e/src/suite/resume-eviction-race.test.ts):Note: the e2e test cannot reliably trigger the race on Linux (disk reads complete in < 1 ms). The unit test is the regression anchor.
Pre-Submission Checklist
Additional Notes
A related open issue (#1021) guards
updateTaskHistoryagainst fire-and-forget saves on abandoned tasks (different race, same code path). That fix is pending onfeature/local-usage-stats. The two fixes are orthogonal and will not conflict.🤖 Generated with Claude Code