diff --git a/src/hosts/external/AuthHandler.ts b/src/hosts/external/AuthHandler.ts index 8983222a..0fe6fbd0 100644 --- a/src/hosts/external/AuthHandler.ts +++ b/src/hosts/external/AuthHandler.ts @@ -162,7 +162,18 @@ export class AuthHandler { // Use SharedUriHandler directly - it handles all validation and processing const success = await SharedUriHandler.handleUri(fullUrl) - const redirectUri = (await HostProvider.env.getIdeRedirectUri({})).value + + // Try to get redirect URI, but don't fail if not implemented (CLI/JetBrains) + let redirectUri: string | undefined + try { + redirectUri = (await HostProvider.env.getIdeRedirectUri({})).value + console.log("AuthHandler: Got redirect URI:", redirectUri) + } catch (error) { + // CLI or JetBrains mode - redirect not available + console.log("AuthHandler: No redirect URI available (CLI/JetBrains mode)") + redirectUri = undefined + } + const html = createAuthSucceededHtml(redirectUri) if (success) { @@ -206,6 +217,8 @@ export class AuthHandler { function createAuthSucceededHtml(redirectUri?: string): string { const redirect = redirectUri ? `` : "" + // Use "terminal" for CLI (no redirect), "IDE" for VSCode/JetBrains (with redirect) + const platform = redirectUri ? "IDE" : "terminal" const html = ` @@ -305,8 +318,8 @@ function createAuthSucceededHtml(redirectUri?: string): string {

Authentication Successful

-

Your authentication token has been securely sent back to your IDE. You can now return to your development environment to continue working.

-
Feel free to close this window and continue in your IDE
+

Your authentication token has been securely sent back to your ${platform}. You can now return to your development environment to continue working.

+
Feel free to close this window and continue in your ${platform}
`