Преглед изворни кода

Fixes #4903: Consistent cancellation error messages for thinking vs streaming phases (#4904)

Co-authored-by: Daniel <[email protected]>
roomote пре 6 месеци
родитељ
комит
fb711a097c
1 измењених фајлова са 9 додато и 4 уклоњено
  1. 9 4
      src/core/task/Task.ts

+ 9 - 4
src/core/task/Task.ts

@@ -1425,10 +1425,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)
 
 					const history = await provider?.getTaskWithId(this.taskId)