Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1417,10 +1417,15 @@ export class Task extends EventEmitter<ClineEvents> {
// cancel task.
this.abortTask()

await abortStream(
"streaming_failed",
error.message ?? JSON.stringify(serializeError(error), null, 2),
)
// Check if this was a user-initiated cancellation
// If this.abort is true, it means the user clicked cancel, so we should
// treat this as "user_cancelled" rather than "streaming_failed"
const cancelReason = this.abort ? "user_cancelled" : "streaming_failed"
const streamingFailedMessage = this.abort
? undefined
: (error.message ?? JSON.stringify(serializeError(error), null, 2))

await abortStream(cancelReason, streamingFailedMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to correctly handle the inconsistent cancellation message. I'm curious if there are any existing tests that cover this scenario, or if we could add a new one to ensure this behavior is protected against regressions?


const history = await provider?.getTaskWithId(this.taskId)

Expand Down
Loading