@@ -26,6 +26,11 @@ import {
2626 ShowMessageRequest ,
2727 ShowMessageRequestParams ,
2828 ConnectionMetadata ,
29+ ShowDocumentRequest ,
30+ ShowDocumentParams ,
31+ ShowDocumentResult ,
32+ ResponseError ,
33+ LSPErrorCodes ,
2934} from '@aws/language-server-runtimes/protocol'
3035import { AuthUtil , CodeWhispererSettings , getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
3136import {
@@ -41,9 +46,10 @@ import {
4146 isAmazonInternalOs ,
4247 fs ,
4348 oidcClientName ,
49+ openUrl ,
4450} from 'aws-core-vscode/shared'
4551import { processUtils } from 'aws-core-vscode/shared'
46- import { activate } from './chat/activation'
52+ import { activate as activateChat } from './chat/activation'
4753import { AmazonQResourcePaths } from './lspInstaller'
4854import { auth2 } from 'aws-core-vscode/auth'
4955import { ConfigSection , isValidConfigSection , toAmazonQLSPLogLevel } from './config'
@@ -127,7 +133,7 @@ export async function startLanguageServer(
127133 name : env . appName ,
128134 version : version ,
129135 extension : {
130- name : clientName ,
136+ name : 'AmazonQ-For-VSCode' ,
131137 version : '0.0.1' ,
132138 } ,
133139 clientId : crypto . randomUUID ( ) ,
@@ -186,6 +192,31 @@ export async function startLanguageServer(
186192 }
187193 )
188194
195+ client . onRequest < ShowDocumentParams , ShowDocumentResult > (
196+ ShowDocumentRequest . method ,
197+ async ( params : ShowDocumentParams ) : Promise < ShowDocumentParams | ResponseError < ShowDocumentResult > > => {
198+ try {
199+ const uri = vscode . Uri . parse ( params . uri )
200+ if ( uri . scheme . startsWith ( 'http' ) ) {
201+ try {
202+ await openUrl ( vscode . Uri . parse ( params . uri ) )
203+ return params
204+ } catch ( err : any ) {
205+ getLogger ( ) . error ( `Failed to open http from LSP: error: %s` , err )
206+ }
207+ }
208+ const doc = await vscode . workspace . openTextDocument ( uri )
209+ await vscode . window . showTextDocument ( doc , { preview : false } )
210+ return params
211+ } catch ( e ) {
212+ return new ResponseError (
213+ LSPErrorCodes . RequestFailed ,
214+ `Failed to open document: ${ ( e as Error ) . message } `
215+ )
216+ }
217+ }
218+ )
219+
189220 const sendProfileToLsp = async ( ) => {
190221 try {
191222 const result = await client . sendRequest ( updateConfigurationRequestType . method , {
@@ -251,7 +282,7 @@ export async function startLanguageServer(
251282 )
252283 }
253284
254- await activate ( client , encryptionKey , resourcePaths . ui )
285+ await activateChat ( client , encryptionKey , resourcePaths . ui )
255286
256287 toDispose . push (
257288 AuthUtil . instance . regionProfileManager . onDidChangeRegionProfile ( sendProfileToLsp ) ,
0 commit comments