diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index e60da1c50be..86b2f45f41b 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -408,6 +408,11 @@ "when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connected && !aws.isSageMakerUnifiedStudio", "group": "2_amazonQ@4" }, + { + "command": "aws.amazonq.showLogs", + "when": "view == aws.amazonq.AmazonQChatView", + "group": "1_amazonQ@5" + }, { "command": "aws.amazonq.reconnect", "when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connectionExpired", @@ -636,6 +641,12 @@ "category": "%AWS.amazonq.title%", "enablement": "aws.codewhisperer.connected" }, + { + "command": "aws.amazonq.showLogs", + "title": "%AWS.command.codewhisperer.showLogs%", + "category": "%AWS.amazonq.title%", + "enablement": "aws.codewhisperer.connected" + }, { "command": "aws.amazonq.selectRegionProfile", "title": "Change Profile", diff --git a/packages/core/package.nls.json b/packages/core/package.nls.json index 20d500e07bd..0a25550ec22 100644 --- a/packages/core/package.nls.json +++ b/packages/core/package.nls.json @@ -275,6 +275,7 @@ "AWS.command.codewhisperer.signout": "Sign Out", "AWS.command.codewhisperer.reconnect": "Reconnect", "AWS.command.codewhisperer.openReferencePanel": "Open Code Reference Log", + "AWS.command.codewhisperer.showLogs": "Show Logs", "AWS.command.q.selectRegionProfile": "Select Profile", "AWS.command.q.transform.acceptChanges": "Accept", "AWS.command.q.transform.rejectChanges": "Reject", diff --git a/packages/core/src/codewhisperer/activation.ts b/packages/core/src/codewhisperer/activation.ts index d6dd7fdc61d..1e73b640a1e 100644 --- a/packages/core/src/codewhisperer/activation.ts +++ b/packages/core/src/codewhisperer/activation.ts @@ -23,6 +23,7 @@ import { enableCodeSuggestions, toggleCodeSuggestions, showReferenceLog, + showLogs, showSecurityScan, showLearnMore, showSsoSignIn, @@ -299,6 +300,7 @@ export async function activate(context: ExtContext): Promise { ), vscode.window.registerWebviewViewProvider(ReferenceLogViewProvider.viewType, ReferenceLogViewProvider.instance), showReferenceLog.register(), + showLogs.register(), showExploreAgentsView.register(), vscode.languages.registerCodeLensProvider( [...CodeWhispererConstants.platformLanguageIds], diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index efe993356bd..a8c21b86ce2 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -147,6 +147,32 @@ export const showReferenceLog = Commands.declare( } ) +export const showLogs = Commands.declare( + { id: 'aws.amazonq.showLogs', compositeKey: { 1: 'source' } }, + () => async (_: VsCodeCommandArg, source: CodeWhispererSource) => { + if (_ !== placeholder) { + source = 'ellipsesMenu' + } + + // Show warning message without buttons - just informational + void vscode.window.showWarningMessage( + 'Log files may contain sensitive information such as account IDs, resource names, and other data. Be careful when sharing these logs.' + ) + + // Get the log directory path + const logFolderPath = globals.context.logUri?.fsPath + const path = require('path') + const logFilePath = path.join(logFolderPath, 'Amazon Q Logs.log') + if (logFilePath) { + // Open the log directory in the OS file explorer directly + await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.file(logFilePath)) + } else { + // Fallback: show error if log path is not available + void vscode.window.showErrorMessage('Log location not available.') + } + } +) + export const showExploreAgentsView = Commands.declare( { id: 'aws.amazonq.exploreAgents', compositeKey: { 1: 'source' } }, () => async (_: VsCodeCommandArg, source: CodeWhispererSource) => {