MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / abortStream

Method abortStream

src/core/task/Task.ts:2680–2702  ·  view source on GitHub ↗
(cancelReason: ClineApiReqCancelReason, streamingFailedMessage?: string)

Source from the content-addressed store, hash-verified

2678 }
2679
2680 const abortStream = async (cancelReason: ClineApiReqCancelReason, streamingFailedMessage?: string) => {
2681 if (this.diffViewProvider.isEditing) {
2682 await this.diffViewProvider.revertChanges() // closes diff view
2683 }
2684
2685 // if last message is a partial we need to update and save it
2686 const lastMessage = this.clineMessages.at(-1)
2687
2688 if (lastMessage && lastMessage.partial) {
2689 // lastMessage.ts = Date.now() DO NOT update ts since it is used as a key for virtuoso list
2690 lastMessage.partial = false
2691 // instead of streaming partialMessage events, we do a save and post like normal to persist to disk
2692 }
2693
2694 // Update `api_req_started` to have cancelled and cost, so that
2695 // we can display the cost of the partial stream and the cancellation reason
2696 updateApiReqMsg(cancelReason, streamingFailedMessage)
2697 await this.saveClineMessages()
2698
2699 // Signals to provider that it can retrieve the saved messages
2700 // from disk, as abortTask can not be awaited on in nature.
2701 this.didFinishAbortingStream = true
2702 }
2703
2704 // Reset streaming state for each new API request
2705 this.currentStreamingContentIndex = 0

Callers

nothing calls this directly

Calls 2

saveClineMessagesMethod · 0.95
revertChangesMethod · 0.80

Tested by

no test coverage detected