Skip to content

Commit dd5e4c8

Browse files
committed
feat: streaming diff animation improvements
1 parent ba96d02 commit dd5e4c8

File tree

8 files changed

+14
-517
lines changed

8 files changed

+14
-517
lines changed

packages/amazonq/src/lsp/chat/diffAnimation/README.md

Lines changed: 0 additions & 157 deletions
This file was deleted.

packages/amazonq/src/lsp/chat/diffAnimation/animationQueueManager.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { getLogger } from 'aws-core-vscode/shared'
76
import { QueuedAnimation, PendingFileWrite } from './types'
87
import { FileSystemManager } from './fileSystemManager'
98

@@ -58,7 +57,6 @@ export class AnimationQueueManager {
5857
const queue = this.animationQueue.get(filePath) || []
5958
queue.push(animation)
6059
this.animationQueue.set(filePath, queue)
61-
getLogger().info(`[AnimationQueueManager] 📋 Queued animation for ${filePath} (queue size: ${queue.length})`)
6260
}
6361

6462
/**
@@ -121,11 +119,6 @@ export class AnimationQueueManager {
121119
if (!next) {
122120
return
123121
}
124-
125-
getLogger().info(
126-
`[AnimationQueueManager] 🎯 Processing queued animation for ${filePath} (${queue.length} remaining)`
127-
)
128-
129122
// Use the current file content as the "original" for the next animation
130123
const currentContent = await this.fileSystemManager.getCurrentFileContent(filePath)
131124

@@ -164,7 +157,6 @@ export class AnimationQueueManager {
164157
public clearAll(): void {
165158
this.animatingFiles.clear()
166159
this.animationQueue.clear()
167-
getLogger().info('[AnimationQueueManager] 🧹 Cleared all animation queues and state')
168160
}
169161

170162
/**
@@ -173,6 +165,5 @@ export class AnimationQueueManager {
173165
public clearFileQueue(filePath: string): void {
174166
this.animationQueue.delete(filePath)
175167
this.markAsNotAnimating(filePath)
176-
getLogger().info(`[AnimationQueueManager] 🧹 Cleared queue for ${filePath}`)
177168
}
178169
}

packages/amazonq/src/lsp/chat/diffAnimation/chatProcessor.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@ export class ChatProcessor {
1717
private onFileWritePreparation: (pendingWrite: PendingFileWrite) => Promise<void>
1818
) {}
1919

20-
/**
21-
* Process streaming ChatResult updates
22-
*/
2320
public async processChatResult(
2421
chatResult: ChatResult | ChatMessage,
2522
tabId: string,
2623
isPartialResult?: boolean
2724
): Promise<void> {
28-
getLogger().info(`[ChatProcessor] 📨 Processing ChatResult for tab ${tabId}, isPartial: ${isPartialResult}`)
29-
3025
try {
31-
// Handle both ChatResult and ChatMessage types
3226
if ('type' in chatResult && chatResult.type === 'tool') {
33-
// This is a ChatMessage
3427
await this.processChatMessage(chatResult as ChatMessage, tabId)
3528
} else if ('additionalMessages' in chatResult && chatResult.additionalMessages) {
36-
// This is a ChatResult with additional messages
3729
for (const message of chatResult.additionalMessages) {
3830
await this.processChatMessage(message, tabId)
3931
}
@@ -43,43 +35,31 @@ export class ChatProcessor {
4335
}
4436
}
4537

46-
/**
47-
* Process individual chat messages
48-
*/
4938
private async processChatMessage(message: ChatMessage, tabId: string): Promise<void> {
5039
if (!message.messageId) {
5140
return
5241
}
5342

54-
// Deduplicate messages
5543
const messageKey = `${message.messageId}_${message.type}`
5644
if (this.processedMessages.has(messageKey)) {
57-
getLogger().info(`[ChatProcessor] ⏭️ Already processed message: ${messageKey}`)
5845
return
5946
}
6047
this.processedMessages.add(messageKey)
6148

62-
// Check for fsWrite tool preparation (when tool is about to execute)
6349
if (message.type === 'tool' && message.messageId.startsWith('progress_')) {
6450
await this.processFsWritePreparation(message, tabId)
6551
}
6652
}
6753

68-
/**
69-
* Process fsWrite preparation - capture content BEFORE file is written
70-
*/
7154
private async processFsWritePreparation(message: ChatMessage, tabId: string): Promise<void> {
72-
// Cast to any to access properties that might not be in the type definition
7355
const messageAny = message as any
74-
7556
const fileList = messageAny.header?.fileList
7657
if (!fileList?.filePaths || fileList.filePaths.length === 0) {
7758
return
7859
}
7960

8061
const fileName = fileList.filePaths[0]
8162
const fileDetails = fileList.details?.[fileName]
82-
8363
if (!fileDetails?.description) {
8464
return
8565
}
@@ -89,16 +69,10 @@ export class ChatProcessor {
8969
return
9070
}
9171

92-
// Extract toolUseId from progress message
9372
const toolUseId = message.messageId!.replace('progress_', '')
94-
95-
getLogger().info(`[ChatProcessor] 🎬 Preparing for fsWrite: ${filePath} (toolUse: ${toolUseId})`)
96-
97-
// Capture current content IMMEDIATELY before the write happens
9873
const { content: originalContent, exists: fileExists } =
9974
await this.fileSystemManager.captureFileContent(filePath)
10075

101-
// Store pending write info
10276
const pendingWrite: PendingFileWrite = {
10377
filePath,
10478
originalContent,
@@ -107,44 +81,28 @@ export class ChatProcessor {
10781
}
10882

10983
try {
110-
// Prepare file for writing
11184
await this.fileSystemManager.prepareFileForWrite(filePath, fileExists)
112-
113-
// Notify handler about the pending write
11485
await this.onFileWritePreparation(pendingWrite)
11586
} catch (error) {
11687
getLogger().error(`[ChatProcessor] ❌ Failed to prepare file write: ${error}`)
11788
throw error
11889
}
11990
}
12091

121-
/**
122-
* Process ChatUpdateParams
123-
*/
12492
public async processChatUpdate(params: ChatUpdateParams): Promise<void> {
125-
getLogger().info(`[ChatProcessor] 🔄 Processing chat update for tab ${params.tabId}`)
126-
12793
if (params.data?.messages) {
12894
for (const message of params.data.messages) {
12995
await this.processChatMessage(message, params.tabId)
13096
}
13197
}
13298
}
13399

134-
/**
135-
* Clear processed messages cache
136-
*/
137100
public clearProcessedMessages(): void {
138101
if (this.processedMessages.size > 1000) {
139-
const oldSize = this.processedMessages.size
140102
this.processedMessages.clear()
141-
getLogger().info(`[ChatProcessor] 🧹 Cleared ${oldSize} processed messages`)
142103
}
143104
}
144105

145-
/**
146-
* Clear all caches
147-
*/
148106
public clearAll(): void {
149107
this.processedMessages.clear()
150108
}

0 commit comments

Comments
 (0)