Skip to content

Commit 94903b5

Browse files
authored
Merge branch 'aws:master' into code-review-tool
2 parents 92a2d01 + 028f4f3 commit 94903b5

File tree

6 files changed

+69
-2
lines changed

6 files changed

+69
-2
lines changed

docs/lsp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sequenceDiagram
2525
```
2626

2727
## Language Server Debugging
28+
2829
If you want to connect a local version of language-servers to aws-toolkit-vscode, follow these steps:
2930

3031
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-servers folder that you just cloned. Your VS code folder structure should look like below.
@@ -57,13 +58,16 @@ If you want to connect a local version of language-servers to aws-toolkit-vscode
5758
6. (Optional): Enable `"amazonq.trace.server": "on"` or `"amazonq.trace.server": "verbose"` in your VSCode settings to view detailed log messages sent to/from the language server. These log messages will show up in the "Amazon Q Language Server" output channel
5859
5960
### Breakpoints Work-Around
61+
6062
If the breakpoints in your language-servers project remain greyed out and do not trigger when you run `Launch LSP with Debugging`, your debugger may be attaching to the language server before it has launched. You can follow the work-around below to avoid this problem. If anyone fixes this issue, please remove this section.
63+
6164
1. Set your breakpoints and click `Launch LSP with Debugging`
6265
2. Once the debugging session has started, click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear
6366
3. On the debug panel, click `Attach to Language Server (amazonq)` next to the red stop button
6467
4. Click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear
6568
6669
## Language Server Runtimes Debugging
70+
6771
If you want to connect a local version of language-server-runtimes to aws-toolkit-vscode, follow these steps:
6872
6973
1. Clone https://github.com/aws/language-server-runtimes.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-server-runtimes folder that you just cloned. Your VS code folder structure should look like below.
@@ -75,6 +79,7 @@ If you want to connect a local version of language-server-runtimes to aws-toolki
7579
/amazonq
7680
/language-server-runtimes
7781
```
82+
7883
2. Inside of the language-server-runtimes project run:
7984
```
8085
npm install

packages/amazonq/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,21 @@
560560
]
561561
},
562562
"commands": [
563+
{
564+
"command": "aws.amazonq.stopCmdExecution",
565+
"title": "Stop Amazon Q Command Execution",
566+
"category": "%AWS.amazonq.title%"
567+
},
568+
{
569+
"command": "aws.amazonq.runCmdExecution",
570+
"title": "Run Amazon Q Command Execution",
571+
"category": "%AWS.amazonq.title%"
572+
},
573+
{
574+
"command": "aws.amazonq.rejectCmdExecution",
575+
"title": "Reject Amazon Q Command Execution",
576+
"category": "%AWS.amazonq.title%"
577+
},
563578
{
564579
"command": "_aws.amazonq.notifications.dismiss",
565580
"title": "%AWS.generic.dismiss%",
@@ -850,6 +865,24 @@
850865
}
851866
],
852867
"keybindings": [
868+
{
869+
"command": "aws.amazonq.stopCmdExecution",
870+
"key": "ctrl+shift+backspace",
871+
"mac": "cmd+shift+backspace",
872+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
873+
},
874+
{
875+
"command": "aws.amazonq.runCmdExecution",
876+
"key": "ctrl+shift+enter",
877+
"mac": "cmd+shift+enter",
878+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
879+
},
880+
{
881+
"command": "aws.amazonq.rejectCmdExecution",
882+
"key": "ctrl+shift+r",
883+
"mac": "cmd+shift+r",
884+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
885+
},
853886
{
854887
"command": "_aws.amazonq.focusChat.keybinding",
855888
"win": "win+alt+i",

packages/amazonq/src/lsp/chat/commands.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
5858
params: {},
5959
})
6060
})
61-
})
61+
}),
62+
registerShellCommandShortCut('aws.amazonq.runCmdExecution', 'run-shell-command', provider),
63+
registerShellCommandShortCut('aws.amazonq.rejectCmdExecution', 'reject-shell-command', provider),
64+
registerShellCommandShortCut('aws.amazonq.stopCmdExecution', 'stop-shell-command', provider)
6265
)
6366
}
6467

@@ -149,3 +152,14 @@ export async function focusAmazonQPanel() {
149152
await Commands.tryExecute('aws.amazonq.AmazonQChatView.focus')
150153
await Commands.tryExecute('aws.amazonq.AmazonCommonAuth.focus')
151154
}
155+
156+
function registerShellCommandShortCut(commandName: string, buttonId: string, provider: AmazonQChatViewProvider) {
157+
return Commands.register(commandName, async () => {
158+
void focusAmazonQPanel().then(() => {
159+
void provider.webview?.postMessage({
160+
command: 'aws/chat/executeShellCommandShortCut',
161+
params: { id: buttonId },
162+
})
163+
})
164+
})
165+
}

packages/amazonq/src/lsp/chat/webviewProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Webview,
1414
} from 'vscode'
1515
import * as path from 'path'
16+
import * as os from 'os'
1617
import {
1718
globals,
1819
isSageMaker,
@@ -149,7 +150,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
149150
const vscodeApi = acquireVsCodeApi()
150151
const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${regionProfileString},${disabledCommands},${isSMUS},${isSM},vscodeApi.postMessage)
151152
const commands = [hybridChatConnector.initialQuickActions[0]]
152-
qChat = amazonQChat.createChat(vscodeApi, {disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
153+
qChat = amazonQChat.createChat(vscodeApi, {os: "${os.platform()}", disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
153154
}
154155
window.addEventListener('message', (event) => {
155156
/**

packages/amazonq/src/lsp/client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
getClientId,
3939
extensionVersion,
4040
isSageMaker,
41+
setContext,
4142
} from 'aws-core-vscode/shared'
4243
import { processUtils } from 'aws-core-vscode/shared'
4344
import { activate } from './chat/activation'
@@ -164,6 +165,7 @@ export async function startLanguageServer(
164165
pinnedContextEnabled: true,
165166
imageContextEnabled: true,
166167
mcp: true,
168+
shortcut: true,
167169
reroute: true,
168170
modelSelection: true,
169171
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
@@ -248,6 +250,17 @@ async function onLanguageServerReady(
248250

249251
if (Experiments.instance.get('amazonqChatLSP', true)) {
250252
await activate(client, encryptionKey, resourcePaths.ui)
253+
254+
await setContext('aws.amazonq.amazonqChatLSP.isRunning', true)
255+
getLogger().info('Amazon Q Chat LSP context flag set on client activated')
256+
257+
// Add a disposable to reset the context flag when the client stops
258+
toDispose.push({
259+
dispose: async () => {
260+
await setContext('aws.amazonq.amazonqChatLSP.isRunning', false)
261+
getLogger().info('Amazon Q Chat LSP context flag reset on client disposal')
262+
},
263+
})
251264
}
252265

253266
const refreshInterval = auth.startTokenRefreshInterval(10 * oneSecond)

packages/core/src/shared/vscode/setContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type contextKey =
4040
| 'gumby.wasQCodeTransformationUsed'
4141
| 'amazonq.inline.codelensShortcutEnabled'
4242
| 'aws.toolkit.lambda.walkthroughSelected'
43+
| 'aws.amazonq.amazonqChatLSP.isRunning'
4344

4445
const contextMap: Partial<Record<contextKey, any>> = {}
4546

0 commit comments

Comments
 (0)