From 6dfdc24500d7dfe7b1a6680c162b79cd8b900753 Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Tue, 24 Jun 2025 03:18:52 +0100 Subject: [PATCH] Hide result message for Read and Edit --- src/extension.ts | 39 ++++++++++++++++++++++------- src/ui-styles.ts | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ui.ts | 9 +++++++ 3 files changed, 104 insertions(+), 9 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 3e7011e..2a01d58 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -574,15 +574,36 @@ class ClaudeChatProvider { let resultContent = content.content || 'Tool executed successfully'; const isError = content.is_error || false; - // Show tool result and save to conversation - this._sendAndSaveMessage({ - type: 'toolResult', - data: { - content: resultContent, - isError: isError, - toolUseId: content.tool_use_id - } - }); + // Find the last tool use to get the tool name + const lastToolUse = this._currentConversation[this._currentConversation.length-1] + + const toolName = lastToolUse?.data?.toolName; + + // Don't send tool result for Read and Edit tools unless there's an error + if ((toolName === 'Read' || toolName === 'Edit') && !isError) { + // Still send to UI to hide loading state, but mark it as hidden + this._sendAndSaveMessage({ + type: 'toolResult', + data: { + content: resultContent, + isError: isError, + toolUseId: content.tool_use_id, + toolName: toolName, + hidden: true + } + }); + } else { + // Show tool result and save to conversation + this._sendAndSaveMessage({ + type: 'toolResult', + data: { + content: resultContent, + isError: isError, + toolUseId: content.tool_use_id, + toolName: toolName + } + }); + } } } } diff --git a/src/ui-styles.ts b/src/ui-styles.ts index 09bcf48..48d7d89 100644 --- a/src/ui-styles.ts +++ b/src/ui-styles.ts @@ -1646,6 +1646,71 @@ const styles = ` color: var(--vscode-descriptionForeground); opacity: 0.8; } + + /* Tool loading animation */ + .tool-loading { + padding: 16px 12px; + display: flex; + align-items: center; + gap: 12px; + background-color: var(--vscode-panel-background); + border-top: 1px solid var(--vscode-panel-border); + } + + .loading-spinner { + display: flex; + gap: 4px; + } + + .loading-ball { + width: 8px; + height: 8px; + border-radius: 50%; + background-color: var(--vscode-button-background); + animation: bounce 1.4s ease-in-out infinite both; + } + + .loading-ball:nth-child(1) { animation-delay: -0.32s; } + .loading-ball:nth-child(2) { animation-delay: -0.16s; } + .loading-ball:nth-child(3) { animation-delay: 0s; } + + @keyframes bounce { + 0%, 80%, 100% { + transform: scale(0.6); + opacity: 0.5; + } + 40% { + transform: scale(1); + opacity: 1; + } + } + + .loading-text { + font-size: 12px; + color: var(--vscode-descriptionForeground); + font-style: italic; + } + + /* Tool completion indicator */ + .tool-completion { + padding: 8px 12px; + display: flex; + align-items: center; + gap: 6px; + background-color: rgba(76, 175, 80, 0.1); + border-top: 1px solid rgba(76, 175, 80, 0.2); + font-size: 12px; + } + + .completion-icon { + color: #4caf50; + font-weight: bold; + } + + .completion-text { + color: var(--vscode-foreground); + opacity: 0.8; + } ` export default styles \ No newline at end of file diff --git a/src/ui.ts b/src/ui.ts index 1e256ca..6beec62 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -722,6 +722,15 @@ const html = ` } function addToolResultMessage(data) { + // For Read and Edit tools with hidden flag, just hide loading state and show completion message + if (data.hidden && (data.toolName === 'Read' || data.toolName === 'Edit') && !data.isError) { + // Show completion message + const toolName = data.toolName; + const completionText = toolName === 'Read' ? '✅ Read completed' : '✅ Edit completed'; + addMessage(completionText, 'system'); + return; // Don't show the result message + } + const messageDiv = document.createElement('div'); messageDiv.className = data.isError ? 'message error' : 'message tool-result';