Skip to content

Commit 4cab15c

Browse files
committed
fix(amazonq): read amazonq-ui.js from servers.zip instead of clients.zip
1 parent 3c0a34b commit 4cab15c

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

packages/amazonq/src/lsp/lspInstaller.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import * as nodeFs from 'fs'
67
import vscode from 'vscode'
78
import { fs, getNodeExecutableName, getRgExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared'
89
import path from 'path'
@@ -45,11 +46,15 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
4546

4647
const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`)
4748
const rgPath = path.join(assetDirectory, `servers/ripgrep/${getRgExecutableName()}`)
49+
// Check for amazonq-ui.js in both locations for backwards compatibility
50+
const amazonqUiInClientsPath = path.join(assetDirectory, 'clients/amazonq-ui.js')
51+
const amazonqUiInServersPath = path.join(assetDirectory, 'servers/amazonq-ui.js')
52+
const uiPath = nodeFs.existsSync(amazonqUiInClientsPath) ? amazonqUiInClientsPath : amazonqUiInServersPath
4853
return {
4954
lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'),
5055
node: nodePath,
5156
ripGrep: rgPath,
52-
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
57+
ui: uiPath,
5358
}
5459
}
5560

@@ -58,10 +63,14 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
5863

5964
export function getBundledResourcePaths(ctx: vscode.ExtensionContext): AmazonQResourcePaths {
6065
const assetDirectory = vscode.Uri.joinPath(ctx.extensionUri, 'resources', 'language-server').fsPath
66+
// Check for amazonq-ui.js in both locations for backwards compatibility
67+
const amazonqUiInClientsPath = path.join(assetDirectory, 'clients/amazonq-ui.js')
68+
const amazonqUiInServersPath = path.join(assetDirectory, 'servers/amazonq-ui.js')
69+
const uiPath = nodeFs.existsSync(amazonqUiInClientsPath) ? amazonqUiInClientsPath : amazonqUiInServersPath
6170
return {
6271
lsp: path.join(assetDirectory, 'servers', 'aws-lsp-codewhisperer.js'),
6372
node: process.execPath,
6473
ripGrep: '',
65-
ui: path.join(assetDirectory, 'clients', 'amazonq-ui.js'),
74+
ui: uiPath,
6675
}
6776
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths,
7676
// resourcePaths = {
7777
// lsp = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/aws-lsp-codewhisperer.js'
7878
// node = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/node'
79-
// ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js'
79+
// ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' or
80+
// '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js'
8081
// }
8182
// ```
8283
resourcePaths: this.resourcePaths(assetDirectory),

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export interface LspResult {
2323
* resourcePaths = {
2424
* lsp = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/aws-lsp-codewhisperer.js'
2525
* node = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/node'
26-
* ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js'
26+
* ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' or
27+
* '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js'
2728
* }
2829
* ```
2930
*/
@@ -47,7 +48,8 @@ export interface LspResolution<T extends ResourcePaths> extends LspResult {
4748
* resourcePaths = {
4849
* lsp = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/aws-lsp-codewhisperer.js'
4950
* node = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/node'
50-
* ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js'
51+
* ui = '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' or
52+
* '<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js'
5153
* }
5254
* ```
5355
*/

scripts/lspArtifact.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ export async function downloadLanguageServer(): Promise<void> {
158158
if (!fs.existsSync(path.join(resourcesDir, 'servers', 'aws-lsp-codewhisperer.js'))) {
159159
throw new Error(`Extracting aws-lsp-codewhisperer.js failure`)
160160
}
161-
if (!fs.existsSync(path.join(resourcesDir, 'clients', 'amazonq-ui.js'))) {
161+
// Check for amazonq-ui.js in both locations for backwards compatibility (moved from clients.zip to servers.zip)
162+
const amazonqUiInClients = fs.existsSync(path.join(resourcesDir, 'clients', 'amazonq-ui.js'))
163+
const amazonqUiInServers = fs.existsSync(path.join(resourcesDir, 'servers', 'amazonq-ui.js'))
164+
if (!amazonqUiInClients && !amazonqUiInServers) {
162165
throw new Error(`Extracting amazonq-ui.js failure`)
163166
}
164167
console.log('Download and extraction completed successfully')

0 commit comments

Comments
 (0)