feat(oauth): show paste input immediately during OpenAI Codex login (#468)

Previously, users had to wait up to 60 seconds for the browser callback
to timeout before being prompted to paste the authorization code. This
was problematic for SSH/VPS sessions where the callback cannot work.

Now the paste input is shown immediately alongside the browser flow:
- Browser callback and manual paste race - whichever completes first wins
- Desktop users: browser callback succeeds, input is cleaned up
- SSH/VPS users: paste code immediately without waiting

Changes:
- Add cancelWait() to OAuth server for early termination of polling loop
- Add onManualCodeInput callback that races with browser callback
- Show paste input immediately in TUI for openai-codex provider
- Clean up input on success, error, or when browser callback wins

Co-authored-by: cc-vps <crcatala+vps@gmail.com>
This commit is contained in:
Christian Catalan 2026-01-05 12:47:58 -05:00 committed by GitHub
parent 817221b79f
commit 05b9d55656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 121 additions and 4 deletions

View file

@ -161,6 +161,8 @@ export class AuthStorage {
onAuth: (info: { url: string; instructions?: string }) => void;
onPrompt: (prompt: { message: string; placeholder?: string }) => Promise<string>;
onProgress?: (message: string) => void;
/** For providers with local callback servers (e.g., openai-codex), races with browser callback */
onManualCodeInput?: () => Promise<string>;
},
): Promise<void> {
let credentials: OAuthCredentials;
@ -186,7 +188,12 @@ export class AuthStorage {
credentials = await loginAntigravity(callbacks.onAuth, callbacks.onProgress);
break;
case "openai-codex":
credentials = await loginOpenAICodex(callbacks);
credentials = await loginOpenAICodex({
onAuth: callbacks.onAuth,
onPrompt: callbacks.onPrompt,
onProgress: callbacks.onProgress,
onManualCodeInput: callbacks.onManualCodeInput,
});
break;
default:
throw new Error(`Unknown OAuth provider: ${provider}`);