You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If this Cline instance was aborted by the provider, then the only thing keeping us alive is a promise still running in the background, in which case we don't want to send its result to the webview as it is attached to a new instance of Cline now. So we can safely ignore the result of any active promises, and this class will be deallocated. (Although we set Cline = undefined in provider, that simply removes the reference to this instance, but the instance is still alive until this promise resolves or rejects.)
274
+
// If this Cline instance was aborted by the provider, then the only thing keeping us alive is a promise
275
+
// still running in the background, in which case we don't want to send its result to the webview as it is
276
+
// attached to a new instance of Cline now. So we can safely ignore the result of any active promises, an
277
+
// this class will be deallocated. (Although we set Cline = undefined in provider, that simply removes the
278
+
// reference to this instance, but the instance is still alive until this promise resolves or rejects.)
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
901
+
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't
902
+
// streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry
903
+
// button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may
904
+
// have executed, so that error is handled differently and requires cancelling the task entirely.
888
905
if(alwaysApproveResubmit){
889
906
consterrorMsg=error.message??"Unknown error"
890
907
constrequestDelay=requestDelaySeconds||5
@@ -920,8 +937,10 @@ export class Cline {
920
937
}
921
938
922
939
// no error, so we can continue to yield all remaining chunks
923
-
// (needs to be placed outside of try/catch since it we want caller to handle errors not with api_req_failed as that is reserved for first chunk failures only)
924
-
// this delegates to another generator or iterable object. In this case, it's saying "yield all remaining values from this iterator". This effectively passes along all subsequent chunks from the original stream.
940
+
// (needs to be placed outside of try/catch since it we want caller to handle errors not with api_req_failed
941
+
// as that is reserved for first chunk failures only)
942
+
// this delegates to another generator or iterable object. In this case, it's saying "yield all remaining values
943
+
// from this iterator". This effectively passes along all subsequent chunks from the original stream.
// console.log("no more content blocks to stream! this shouldn't happen?")
946
966
this.presentAssistantMessageLocked=false
947
967
return
948
-
//throw new Error("No more content blocks to stream! This shouldn't happen...") // remove and just return after testing
968
+
// remove and just return after testing
969
+
// throw new Error("No more content blocks to stream! This shouldn't happen...")
949
970
}
950
971
951
972
constblock=cloneDeep(this.assistantMessageContent[this.currentStreamingContentIndex])// need to create copy bc while stream is updating the array, it could be updating the reference block properties too
973
+
952
974
switch(block.type){
953
975
case"text": {
954
976
if(this.didRejectTool||this.didAlreadyUseTool){
@@ -1072,7 +1094,7 @@ export class Cline {
1072
1094
}else{
1073
1095
this.userMessageContent.push(...content)
1074
1096
}
1075
-
// once a tool result has been collected, ignore all other tool uses since we should only ever present one tool result per message
1097
+
// once a tool result has been collected, ignore all other tool uses since we should only everpresent one tool result per message
When you see the UI inactive during this, it means that a tool is breaking without presenting any UI. For example the write_to_file tool was breaking when relpath was undefined, and for invalid relpath it never presented UI.
2545
2579
*/
2546
2580
this.presentAssistantMessageLocked=false// this needs to be placed here, if not then calling this.presentAssistantMessage below would fail (sometimes) since it's locked
2581
+
2547
2582
// NOTE: when tool is rejected, iterator stream is interrupted and it waits for userMessageContentReady to be true. Future calls to present will skip execution since didRejectTool and iterate until contentIndex is set to message length and it sets userMessageContentReady to true itself (instead of preemptively doing it in iterator)
// getting verbose details is an expensive operation, it uses globby to top-down build file structure of project which for large projects can take a few seconds
2640
+
// getting verbose details is an expensive operation, it uses globby to top-down build file structure of project
2641
+
// which for large projects can take a few seconds
2606
2642
// for the best UX we show a placeholder api_req_started message with a loading spinner as this happens
// since we sent off a placeholder api_req_started message to update the webview while waiting to actually start the API request (to load potential details for example), we need to update the text of that message
2658
+
// since we sent off a placeholder api_req_started message to update the webview while waiting to actually start
2659
+
// the API request (to load potential details for example), we need to update the text of that message
// update api_req_started. we can't use api_req_finished anymore since it's a unique case where it could come after a streaming message (ie in the middle of being updated or executed)
2638
-
// fortunately api_req_finished was always parsed out for the gui anyways, so it remains solely for legacy purposes to keep track of prices in tasks from history
2639
-
// (it's worth removing a few months from now)
2674
+
// update api_req_started. we can't use api_req_finished anymore since it's a unique case where it could
2675
+
// come after a streaming message (ie in the middle of being updated or executed)
2676
+
// fortunately api_req_finished was always parsed out for the gui anyways, so it remains solely for legacy
2677
+
// purposes to keep track of prices in tasks from history (it's worth removing a few months from now)
conststream=this.attemptApiRequest(previousApiReqIndex)// yields only if the first chunk is successful, otherwise will allow the user to retry the request (most likely due to rate limit error, which gets thrown on the first chunk)
2751
+
// yields only if the first chunk is successful, otherwise will allow the user to retry the request (most
2752
+
// likely due to rate limit error, which gets thrown on the first chunk)
0 commit comments