Fix: Preserve chat history on task cancellation #3775
Draft
+120
−1
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.
closes #2537
jules test
Previously, canceling a running task could lead to the loss of the most recent chat history if it hadn't been saved immediately prior to cancellation.
This commit addresses the issue by ensuring that both the Cline messages (user-facing chat) and the API conversation history are explicitly saved at the beginning of the
abortTask
method insrc/core/task/Task.ts
. This guarantees that the latest state of the conversation is persisted before the task is fully terminated and its resources are released.An automated E2E test has been added to
e2e/src/suite/task.test.ts
to specifically verify this fix. The test simulates starting a task, sending messages, canceling the task, and then resuming it to assert that the chat history remains intact.Manual testing also confirmed that the chat history is correctly preserved after canceling and resuming a task.
Related GitHub Issue
Closes: #
Description
Test Procedure
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Fixes chat history loss on task cancellation by saving history at the start of
abortTask
inTask.ts
, with E2E test added for verification.clineMessages
andapiConversationHistory
at the start ofabortTask
inTask.ts
.task.test.ts
to verify chat history preservation on task cancellation and resumption.This description was created by
for dbf1c83. You can customize this summary. It will automatically update as commits are pushed.