Skip to content

Commit 55fe5e1

Browse files
committed
feat(amazonq lsp): Make chat client assets configurable
1 parent 708f538 commit 55fe5e1

File tree

8 files changed

+28
-16
lines changed

8 files changed

+28
-16
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Example:
439439
"supportedVersions": "4.0.0",
440440
"id": "AmazonQ",
441441
"path": "/custom/path/to/local/lsp/folder",
442+
"ui": "/custom/path/to/chat-client/ui"
442443
}
443444
```
444445

@@ -503,11 +504,12 @@ Unlike the user setting overrides, not all of these environment variables have t
503504
- `__AMAZONQLSP_MANIFEST_URL`: for aws.dev.amazonqLsp.manifestUrl
504505
- `__AMAZONQLSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqLsp.supportedVersions
505506
- `__AMAZONQLSP_ID`: for aws.dev.amazonqLsp.id
506-
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
507+
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqLsp.path
508+
- `__AMAZONQLSP_UI`: for aws.dev.amazonqLsp.ui
507509
- `__AMAZONQWORKSPACELSP_MANIFEST_URL`: for aws.dev.amazonqWorkspaceLsp.manifestUrl
508510
- `__AMAZONQWORKSPACELSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqWorkspaceLsp.supportedVersions
509511
- `__AMAZONQWORKSPACELSP_ID`: for aws.dev.amazonqWorkspaceLsp.id
510-
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
512+
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.path
511513

512514
#### Lambda
513515

docs/lsp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ sequenceDiagram
5454
}
5555
```
5656
4. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
57+
1. Uncomment the `__AMAZONQLSP_UI` variable in `amazonq/.vscode/launch.json` Extension configuration if you want to debug the flare chat-client as well
5758
5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
5859
5960
## Amazon Q Inline Activation

packages/amazonq/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"SSMDOCUMENT_LANGUAGESERVER_PORT": "6010",
1616
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080"
1717
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js",
18+
// "__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js"
1819
},
1920
"envFile": "${workspaceFolder}/.local.env",
2021
"outFiles": ["${workspaceFolder}/dist/**/*.js", "${workspaceFolder}/../core/dist/**/*.js"],

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from 'vscode'
1515
import { LanguageServerResolver } from 'aws-core-vscode/shared'
1616
import { QuickActionCommandGroup } from '@aws/mynah-ui'
17+
import * as path from 'path'
1718

1819
export class AmazonQChatViewProvider implements WebviewViewProvider {
1920
public static readonly viewType = 'aws.amazonq.AmazonQChatView'
@@ -49,7 +50,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
4950
webviewView.webview.options = {
5051
enableScripts: true,
5152
enableCommandUris: true,
52-
localResourceRoots: [lspDir],
53+
localResourceRoots: [lspDir, Uri.parse(path.dirname(this.mynahUIPath))],
5354
}
5455

5556
const uiPath = webviewView.webview.asWebviewUri(Uri.parse(this.mynahUIPath)).toString()

packages/amazonq/src/lsp/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function startLanguageServer(
126126
}
127127

128128
if (Experiments.instance.get('amazonqChatLSP', false)) {
129-
activate(client, encryptionKey, resourcePaths.mynahUI)
129+
activate(client, encryptionKey, resourcePaths.ui)
130130
}
131131

132132
// Temporary code for pen test. Will be removed when we switch to the real flare auth

packages/amazonq/src/lsp/config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@
66
import { DevSettings, getServiceEnvVarConfig } from 'aws-core-vscode/shared'
77
import { LspConfig } from 'aws-core-vscode/amazonq'
88

9-
export const defaultAmazonQLspConfig: LspConfig = {
9+
export interface ExtendedAmazonQLSPConfig extends LspConfig {
10+
ui?: string
11+
}
12+
13+
export const defaultAmazonQLspConfig: ExtendedAmazonQLSPConfig = {
1014
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json',
1115
supportedVersions: '^3.1.1',
1216
id: 'AmazonQ', // used across IDEs for identifying global storage/local disk locations. Do not change.
1317
suppressPromptPrefix: 'amazonQ',
1418
path: undefined,
19+
ui: undefined,
1520
}
1621

17-
export function getAmazonQLspConfig(): LspConfig {
22+
export function getAmazonQLspConfig(): ExtendedAmazonQLSPConfig {
1823
return {
1924
...defaultAmazonQLspConfig,
20-
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as LspConfig),
25+
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as ExtendedAmazonQLSPConfig),
2126
...getServiceEnvVarConfig('amazonqLsp', Object.keys(defaultAmazonQLspConfig)),
2227
}
2328
}

packages/amazonq/src/lsp/lspInstaller.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
import { fs, getNodeExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared'
77
import path from 'path'
8-
import { getAmazonQLspConfig } from './config'
9-
import { LspConfig } from 'aws-core-vscode/amazonq'
8+
import { ExtendedAmazonQLSPConfig, getAmazonQLspConfig } from './config'
109

1110
export interface AmazonQResourcePaths extends ResourcePaths {
12-
mynahUI: string
11+
ui: string
1312
}
1413

15-
export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<AmazonQResourcePaths> {
16-
constructor(lspConfig: LspConfig = getAmazonQLspConfig()) {
14+
export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
15+
AmazonQResourcePaths,
16+
ExtendedAmazonQLSPConfig
17+
> {
18+
constructor(lspConfig: ExtendedAmazonQLSPConfig = getAmazonQLspConfig()) {
1719
super(lspConfig, 'amazonqLsp')
1820
}
1921

@@ -27,15 +29,15 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<Amazo
2729
return {
2830
lsp: this.config.path ?? '',
2931
node: getNodeExecutableName(),
30-
mynahUI: '', // TODO make mynah UI configurable
32+
ui: this.config.ui ?? '',
3133
}
3234
}
3335

3436
const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`)
3537
return {
3638
lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'),
3739
node: nodePath,
38-
mynahUI: path.join(assetDirectory, 'clients/amazonq-ui.js'),
40+
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
3941
}
4042
}
4143
}

packages/core/src/shared/lsp/baseLspInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { Range } from 'semver'
1414
import { getLogger } from '../logger/logger'
1515
import type { Logger, LogTopic } from '../logger/logger'
1616

17-
export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths> {
17+
export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths, Config extends LspConfig = LspConfig> {
1818
private logger: Logger
1919

2020
constructor(
21-
protected config: LspConfig,
21+
protected config: Config,
2222
loggerName: Extract<LogTopic, 'amazonqLsp' | 'amazonqWorkspaceLsp'>
2323
) {
2424
this.logger = getLogger(loggerName)

0 commit comments

Comments
 (0)