Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/lsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sequenceDiagram
```

## Language Server Debugging

If you want to connect a local version of language-servers to aws-toolkit-vscode, follow these steps:

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.
Expand Down Expand Up @@ -57,13 +58,16 @@ If you want to connect a local version of language-servers to aws-toolkit-vscode
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

### Breakpoints Work-Around

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.

1. Set your breakpoints and click `Launch LSP with Debugging`
2. Once the debugging session has started, click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear
3. On the debug panel, click `Attach to Language Server (amazonq)` next to the red stop button
4. Click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear

## Language Server Runtimes Debugging

If you want to connect a local version of language-server-runtimes to aws-toolkit-vscode, follow these steps:

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.
Expand All @@ -75,6 +79,7 @@ If you want to connect a local version of language-server-runtimes to aws-toolki
/amazonq
/language-server-runtimes
```

2. Inside of the language-server-runtimes project run:
```
npm install
Expand Down
53 changes: 50 additions & 3 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@
]
},
"commands": [
{
"command": "aws.amazonq.stopCmdExecution",
"title": "Stop Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the stop shortcut will also used for global stop, right? if yes, then we should change the title. IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but regular prompt without tool execution can be still considered as Q Command right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why no tool execution can be considered Q command stop / run / reject?

},
{
"command": "aws.amazonq.runCmdExecution",
"title": "Run Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
},
{
"command": "aws.amazonq.rejectCmdExecution",
"title": "Reject Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
},
{
"command": "_aws.amazonq.notifications.dismiss",
"title": "%AWS.generic.dismiss%",
Expand Down Expand Up @@ -843,6 +858,24 @@
}
],
"keybindings": [
{
"command": "aws.amazonq.stopCmdExecution",
"key": "ctrl+shift+backspace",
"mac": "cmd+shift+backspace",
"when": "aws.amazonq.amazonqChatLSP.isRunning"
},
{
"command": "aws.amazonq.runCmdExecution",
"key": "ctrl+shift+enter",
"mac": "cmd+shift+enter",
"when": "aws.amazonq.amazonqChatLSP.isRunning"
},
{
"command": "aws.amazonq.rejectCmdExecution",
"key": "ctrl+shift+r",
"mac": "cmd+shift+r",
"when": "aws.amazonq.amazonqChatLSP.isRunning"
},
{
"command": "_aws.amazonq.focusChat.keybinding",
"win": "win+alt+i",
Expand Down Expand Up @@ -1325,26 +1358,40 @@
"fontCharacter": "\\f1de"
}
},
"aws-schemas-registry": {
"aws-sagemaker-code-editor": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was because of npm install not sure why, I reverted it, then the next npm install will change this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the catch na

"description": "AWS Contributed Icon",
"default": {
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
"fontCharacter": "\\f1df"
}
},
"aws-schemas-schema": {
"aws-sagemaker-jupyter-lab": {
"description": "AWS Contributed Icon",
"default": {
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
"fontCharacter": "\\f1e0"
}
},
"aws-stepfunctions-preview": {
"aws-schemas-registry": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yueny2020 got added here after npm install run for dependencies.

"description": "AWS Contributed Icon",
"default": {
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
"fontCharacter": "\\f1e1"
}
},
"aws-schemas-schema": {
"description": "AWS Contributed Icon",
"default": {
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
"fontCharacter": "\\f1e2"
}
},
"aws-stepfunctions-preview": {
"description": "AWS Contributed Icon",
"default": {
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
"fontCharacter": "\\f1e3"
}
}
},
"walkthroughs": [
Expand Down
16 changes: 15 additions & 1 deletion packages/amazonq/src/lsp/chat/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
params: {},
})
})
})
}),
registerShellCommandShortCut('aws.amazonq.runCmdExecution', 'run-shell-command', provider),
registerShellCommandShortCut('aws.amazonq.rejectCmdExecution', 'reject-shell-command', provider),
registerShellCommandShortCut('aws.amazonq.stopCmdExecution', 'stop-shell-command', provider)
)
}

Expand Down Expand Up @@ -123,3 +126,14 @@ export async function focusAmazonQPanel() {
await Commands.tryExecute('aws.amazonq.AmazonQChatView.focus')
await Commands.tryExecute('aws.amazonq.AmazonCommonAuth.focus')
}

function registerShellCommandShortCut(commandName: string, buttonId: string, provider: AmazonQChatViewProvider) {
return Commands.register(commandName, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Not a blocking One.
We can add a log here which helps us to debug the issues.

void focusAmazonQPanel().then(() => {
void provider.webview?.postMessage({
command: 'aws/chat/executeShellCommandShortCut',
params: { id: buttonId },
})
})
})
}
3 changes: 2 additions & 1 deletion packages/amazonq/src/lsp/chat/webviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Webview,
} from 'vscode'
import * as path from 'path'
import * as os from 'os'
import {
globals,
isSageMaker,
Expand Down Expand Up @@ -149,7 +150,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
const vscodeApi = acquireVsCodeApi()
const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${regionProfileString},${disabledCommands},${isSMUS},${isSM},vscodeApi.postMessage)
const commands = [hybridChatConnector.initialQuickActions[0]]
qChat = amazonQChat.createChat(vscodeApi, {disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
qChat = amazonQChat.createChat(vscodeApi, {os: "${os.platform()}", disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
}
window.addEventListener('message', (event) => {
/**
Expand Down
13 changes: 13 additions & 0 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
getClientId,
extensionVersion,
isSageMaker,
setContext,
} from 'aws-core-vscode/shared'
import { processUtils } from 'aws-core-vscode/shared'
import { activate } from './chat/activation'
Expand Down Expand Up @@ -164,6 +165,7 @@ export async function startLanguageServer(
pinnedContextEnabled: true,
imageContextEnabled: true,
mcp: true,
shortcut: true,
reroute: true,
modelSelection: true,
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
Expand Down Expand Up @@ -247,6 +249,17 @@ async function onLanguageServerReady(

if (Experiments.instance.get('amazonqChatLSP', true)) {
await activate(client, encryptionKey, resourcePaths.ui)

await setContext('aws.amazonq.amazonqChatLSP.isRunning', true)
getLogger().info('Amazon Q Chat LSP context flag set on client activated')

// Add a disposable to reset the context flag when the client stops
toDispose.push({
dispose: async () => {
await setContext('aws.amazonq.amazonqChatLSP.isRunning', false)
getLogger().info('Amazon Q Chat LSP context flag reset on client disposal')
},
})
}

const refreshInterval = auth.startTokenRefreshInterval(10 * oneSecond)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/vscode/setContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type contextKey =
| 'gumby.wasQCodeTransformationUsed'
| 'amazonq.inline.codelensShortcutEnabled'
| 'aws.toolkit.lambda.walkthroughSelected'
| 'aws.amazonq.amazonqChatLSP.isRunning'

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

Expand Down
Loading