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
15 changes: 15 additions & 0 deletions packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,21 @@ export function registerMessageListeners(
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
try {
const uri = vscode.Uri.parse(params.uri)

if (params.external) {
// Note: Not using openUrl() because we probably don't want telemetry for these URLs.
// Also it doesn't yet support the required HACK below.

// HACK: workaround vscode bug: https://github.com/microsoft/vscode/issues/85930
vscode.env.openExternal(params.uri as any).then(undefined, (e) => {
// TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e)
vscode.env.openExternal(uri).then(undefined, (e) => {
// TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e)
})
})
return params
}

const doc = await vscode.workspace.openTextDocument(uri)
await vscode.window.showTextDocument(doc, { preview: false })
return params
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/shared/utilities/vsCodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ export function reloadWindowPrompt(message: string): void {
* if user dismisses the vscode confirmation prompt.
*/
export async function openUrl(url: vscode.Uri, source?: string): Promise<boolean> {
// Avoid PII in URL.
const truncatedUrl = `${url.scheme}${url.authority}${url.path}${url.fragment.substring(20)}`

return telemetry.aws_openUrl.run(async (span) => {
span.record({ url: url.toString(), source })
span.record({ url: truncatedUrl, source })
const didOpen = await vscode.env.openExternal(url)
if (!didOpen) {
throw new CancellationError('user')
Expand Down
Loading