fix: add cancel button to ChatGPT login when OAuth in progress#172
fix: add cancel button to ChatGPT login when OAuth in progress#172Sun-sunshine06 merged 7 commits intomainfrom
Conversation
Signed-off-by: Sun-sunshine06 <[email protected]>
Signed-off-by: Sun-sunshine06 <[email protected]>
Signed-off-by: Sun-sunshine06 <[email protected]>
Signed-off-by: Sun-sunshine06 <[email protected]>
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]>
5d6fa7d to
623a297
Compare
# Conflicts: # packages/providers/src/index.ts
There was a problem hiding this comment.
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.mdanddocs/PRINCIPLES.mdare Not found in repo/docs in this checkout, so doc-level constraint cross-check relied onCLAUDE.mdplus 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 璁㈤槄', |
There was a problem hiding this comment.
[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(); |
There was a problem hiding this comment.
[Major] cancelLogin() errors are unhandled here. Please catch and surface via toast (and reset loading) so cancel-path failures are not silent.
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
waitForCodepromise would not resolve/reject until timeout. During this time, the UI was disabled and user couldn't do anything.Fix this by two improvements:
Screenshot
Before (stuck forever / 5min):
(provided by user)
After (user can cancel):
The loading state now shows a "Cancel" button next to the in-progress button.
Testing
Checklist
strict: true)Co-Authored-By: Claude Opus 4.7 [email protected]