From f8ebacaf84fde5e8002911097f6279851adbc6c5 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Mon, 9 Jun 2025 13:17:35 -0700 Subject: [PATCH 1/6] feat(lsp): support select images as context --- packages/amazonq/src/lsp/chat/messages.ts | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 74b56a9bada..a0548b1349d 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -16,6 +16,7 @@ import { ChatPromptOptionAcknowledgedMessage, STOP_CHAT_RESPONSE, StopChatResponseMessage, + OPEN_FILE_DIALOG, } from '@aws/chat-client-ui-types' import { ChatResult, @@ -60,6 +61,10 @@ import { ruleClickRequestType, pinnedContextNotificationType, activeEditorChangedNotificationType, + ShowOpenDialogRequestType, + ShowOpenDialogParams, + openFileDialogRequestType, + OpenFileDialogResult, } from '@aws/language-server-runtimes/protocol' import { v4 as uuidv4 } from 'uuid' import * as vscode from 'vscode' @@ -316,6 +321,17 @@ export function registerMessageListeners( } break } + case OPEN_FILE_DIALOG: { + const result = await languageClient.sendRequest( + openFileDialogRequestType.method, + message.params + ) + void provider.webview?.postMessage({ + command: openFileDialogRequestType.method, + params: result, + }) + break + } case quickActionRequestType.method: { const quickActionPartialResultToken = uuidv4() const quickActionDisposable = languageClient.onProgress( @@ -461,6 +477,19 @@ export function registerMessageListeners( } }) + languageClient.onRequest(ShowOpenDialogRequestType.method, async (params: ShowOpenDialogParams) => { + const uris = await vscode.window.showOpenDialog({ + canSelectFiles: params.canSelectFiles ?? true, + canSelectFolders: params.canSelectFolders ?? false, + canSelectMany: params.canSelectMany ?? false, + filters: params.filters, + defaultUri: params.defaultUri ? vscode.Uri.parse(params.defaultUri) : undefined, + title: params.title, + }) + const urisString = uris?.map((uri) => uri.toString()) + return { uris: urisString || [] } + }) + languageClient.onRequest( ShowDocumentRequest.method, async (params: ShowDocumentParams): Promise> => { From 7b764209aafcc5499fb07f8370b485d0917d0f33 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Mon, 23 Jun 2025 17:51:08 -0700 Subject: [PATCH 2/6] feat(amazonq): fix build fail --- package-lock.json | 28 ++++++++++++++++------------ packages/core/package.json | 6 +++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64f84b7a2b8..b157d768908 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15033,20 +15033,23 @@ } }, "node_modules/@aws/chat-client-ui-types": { - "version": "0.1.26", + "version": "0.1.47", + "resolved": "https://registry.npmjs.org/@aws/chat-client-ui-types/-/chat-client-ui-types-0.1.47.tgz", + "integrity": "sha512-Pu6UnAImpweLMcAmhNdw/NrajB25Ymzp1Om1V9NEVQJRMO/KJCDiErmbOYTYBXvgNoR10kObqiL1P/Tk/Fpu3g==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@aws/language-server-runtimes-types": "^0.1.22" + "@aws/language-server-runtimes-types": "^0.1.41" } }, "node_modules/@aws/language-server-runtimes": { - "version": "0.2.97", - "resolved": "https://registry.npmjs.org/@aws/language-server-runtimes/-/language-server-runtimes-0.2.97.tgz", - "integrity": "sha512-Wzt09iC5YTVRJmmW6DwunBFSR0mV+cHjDwJ5iic1sEvXlI9CnrxlEjfn09crkVQ2XZj3dNJHoLQPptH+AEQfNg==", + "version": "0.2.99", + "resolved": "https://registry.npmjs.org/@aws/language-server-runtimes/-/language-server-runtimes-0.2.99.tgz", + "integrity": "sha512-WLMEHhWDgsJW2FAYDX6bxQ7NvR47I9H63SXIDbCEnZQdC9/OnKBdl0IJ8bWYQ256xaI9QVof7/YUXFSzNfV7DA==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@aws/language-server-runtimes-types": "^0.1.39", + "@aws/language-server-runtimes-types": "^0.1.41", "@opentelemetry/api": "^1.9.0", "@opentelemetry/api-logs": "^0.200.0", "@opentelemetry/core": "^2.0.0", @@ -15073,10 +15076,11 @@ } }, "node_modules/@aws/language-server-runtimes-types": { - "version": "0.1.39", - "resolved": "https://registry.npmjs.org/@aws/language-server-runtimes-types/-/language-server-runtimes-types-0.1.39.tgz", - "integrity": "sha512-HjZ9tYcs++vcSyNwCcGLC8k1nvdWTD7XRa6sI71OYwFzJvyMa4/BY7Womq/kmyuD/IB6MRVvuRdgYQxuU1mSGA==", + "version": "0.1.41", + "resolved": "https://registry.npmjs.org/@aws/language-server-runtimes-types/-/language-server-runtimes-types-0.1.41.tgz", + "integrity": "sha512-Ejupyj9560P6wQ9d9miSkgmEOUEczuc7mrFA727KmwXzp8yocNKonecdAn4r+CBxuPcbOaXDdyywK08cvAruig==", "dev": true, + "license": "Apache-2.0", "dependencies": { "vscode-languageserver-textdocument": "^1.0.12", "vscode-languageserver-types": "^3.17.5" @@ -30068,9 +30072,9 @@ "devDependencies": { "@aws-sdk/types": "^3.13.1", "@aws/chat-client": "^0.1.4", - "@aws/chat-client-ui-types": "^0.1.24", - "@aws/language-server-runtimes": "^0.2.97", - "@aws/language-server-runtimes-types": "^0.1.39", + "@aws/chat-client-ui-types": "^0.1.47", + "@aws/language-server-runtimes": "^0.2.99", + "@aws/language-server-runtimes-types": "^0.1.41", "@cspotcode/source-map-support": "^0.8.1", "@sinonjs/fake-timers": "^10.0.2", "@types/adm-zip": "^0.4.34", diff --git a/packages/core/package.json b/packages/core/package.json index 7371d41159b..fd57e94d97f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -470,9 +470,9 @@ "devDependencies": { "@aws-sdk/types": "^3.13.1", "@aws/chat-client": "^0.1.4", - "@aws/chat-client-ui-types": "^0.1.24", - "@aws/language-server-runtimes": "^0.2.97", - "@aws/language-server-runtimes-types": "^0.1.39", + "@aws/chat-client-ui-types": "^0.1.47", + "@aws/language-server-runtimes": "^0.2.99", + "@aws/language-server-runtimes-types": "^0.1.41", "@cspotcode/source-map-support": "^0.8.1", "@sinonjs/fake-timers": "^10.0.2", "@types/adm-zip": "^0.4.34", From 69b219616bdddc68000444923fe1e8ff5214b503 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Wed, 25 Jun 2025 10:43:43 -0700 Subject: [PATCH 3/6] add feature flag --- packages/amazonq/src/lsp/client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index df2e29c3149..b96d0ef8b60 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -163,6 +163,7 @@ export async function startLanguageServer( q: { developerProfiles: true, pinnedContextEnabled: true, + imageContextEnabled: true, mcp: true, reroute: true, modelSelection: true, From bc726297ff391af54ce47645370a6d42b6fc3eab Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Sat, 28 Jun 2025 13:30:52 -0700 Subject: [PATCH 4/6] change to use fsPath --- packages/amazonq/src/lsp/chat/messages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index a0548b1349d..161b2bd518a 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -486,7 +486,7 @@ export function registerMessageListeners( defaultUri: params.defaultUri ? vscode.Uri.parse(params.defaultUri) : undefined, title: params.title, }) - const urisString = uris?.map((uri) => uri.toString()) + const urisString = uris?.map((uri) => uri.fsPath) return { uris: urisString || [] } }) From 56dd5baa995ffaa860b3ea10926f0bf73e7e0ee4 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Tue, 8 Jul 2025 18:27:47 -0700 Subject: [PATCH 5/6] feat(amazonq): fix comments --- ...-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json | 4 +++ packages/amazonq/src/lsp/chat/messages.ts | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json diff --git a/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json b/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json new file mode 100644 index 00000000000..0866b9a8e91 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "support adding image context from file system" +} diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 161b2bd518a..b44ada0a134 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -322,6 +322,8 @@ export function registerMessageListeners( break } case OPEN_FILE_DIALOG: { + // openFileDialog is the event emitted from webView to open + // file system const result = await languageClient.sendRequest( openFileDialogRequestType.method, message.params @@ -478,16 +480,21 @@ export function registerMessageListeners( }) languageClient.onRequest(ShowOpenDialogRequestType.method, async (params: ShowOpenDialogParams) => { - const uris = await vscode.window.showOpenDialog({ - canSelectFiles: params.canSelectFiles ?? true, - canSelectFolders: params.canSelectFolders ?? false, - canSelectMany: params.canSelectMany ?? false, - filters: params.filters, - defaultUri: params.defaultUri ? vscode.Uri.parse(params.defaultUri) : undefined, - title: params.title, - }) - const urisString = uris?.map((uri) => uri.fsPath) - return { uris: urisString || [] } + try { + const uris = await vscode.window.showOpenDialog({ + canSelectFiles: params.canSelectFiles ?? true, + canSelectFolders: params.canSelectFolders ?? false, + canSelectMany: params.canSelectMany ?? false, + filters: params.filters, + defaultUri: params.defaultUri ? vscode.Uri.parse(params.defaultUri, false) : undefined, + title: params.title, + }) + const urisString = uris?.map((uri) => uri.fsPath) + return { uris: urisString || [] } + } catch (err) { + languageClient.error(`[VSCode Client] Failed to open file dialog: ${(err as Error).message}`) + return { uris: [] } + } }) languageClient.onRequest( From b6efb948ade11c2e4634088d7e3f058f4ba9118b Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Tue, 8 Jul 2025 19:05:30 -0700 Subject: [PATCH 6/6] feat(amazonq): refactor change log --- .../Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json b/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json index 0866b9a8e91..f3684999e6f 100644 --- a/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json +++ b/packages/amazonq/.changes/next-release/Feature-a93aa3b3-83cd-45bb-81d9-4ad25e783300.json @@ -1,4 +1,4 @@ { "type": "Feature", - "description": "support adding image context from file system" + "description": "Added image support to Amazon Q chat, users can now upload images from their local file system" }