Skip to content

Commit 24e6326

Browse files
authored
small fixes to Amazon Q tree nodes in toolkit view (#4137)
* refact(awsq): update enable button string * fix(awsq): use more reliable command to focus on Amazon Q Chat view Problem: "Switch To Amazon Q" tree node button does not always work for all clients. It is a silent failure. Solution: Use an alternative generated command to open the chat view.
1 parent 2a85a1a commit 24e6326

File tree

7 files changed

+19
-15
lines changed

7 files changed

+19
-15
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q: 'Switch to Q Chat' button not working for some users."
4+
}

src/amazonq/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { Commands, VsCodeCommandArg } from '../shared/vscode/commands2'
1313
import { MessagePublisher } from './messages/messagePublisher'
1414
import { welcome } from './onboardingPage'
1515
import { learnMoreAmazonQCommand, switchToAmazonQCommand } from './explorer/amazonQChildrenNodes'
16-
import { focusAmazonQPanel } from '../codewhisperer/commands/basicCommands'
1716
import { activateBadge } from './util/viewBadgeHandler'
1817
import { telemetry } from '../shared/telemetry/telemetry'
18+
import { focusAmazonQPanel } from '../auth/ui/vue/show'
1919

2020
export async function activate(context: ExtensionContext) {
2121
const appInitContext = new DefaultAmazonQAppInitContext()

src/amazonq/explorer/amazonQChildrenNodes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import * as vscode from 'vscode'
77
import * as nls from 'vscode-nls'
88
import { Commands, placeholder } from '../../shared/vscode/commands2'
99
import { getIcon } from '../../shared/icons'
10-
import { focusAmazonQPanel, reconnect, showTransformByQ } from '../../codewhisperer/commands/basicCommands'
10+
import { reconnect, showTransformByQ } from '../../codewhisperer/commands/basicCommands'
1111
import { transformByQState } from '../../codewhisperer/models/model'
1212
import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
1313
import { amazonQHelpUrl } from '../../shared/constants'
1414
import { cwTreeNodeSource } from '../../codewhisperer/commands/types'
1515
import { telemetry } from '../../shared/telemetry/telemetry'
16+
import { focusAmazonQPanel } from '../../auth/ui/vue/show'
1617

1718
const localize = nls.loadMessageBundle()
1819

@@ -50,7 +51,7 @@ export const switchToAmazonQNode = () =>
5051
export const enableAmazonQNode = () =>
5152
// Simply trigger re-auth to obtain the proper scopes- same functionality as if requested in the chat window.
5253
reconnect.build(placeholder, cwTreeNodeSource).asTreeNode({
53-
label: localize('AWS.amazonq.enable', 'Enable Amazon Q (Preview)'),
54+
label: localize('AWS.amazonq.enable', 'Enable'),
5455
iconPath: getIcon('vscode-debug-start'),
5556
contextValue: 'awsEnableAmazonQ',
5657
})

src/amazonq/onboardingPage/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import * as vscode from 'vscode'
77
import globals from '../../shared/extensionGlobals'
88
import path from 'path'
99
import { MessagePublisher } from '../messages/messagePublisher'
10-
import { focusAmazonQPanel } from '../../codewhisperer/commands/basicCommands'
1110
import { telemetry } from '../../shared/telemetry/telemetry'
11+
import { focusAmazonQPanel } from '../../auth/ui/vue/show'
1212

1313
export function welcome(context: vscode.ExtensionContext, cwcWebViewToAppsPublisher: MessagePublisher<any>): void {
1414
const panel = vscode.window.createWebviewPanel(

src/auth/ui/vue/show.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class AuthWebview extends VueWebview {
181181
}
182182

183183
async showAmazonQChat(): Promise<void> {
184-
await vscode.commands.executeCommand('aws.AmazonQChatView.focus')
184+
focusAmazonQPanel()
185185
}
186186

187187
async getIdentityCenterRegion(): Promise<Region | undefined> {
@@ -843,3 +843,11 @@ export async function emitWebviewClosed(authWebview: ClassToInterfaceType<AuthWe
843843
return result
844844
}
845845
}
846+
847+
/**
848+
* Forces focus to Amazon Q panel - USE THIS SPARINGLY (don't betray customer trust by hijacking the IDE)
849+
* Used on first load, and any time we want to directly populate chat.
850+
*/
851+
export async function focusAmazonQPanel(): Promise<void> {
852+
await vscode.commands.executeCommand('aws.AmazonQChatView.focus')
853+
}

src/codewhisperer/commands/basicCommands.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,6 @@ export const applySecurityFix = Commands.declare(
312312
}
313313
)
314314

315-
/**
316-
* Forces focus to Amazon Q panel - USE THIS SPARINGLY (don't betray customer trust by hijacking the IDE)
317-
* Used on first load, and any time we want to directly populate chat.
318-
*/
319-
export async function focusAmazonQPanel(): Promise<void> {
320-
// VS Code-owned command: "View: Show Amazon Q"
321-
await vscode.commands.executeCommand('workbench.view.extension.amazonq')
322-
}
323-
324315
export const signoutCodeWhisperer = Commands.declare(
325316
{ id: 'aws.codewhisperer.signout', compositeKey: { 1: 'source' } },
326317
(auth: AuthUtil) => (_: VsCodeCommandArg, source: CodeWhispererSource) => {

src/codewhispererChat/commands/registerCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { focusAmazonQPanel } from '../../codewhisperer/commands/basicCommands'
6+
import { focusAmazonQPanel } from '../../auth/ui/vue/show'
77
import { Commands } from '../../shared/vscode/commands2'
88
import { ChatControllerMessagePublishers } from '../controllers/chat/controller'
99

0 commit comments

Comments
 (0)