refactor: simplify postStateToWebview by removing incremental message delivery logic

This commit is contained in:
Daniel Riccio 2025-08-01 16:39:52 -05:00 committed by Roo Code
parent 26e0786ddc
commit 72bdae1acb

View file

@ -9,9 +9,6 @@ import axios from "axios"
import pWaitFor from "p-wait-for"
import * as vscode from "vscode"
// Small delay used for incremental message delivery to the webview
const INCREMENTAL_SEND_DELAY_MS = 10
import {
type TaskProviderLike,
type TaskProviderEvents,
@ -1561,26 +1558,7 @@ export class ClineProvider
async postStateToWebview() {
const state = await this.getStateToPostToWebview()
// Check if we're loading an existing task with messages
const currentCline = this.getCurrentCline()
const hasExistingMessages = currentCline && currentCline.clineMessages.length > 0
if (hasExistingMessages) {
// Send state without messages first
const stateWithoutMessages = { ...state, clineMessages: [] }
await this.postMessageToWebview({ type: "state", state: stateWithoutMessages })
// Then send messages incrementally with a small delay for smooth rendering
for (const message of currentCline.clineMessages) {
await this.postMessageToWebview({ type: "messageCreated", clineMessage: message })
// Small delay to prevent overwhelming the webview
await delay(INCREMENTAL_SEND_DELAY_MS)
}
} else {
// Normal state update for new tasks or tasks without messages
await this.postMessageToWebview({ type: "state", state })
}
await this.postMessageToWebview({ type: "state", state })
// Check MDM compliance and send user to account tab if not compliant
if (!this.checkMdmCompliance()) {