@@ -260,13 +260,30 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
260260 // Generate a cryptographically random state parameter.
261261 const state = crypto . randomBytes ( 16 ) . toString ( "hex" )
262262 await this . context . globalState . update ( AUTH_STATE_KEY , state )
263+
264+ // Resolve the deep link target for the CURRENT VS Code instance.
265+ // In remote/web (e.g. GitHub Codespaces), asExternalUri produces an HTTPS URL
266+ // that routes back to the running instance instead of launching a local VS Code.
263267 const packageJSON = this . context . extension ?. packageJSON
264268 const publisher = packageJSON ?. publisher ?? "RooVeterinaryInc"
265269 const name = packageJSON ?. name ?? "roo-cline"
270+
271+ const deepLink = vscode . Uri . parse ( `${ vscode . env . uriScheme } ://${ publisher } .${ name } ` )
272+
273+ let authRedirect = deepLink . toString ( )
274+ try {
275+ const external = await vscode . env . asExternalUri ( deepLink )
276+ authRedirect = external . toString ( )
277+ } catch ( e ) {
278+ // Fallback to the raw deep link if resolution fails (desktop will still work).
279+ this . log ( `[auth] asExternalUri failed, falling back to deep link: ${ e } ` )
280+ }
281+
266282 const params = new URLSearchParams ( {
267283 state,
268- auth_redirect : ` ${ vscode . env . uriScheme } :// ${ publisher } . ${ name } ` ,
284+ auth_redirect : authRedirect ,
269285 } )
286+
270287 const url = `${ getRooCodeApiUrl ( ) } /extension/sign-in?${ params . toString ( ) } `
271288 await vscode . env . openExternal ( vscode . Uri . parse ( url ) )
272289 } catch ( error ) {
0 commit comments