From 5bd61596cd88f18b286dbc8a24c94cbb7410487f Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Mon, 16 Jun 2025 12:24:44 -0600 Subject: [PATCH] Add explanatory comments for automated workflow focus preservation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add detailed comments explaining why we preserve focus during automated workflows - Clarify the security implications of accidental API key exposure - Reference issue #4574 for additional context - Improve code documentation for future maintainers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/core/mentions/index.ts | 4 +++- src/core/webview/webviewMessageHandler.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/mentions/index.ts b/src/core/mentions/index.ts index 8349aae7cc..21272c4007 100644 --- a/src/core/mentions/index.ts +++ b/src/core/mentions/index.ts @@ -37,7 +37,9 @@ export async function openMention(mention?: string): Promise { if (mention.endsWith("/")) { vscode.commands.executeCommand("revealInExplorer", vscode.Uri.file(absPath)) } else { - // Check if we're in an automated workflow to preserve chat focus during AI processing + // Check if we're in an automated workflow to preserve chat focus during AI processing. + // When users mention files (e.g., @/path/to/file.txt) while the AI is actively processing, + // we want to prevent the chatbox from losing focus to avoid accidental input interruption. const shouldPreserveFocus = isInAutomatedWorkflowFromVisibleProvider() openFile(absPath, { preserveFocus: shouldPreserveFocus }) diff --git a/src/core/webview/webviewMessageHandler.ts b/src/core/webview/webviewMessageHandler.ts index 29ef0daecd..0a4d33f5b3 100644 --- a/src/core/webview/webviewMessageHandler.ts +++ b/src/core/webview/webviewMessageHandler.ts @@ -427,7 +427,10 @@ export const webviewMessageHandler = async ( openImage(message.text!) break case "openFile": - // Check if we're in an automated workflow to preserve chat focus during AI processing + // Check if we're in an automated workflow to preserve chat focus during AI processing. + // This prevents the chatbox from losing focus when the AI is actively working, + // which could cause users to accidentally type sensitive information (like API keys) + // into the wrong window. See issue #4574 for more context. const shouldPreserveFocus = isInAutomatedWorkflowFromProvider(provider) openFile(message.text!, {