diff --git a/src/extension.ts b/src/extension.ts index b1162f2..5008954 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -440,7 +440,7 @@ class ClaudeChatProvider { // Set processing state to true this._postMessage({ type: 'setProcessing', - data: true + data: {isProcessing: true} }); // Create backup commit before Claude makes changes @@ -784,7 +784,7 @@ class ClaudeChatProvider { // Clear processing state this._postMessage({ type: 'setProcessing', - data: false + data: {isProcessing: false} }); // Update cumulative tracking @@ -866,7 +866,7 @@ class ClaudeChatProvider { // Clear processing state this._postMessage({ type: 'setProcessing', - data: false + data: {isProcessing: false} }); // Show login required message @@ -1744,17 +1744,11 @@ class ClaudeChatProvider { private _sendAndSaveMessage(message: { type: string, data: any }, options?: { isProcessing?: boolean }): void { - console.log("--MESSAGE", message, options) - // Initialize conversation if this is the first message if (this._currentConversation.length === 0) { this._conversationStartTime = new Date().toISOString(); } - if (message.type === 'sessionInfo') { - message.data.sessionId; - } - // Send to UI using the helper method this._postMessage(message); @@ -1916,6 +1910,14 @@ class ClaudeChatProvider { private _stopClaudeProcess(): void { console.log('Stop request received'); + + this._isProcessing = false + + // Update UI state + this._postMessage({ + type: 'setProcessing', + data: {isProcessing: false} + }); if (this._currentClaudeProcess) { console.log('Terminating Claude process...'); @@ -1933,11 +1935,6 @@ class ClaudeChatProvider { // Clear process reference this._currentClaudeProcess = undefined; - // Update UI state - this._postMessage({ - type: 'setProcessing', - data: false - }); this._postMessage({ type: 'clearLoading' @@ -2024,6 +2021,8 @@ class ClaudeChatProvider { type: 'sessionCleared' }); + let requestStartTime: number + // Small delay to ensure messages are cleared before loading new ones setTimeout(() => { for (const message of this._currentConversation) { @@ -2031,6 +2030,13 @@ class ClaudeChatProvider { type: message.messageType, data: message.data }); + if(message.messageType === 'userInput'){ + try{ + requestStartTime = new Date(message.timestamp).getTime() + }catch(e){ + console.log(e) + } + } } // Send updated totals @@ -2049,7 +2055,7 @@ class ClaudeChatProvider { this._isProcessing = conversationData.isProcessing; this._postMessage({ type: 'setProcessing', - data: conversationData.isProcessing + data: {isProcessing: conversationData.isProcessing, requestStartTime} }); } // Send ready message after conversation is loaded diff --git a/src/ui.ts b/src/ui.ts index b491b2f..38ac173 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -1494,8 +1494,8 @@ const html = ` } } - function startRequestTimer() { - requestStartTime = Date.now(); + function startRequestTimer(startTime = undefined) { + requestStartTime = startTime || Date.now(); // Update status every 100ms for smooth real-time display requestTimer = setInterval(() => { if (isProcessing) { @@ -2533,9 +2533,9 @@ const html = ` break; case 'setProcessing': - isProcessing = message.data; + isProcessing = message.data.isProcessing; if (isProcessing) { - startRequestTimer(); + startRequestTimer(message.data.requestStartTime); showStopButton(); disableButtons(); } else { @@ -2584,7 +2584,6 @@ const html = ` break; case 'sessionInfo': - console.log('Session info:', message.data); if (message.data.sessionId) { showSessionInfo(message.data.sessionId); // Show detailed session information