Skip to content

Commit 392691b

Browse files
committed
feat(lsp): support select images as context
1 parent 3774910 commit 392691b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ChatPromptOptionAcknowledgedMessage,
1717
STOP_CHAT_RESPONSE,
1818
StopChatResponseMessage,
19+
OPEN_FILE_DIALOG,
1920
} from '@aws/chat-client-ui-types'
2021
import {
2122
ChatResult,
@@ -60,6 +61,10 @@ import {
6061
ruleClickRequestType,
6162
pinnedContextNotificationType,
6263
activeEditorChangedNotificationType,
64+
ShowOpenDialogRequestType,
65+
ShowOpenDialogParams,
66+
openFileDialogRequestType,
67+
OpenFileDialogResult,
6368
} from '@aws/language-server-runtimes/protocol'
6469
import { v4 as uuidv4 } from 'uuid'
6570
import * as vscode from 'vscode'
@@ -316,6 +321,17 @@ export function registerMessageListeners(
316321
}
317322
break
318323
}
324+
case OPEN_FILE_DIALOG: {
325+
const result = await languageClient.sendRequest<OpenFileDialogResult>(
326+
openFileDialogRequestType.method,
327+
message.params
328+
)
329+
void provider.webview?.postMessage({
330+
command: openFileDialogRequestType.method,
331+
params: result,
332+
})
333+
break
334+
}
319335
case quickActionRequestType.method: {
320336
const quickActionPartialResultToken = uuidv4()
321337
const quickActionDisposable = languageClient.onProgress(
@@ -461,6 +477,19 @@ export function registerMessageListeners(
461477
}
462478
})
463479

480+
languageClient.onRequest(ShowOpenDialogRequestType.method, async (params: ShowOpenDialogParams) => {
481+
const uris = await vscode.window.showOpenDialog({
482+
canSelectFiles: params.canSelectFiles ?? true,
483+
canSelectFolders: params.canSelectFolders ?? false,
484+
canSelectMany: params.canSelectMany ?? false,
485+
filters: params.filters,
486+
defaultUri: params.defaultUri ? vscode.Uri.parse(params.defaultUri) : undefined,
487+
title: params.title,
488+
})
489+
const urisString = uris?.map((uri) => uri.toString())
490+
return { uris: urisString || [] }
491+
})
492+
464493
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
465494
ShowDocumentRequest.method,
466495
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {

0 commit comments

Comments
 (0)