Skip to content

Commit 2eb586b

Browse files
roomote[bot]ellipsis-dev[bot]roomotedaniel-lxs
authored
fix: properly distinguish between user cancellations and API failures (#6025)
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Roo Code <[email protected]> Co-authored-by: Daniel <[email protected]>
1 parent 464a3ff commit 2eb586b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/task/Task.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,16 +1442,18 @@ export class Task extends EventEmitter<ClineEvents> {
14421442
// could be in (i.e. could have streamed some tools the user
14431443
// may have executed), so we just resort to replicating a
14441444
// cancel task.
1445-
this.abortTask()
14461445

1447-
// Check if this was a user-initiated cancellation
1448-
// If this.abort is true, it means the user clicked cancel, so we should
1446+
// Check if this was a user-initiated cancellation BEFORE calling abortTask
1447+
// If this.abort is already true, it means the user clicked cancel, so we should
14491448
// treat this as "user_cancelled" rather than "streaming_failed"
14501449
const cancelReason = this.abort ? "user_cancelled" : "streaming_failed"
14511450
const streamingFailedMessage = this.abort
14521451
? undefined
14531452
: (error.message ?? JSON.stringify(serializeError(error), null, 2))
14541453

1454+
// Now call abortTask after determining the cancel reason
1455+
await this.abortTask()
1456+
14551457
await abortStream(cancelReason, streamingFailedMessage)
14561458

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

0 commit comments

Comments
 (0)