Skip to content
Merged
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,16 +1442,18 @@ export class Task extends EventEmitter<ClineEvents> {
// could be in (i.e. could have streamed some tools the user
// may have executed), so we just resort to replicating a
// cancel task.
this.abortTask()

// Check if this was a user-initiated cancellation
// If this.abort is true, it means the user clicked cancel, so we should
// Check if this was a user-initiated cancellation BEFORE calling abortTask
// If this.abort is already 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))

// Now call abortTask after determining the cancel reason
this.abortTask()

await abortStream(cancelReason, streamingFailedMessage)

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