Skip to content

fix: add cancel button to ChatGPT login when OAuth in progress#172

Merged
Sun-sunshine06 merged 7 commits intomainfrom
fix/codex-oauth-stuck-loading
Apr 23, 2026
Merged

fix: add cancel button to ChatGPT login when OAuth in progress#172
Sun-sunshine06 merged 7 commits intomainfrom
fix/codex-oauth-stuck-loading

Conversation

@Sun-sunshine06
Copy link
Copy Markdown
Collaborator

Summary

When user starts ChatGPT OAuth login and then closes the browser without completing authorization, the loading state would stay stuck for up to 5 minutes because the waitForCode promise would not resolve/reject until timeout. During this time, the UI was disabled and user couldn't do anything.

Fix this by two improvements:

  1. Add a manual Cancel button when in loading state - user can immediately reset the UI and try login again without waiting for timeout
  2. Shorten callback timeout from 5 minutes → 2 minutes for better UX even if user forgets to cancel

Screenshot

Before (stuck forever / 5min):
image (provided by user)

After (user can cancel):
The loading state now shows a "Cancel" button next to the in-progress button.

Testing

  • Click "Login with ChatGPT Plus"
  • Browser opens → close browser immediately
  • Back to app → click "Cancel"
  • UI resets, you can click login again

Checklist

  • Code is typed with TypeScript (strict: true)
  • Pre-push typecheck + lint passes
  • Fix follows project conventions (no new dependencies, minimal changes)
  • Fix addresses the root cause (user closes browser → no code arrives → stuck)

Co-Authored-By: Claude Opus 4.7 [email protected]

@github-actions github-actions Bot added docs Documentation area:desktop apps/desktop (Electron shell, renderer) area:core packages/core (generation orchestration) area:providers packages/providers (pi-ai adapter, model calls) labels Apr 22, 2026
When user starts ChatGPT OAuth login and then closes the browser without
completing authorization, the loading state would stay stuck for up to
5 minutes because the waitForCode promise would not resolve/reject until
timeout.

Fix this by:
1. Adding a manual Cancel button when in loading state so user can
   immediately reset the UI and try again
2. Shorten callback timeout from 5min → 2min for better UX

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Signed-off-by: Sun-sunshine06 <[email protected]>
@Sun-sunshine06 Sun-sunshine06 force-pushed the fix/codex-oauth-stuck-loading branch from 5d6fa7d to 623a297 Compare April 22, 2026 16:03
# Conflicts:
#	packages/providers/src/index.ts
@github-actions github-actions Bot removed docs Documentation area:core packages/core (generation orchestration) labels Apr 22, 2026
@hqhq1025 hqhq1025 closed this Apr 23, 2026
@hqhq1025 hqhq1025 reopened this Apr 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Major] Garbled localized strings introduced in OAuth provider metadata and error messaging — this regresses user-facing copy quality and can confuse users during login failures, evidence apps/desktop/src/main/codex-oauth-ipc.ts:43, apps/desktop/src/main/codex-oauth-ipc.ts:174
    Suggested fix:

    const CHATGPT_CODEX_PROVIDER: ProviderEntry = {
      id: CHATGPT_CODEX_PROVIDER_ID,
      name: 'ChatGPT 订阅',
      // ...
    };
    
    throw new CodesignError(
      'Codex 登录成功但无法读取 ChatGPT 账户 ID,请重试登录。',
      ERROR_CODES.PROVIDER_ERROR,
      { cause: null },
    );
  • [Major] Cancel action has no error handling, so IPC failures are not surfaced in UI — this violates the “no silent fallbacks” constraint on the newly added cancel path, evidence apps/desktop/src/renderer/src/components/ChatgptLoginCard.tsx:169
    Suggested fix:

    const handleCancel = useCallback(async () => {
      if (!window.codesign) return;
      try {
        const cancelled = await window.codesign.codexOAuth.cancelLogin();
        if (!cancelled && mountedRef.current) setLoading(false);
      } catch (err) {
        if (mountedRef.current) setLoading(false);
        pushToast({
          variant: 'error',
          title: t('settings.providers.chatgptLogin.loginFailedTitle'),
          description: err instanceof Error ? err.message : t('settings.providers.chatgptLogin.unknownError'),
        });
      }
    }, [pushToast, t]);

Summary

  • Review mode: initial
  • 2 issues found on modified lines. docs/VISION.md and docs/PRINCIPLES.md are Not found in repo/docs in this checkout, so doc-level constraint cross-check relied on CLAUDE.md plus code-level validation.

Testing

  • Not run (automation)
  • Suggested: add a renderer unit test for cancel-path IPC rejection to assert toast + loading reset behavior.

open-codesign Bot

const CHATGPT_CODEX_PROVIDER: ProviderEntry = {
id: CHATGPT_CODEX_PROVIDER_ID,
name: 'ChatGPT 订阅',
name: 'ChatGPT 璁㈤槄',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] name appears mojibake ("ChatGPT 璁㈤槄") and is user-visible. Please restore the intended localized string (e.g. ChatGPT 订阅).


const handleCancel = useCallback(async () => {
if (!window.codesign) return;
const cancelled = await window.codesign.codexOAuth.cancelLogin();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] cancelLogin() errors are unhandled here. Please catch and surface via toast (and reset loading) so cancel-path failures are not silent.

@Sun-sunshine06 Sun-sunshine06 merged commit 803a735 into main Apr 23, 2026
12 of 13 checks passed
@Sun-sunshine06 Sun-sunshine06 deleted the fix/codex-oauth-stuck-loading branch April 23, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:desktop apps/desktop (Electron shell, renderer) area:providers packages/providers (pi-ai adapter, model calls)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants