File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -562,7 +562,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
562562 private async addToClineMessages ( message : ClineMessage ) {
563563 this . clineMessages . push ( message )
564564 const provider = this . providerRef . deref ( )
565- await provider ?. postStateToWebview ( )
565+ // Send only the new message instead of the entire state
566+ await provider ?. postMessageToWebview ( { type : "messageCreated" , clineMessage : message } )
566567 this . emit ( RooCodeEventName . Message , { action : "created" , message } )
567568 await this . saveClineMessages ( )
568569
@@ -1172,6 +1173,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
11721173 // the task first.
11731174 this . apiConversationHistory = await this . getSavedApiConversationHistory ( )
11741175
1176+ // Send initial state to webview (this will now handle incremental message loading)
1177+ await this . providerRef . deref ( ) ?. postStateToWebview ( )
1178+
11751179 const lastClineMessage = this . clineMessages
11761180 . slice ( )
11771181 . reverse ( )
Original file line number Diff line number Diff line change @@ -1550,7 +1550,26 @@ export class ClineProvider
15501550
15511551 async postStateToWebview ( ) {
15521552 const state = await this . getStateToPostToWebview ( )
1553- this . postMessageToWebview ( { type : "state" , state } )
1553+
1554+ // Check if we're loading an existing task with messages
1555+ const currentCline = this . getCurrentCline ( )
1556+ const hasExistingMessages = currentCline && currentCline . clineMessages . length > 0
1557+
1558+ if ( hasExistingMessages ) {
1559+ // Send state without messages first
1560+ const stateWithoutMessages = { ...state , clineMessages : [ ] }
1561+ await this . postMessageToWebview ( { type : "state" , state : stateWithoutMessages } )
1562+
1563+ // Then send messages incrementally with a small delay for smooth rendering
1564+ for ( const message of currentCline . clineMessages ) {
1565+ await this . postMessageToWebview ( { type : "messageCreated" , clineMessage : message } )
1566+ // Small delay to prevent overwhelming the webview
1567+ await delay ( 10 )
1568+ }
1569+ } else {
1570+ // Normal state update for new tasks or tasks without messages
1571+ await this . postMessageToWebview ( { type : "state" , state } )
1572+ }
15541573
15551574 // Check MDM compliance and send user to account tab if not compliant
15561575 if ( ! this . checkMdmCompliance ( ) ) {
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ export interface ExtensionMessage {
6666 | "workspaceUpdated"
6767 | "invoke"
6868 | "messageUpdated"
69+ | "messageCreated"
6970 | "mcpServers"
7071 | "enhancedPrompt"
7172 | "commitSearchResults"
Original file line number Diff line number Diff line change @@ -333,6 +333,14 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
333333 setCommands ( message . commands ?? [ ] )
334334 break
335335 }
336+ case "messageCreated" : {
337+ const clineMessage = message . clineMessage !
338+ setState ( ( prevState ) => ( {
339+ ...prevState ,
340+ clineMessages : [ ...prevState . clineMessages , clineMessage ] ,
341+ } ) )
342+ break
343+ }
336344 case "messageUpdated" : {
337345 const clineMessage = message . clineMessage !
338346 setState ( ( prevState ) => {
You can’t perform that action at this time.
0 commit comments