From a7d851146a5348163e4e6fa3248b3f86d6a4e8b3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sat, 21 Feb 2026 13:55:11 -0800 Subject: [PATCH] feat(core): remove unnecessary login verbiage from Code Assist auth (#19861) --- packages/core/src/code_assist/oauth2.ts | 5 ++--- packages/core/src/utils/authConsent.test.ts | 19 +++++++++++++++++++ packages/core/src/utils/authConsent.ts | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/core/src/code_assist/oauth2.ts b/packages/core/src/code_assist/oauth2.ts index bfa50599c7..7ee3fbe02e 100644 --- a/packages/core/src/code_assist/oauth2.ts +++ b/packages/core/src/code_assist/oauth2.ts @@ -271,7 +271,7 @@ async function initOauthClient( await triggerPostAuthCallbacks(client.credentials); } else { - const userConsent = await getConsentForOauth('Code Assist login required.'); + const userConsent = await getConsentForOauth(''); if (!userConsent) { throw new FatalCancellationError('Authentication cancelled by user.'); } @@ -281,8 +281,7 @@ async function initOauthClient( coreEvents.emit(CoreEvent.UserFeedback, { severity: 'info', message: - `\n\nCode Assist login required.\n` + - `Attempting to open authentication page in your browser.\n` + + `\n\nAttempting to open authentication page in your browser.\n` + `Otherwise navigate to:\n\n${webLogin.authUrl}\n\n\n`, }); try { diff --git a/packages/core/src/utils/authConsent.test.ts b/packages/core/src/utils/authConsent.test.ts index c46df2d250..7fc05b2a03 100644 --- a/packages/core/src/utils/authConsent.test.ts +++ b/packages/core/src/utils/authConsent.test.ts @@ -56,6 +56,25 @@ describe('getConsentForOauth', () => { ); }); + it('should handle empty prompt correctly', async () => { + const mockEmitConsentRequest = vi.spyOn(coreEvents, 'emitConsentRequest'); + vi.spyOn(coreEvents, 'listenerCount').mockReturnValue(1); + + mockEmitConsentRequest.mockImplementation((payload) => { + payload.onConfirm(true); + }); + + await getConsentForOauth(''); + + expect(mockEmitConsentRequest).toHaveBeenCalledWith( + expect.objectContaining({ + prompt: expect.stringMatching( + /^Opening authentication page in your browser\./, + ), + }), + ); + }); + it('should return false when user declines via UI', async () => { const mockEmitConsentRequest = vi.spyOn(coreEvents, 'emitConsentRequest'); vi.spyOn(coreEvents, 'listenerCount').mockReturnValue(1); diff --git a/packages/core/src/utils/authConsent.ts b/packages/core/src/utils/authConsent.ts index ef8b52b02e..589c922f57 100644 --- a/packages/core/src/utils/authConsent.ts +++ b/packages/core/src/utils/authConsent.ts @@ -15,7 +15,9 @@ import { isHeadlessMode } from './headless.js'; * Handles both interactive and non-interactive (headless) modes. */ export async function getConsentForOauth(prompt: string): Promise { - const finalPrompt = prompt + ' Opening authentication page in your browser. '; + const finalPrompt = + (prompt ? prompt + ' ' : '') + + 'Opening authentication page in your browser. '; if (isHeadlessMode()) { return getOauthConsentNonInteractive(finalPrompt);