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
28 changes: 16 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Added image support to Amazon Q chat, users can now upload images from their local file system"
}
36 changes: 36 additions & 0 deletions packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ChatPromptOptionAcknowledgedMessage,
STOP_CHAT_RESPONSE,
StopChatResponseMessage,
OPEN_FILE_DIALOG,
} from '@aws/chat-client-ui-types'
import {
ChatResult,
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -316,6 +321,19 @@ export function registerMessageListeners(
}
break
}
case OPEN_FILE_DIALOG: {
// openFileDialog is the event emitted from webView to open
// file system
const result = await languageClient.sendRequest<OpenFileDialogResult>(
openFileDialogRequestType.method,
message.params
)
void provider.webview?.postMessage({
command: openFileDialogRequestType.method,
params: result,
})
break
}
case quickActionRequestType.method: {
const quickActionPartialResultToken = uuidv4()
const quickActionDisposable = languageClient.onProgress(
Expand Down Expand Up @@ -461,6 +479,24 @@ export function registerMessageListeners(
}
})

languageClient.onRequest(ShowOpenDialogRequestType.method, async (params: ShowOpenDialogParams) => {
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<ShowDocumentParams, ShowDocumentResult>(
ShowDocumentRequest.method,
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
Expand Down
1 change: 1 addition & 0 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export async function startLanguageServer(
q: {
developerProfiles: true,
pinnedContextEnabled: true,
imageContextEnabled: true,
mcp: true,
reroute: true,
modelSelection: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading