Skip to content

fix(task): skip saveClineMessages when history task aborts before messages load - #1181

Draft
edelauna wants to merge 1 commit into
mainfrom
fix/resume-eviction-title-clobber
Draft

fix(task): skip saveClineMessages when history task aborts before messages load#1181
edelauna wants to merge 1 commit into
mainfrom
fix/resume-eviction-title-clobber

Conversation

@edelauna

@edelauna edelauna commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #1180

Description

resumeTaskFromHistory() starts with an async disk read (getSavedClineMessages). Until that read completes, clineMessages is []. evictCurrentTask() calls abortTask(), which called saveClineMessages()taskMetadata(). With an empty array, taskMetadata() writes the no_messages placeholder as the stored title, permanently overwriting the real one.

On Windows, ui_messages.json files 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 and clineMessages is still empty, skip saveClineMessages(). 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):

  • Constructs a history task with startTask: false
  • Holds the readTaskMessages disk read open via a deferred promise
  • Calls task.run() fire-and-forget (mirrors createTaskWithHistoryItem)
  • Calls task.abortTask(true) while the read is still pending
  • Asserts updateTaskHistory was not called with a title containing "no_messages"

E2E smoke test (apps/vscode-e2e/src/suite/resume-eviction-race.test.ts):

  • Runs a task to completion, then resumes and immediately evicts it
  • Asserts the stored title is unchanged after the round-trip

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

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): Not applicable — no UI changes.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Additional Notes

A related open issue (#1021) guards updateTaskHistory against fire-and-forget saves on abandoned tasks (different race, same code path). That fix is pending on feature/local-usage-stats. The two fixes are orthogonal and will not conflict.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac344e09-edb3-4f89-a9fb-5e6957337101

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edelauna edelauna changed the title fix(task): skip saveClineMessages when history task aborts before mes… fix(task): skip saveClineMessages when history task aborts before messages load Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

[BUG] Task titles corrupt to "Work #1 (no message)" after rapid history navigation

1 participant