feat(core): remove unnecessary login verbiage from Code Assist auth (#19861)

This commit is contained in:
N. Taylor Mullen
2026-02-21 13:55:11 -08:00
committed by GitHub
parent acb7f577de
commit a7d851146a
3 changed files with 24 additions and 4 deletions

View File

@@ -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);

View File

@@ -15,7 +15,9 @@ import { isHeadlessMode } from './headless.js';
* Handles both interactive and non-interactive (headless) modes.
*/
export async function getConsentForOauth(prompt: string): Promise<boolean> {
const finalPrompt = prompt + ' Opening authentication page in your browser. ';
const finalPrompt =
(prompt ? prompt + ' ' : '') +
'Opening authentication page in your browser. ';
if (isHeadlessMode()) {
return getOauthConsentNonInteractive(finalPrompt);