fix(task): update UI with final usage after stream completion (#7552)
Ensure the UI displays accurate token usage and costs by updating the API request message when the stream completes. This commit adds a call to updateApiReqMsg followed by saving messages and posting state to the webview, which occurs before finalizing tool calls. This ensures users see the final usage statistics (input/output tokens, cache tokens, and total cost) reflected in the interface immediately after stream processing.
This commit is contained in:
1 file changed
+14
@@ -2960,6 +2960,20 @@ export class Task {
|
||||
}
|
||||
}
|
||||
|
||||
// Update UI with final usage after stream is complete
|
||||
await updateApiReqMsg({
|
||||
messageStateHandler: this.messageStateHandler,
|
||||
lastApiReqIndex,
|
||||
inputTokens,
|
||||
outputTokens,
|
||||
cacheWriteTokens,
|
||||
cacheReadTokens,
|
||||
api: this.api,
|
||||
totalCost,
|
||||
})
|
||||
await this.messageStateHandler.saveClineMessagesAndUpdateHistory()
|
||||
await this.postStateToWebview()
|
||||
|
||||
// Finalize any remaining tool calls at the end of the stream
|
||||
if (this.useNativeToolCalls) {
|
||||
// For native tool calls, mark all pending tool uses as complete
|
||||
|
||||
Reference in new issue
Block a user