fix(desktop): recover auth after credential backend failure - #3960
fix(desktop): recover auth after credential backend failure#3960dashhuang wants to merge 2 commits into
Conversation
Signed-off-by: Cindy <cindy@Cindys-Mac-mini.local>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/authCredentialRecovery.ts | 新增一次性、解锁感知且等待任务空闲的凭证故障重启状态机。 |
| apps/desktop/src/main/bootstrap-electron.ts | 接入恢复状态机及统一重启忙碌来源,但探针未阻止正在进行的认证流程。 |
| apps/desktop/src/main/authManager.ts | 诊断 safeStorage 后端故障、保留启动失败状态,并向登录流程提供可恢复错误。 |
| apps/desktop/src/main/authBrowserLaunch.ts | 为不可取消的系统浏览器启动增加取消、失败和 15 秒超时边界。 |
| apps/desktop/src/main/authHostedCallback.ts | 将 hosted 授权总超时从静默取消调整为明确的 REQUEST_TIMEOUT。 |
| apps/desktop/src/renderer/components/login/LoginPage.tsx | 复用现有错误面板展示保存登录仍被保留的凭证故障提示。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[启动读取保存凭证] --> B{凭证后端可用?}
B -->|是| C[恢复登录]
B -->|否| D[记录 CREDENTIAL_STORE_UNAVAILABLE]
D --> E[等待屏幕可用并延迟 3 秒]
E --> F{任务忙碌?}
F -->|是| G[30 秒后重试]
G --> F
F -->|否| H[携带一次性标记重启]
H --> I{新进程读取成功?}
I -->|是| C
I -->|否| J[停止自动重启并显示恢复提示]
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/main/bootstrap-electron.ts:3063-3071
**认证期间可能自动重启**
凭证故障后,如果用户在 3 秒延迟内点击重试并开始登录,`needsCredentialProcessRecovery()` 在登录提交前仍为 true。这里的忙碌探针没有检查登录 action、浏览器授权或后台冷启动认证,因此可能误判为空闲并执行 `app.relaunch()`/`app.quit()`,中断正在进行的认证。请将这些认证活动纳入重启阻断条件。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(desktop): recover auth after credent..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47b8dce481
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/bootstrap-electron.ts / apps/desktop/src/main/authManager.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
命中 UI 路径(apps/desktop/src/renderer/components/login/LoginPage.tsx)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
Signed-off-by: Cindy <cindy@Cindys-Mac-mini.local>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5746376024
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return finishColdStartSignedOut('cold-start-credential-reconcile-unavailable'); | ||
| return finishColdStartSignedOut( | ||
| 'cold-start-credential-reconcile-unavailable', | ||
| error instanceof AuthApiError && error.code === 'CREDENTIAL_STORE_UNAVAILABLE', |
There was a problem hiding this comment.
Distinguish corrupt vaults from restartable backend failures
When the encrypted account vault contains invalid JSON/schema, readAuthAccountVault() also throws CREDENTIAL_STORE_UNAVAILABLE, so this marks the credential-store health unavailable even though safeStorage.isEncryptionAvailable() succeeded. In that case automatic process recovery is ineligible, getLoginState() keeps returning the recovery error, and runLoginAction() blocks every action except reset; reset reruns the same strict parse indefinitely. This removes the previous explicit-login path that used recoverInvalidForExplicitLogin: true to repair an invalid vault, leaving affected users unable to sign in or enter local mode. Only classify an observed encryption-backend failure as restartable, or preserve a route to the explicit-login recovery path for malformed records.
Useful? React with 👍 / 👎.
|
@dashhuang 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/authManager.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
@dashhuang 👋 这个 PR 目前与 请在本地 merge 最新的 |
这次改了什么
摘要
修复 macOS 上 safeStorage 首次读取失败后登录状态显示异常的问题。Electron 会在进程内缓存该失败,Cindy 现在会在解锁且没有运行中任务时自动正常重启一次,重启后恢复已保存登录;同时为浏览器启动增加独立超时和明确错误。
变更类型
fix缺陷修复范围
UI 变化
docs/design-rules/DESIGN.md双模式交付门槛;复用现有登录错误面板和语义主题 token,新增文案已覆盖五种 locale。怎么验证的
自动验证
手工验证
不涉及:当前 worktree 未安装到正在运行的 Cindy.app,未执行真实锁屏重启。
未执行的验证
真实 macOS 锁屏 / 钥匙串拒绝场景未执行,原因是需要在用户运行客户端上复现;系统日志对历史故障没有保留原始 Keychain OSStatus。
风险
风险分类
影响与回滚
提交前检查
git commit -s)