Repository navigation
fix(claude-account): stash the displaced default login instead of adopting it - #10153
Conversation
…pting it With "switch login on card switch" on, switching to a card bound to another account used to adopt the default slot's login as a new account when it was not collected yet. It now goes into a private stash slot (<data>/claude-login-stash/<sha256(key)[..16]>/config) that is not listed in the account table, so a login is never collected without the user's consent but is also not lost. The stash location is derived from the account key, so no index is kept. When a later step fails, check_back restores the previous login and deletes the stash; startup recovery falls back to the stash when before_owner is not an account; formally adding the same account later drops its stash. Adopter, Ctx.adopter, DiskAccounts::adopt and Outcome::Switched.adopted are removed.
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2f8170e97
ℹ️ 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".
| check_out(ctx, previous, dir)?; | ||
| if layout::is_stash_dir(ctx.data_dir, dir) { | ||
| if let Err(error) = super::discard_stash(ctx, dir) { |
There was a problem hiding this comment.
Preserve the stash until rollback finishing has completed
If restoring the stashed login commits its credentials but finish fails—for example, because Claude Code holds the default profile's configuration lock—check_out still returns success and leaves a Committed journal for recovery. Deleting the stash here removes the only profile that recover_locked can use to finish that rollback: the restored account is not in ctx.accounts, and recovery searches only the journal's target directory and the registered account directory. This can leave the restored credentials paired with the other account's profile, with recovery unable to repair it. Retain the stash until finishing succeeds, or defer deletion until recovery completes.
Useful? React with 👍 / 👎.
Human Note / 本人说明
用户不希望在未经他允许的下,把已经登录的账号收入到授权中心里面。尤其是 Claude、Antigravity、Codex 这三个应用。
Summary / 概述
With "switch login on card switch" enabled, switching to a card bound to another Claude account used to adopt the login sitting in the default slot as a new account in the Auth Center whenever it was not collected yet. This PR keeps that login safe without collecting it, following the Codex login-stash precedent.
开启「切卡时切换登录」后,切到绑了其他账号的官方卡时,默认槽位里原来那个没收录的号会被自动收录成新账号。现在改为放进隐藏暂存,不进授权中心,也不会丢。
<data>/claude-login-stash/<sha256(key)[..16]>/config, an ordinary account slot (own keychain entry /.credentials.json) that is not listed inclaude_accounts.jsonand not shown in the UI.check_backrestores the previous login from the stash and then deletes the stash (credentials and directory).before_owneris not an account in the table.Adopter,Ctx.adopter,DiskAccounts::adoptand the unusedOutcome::Switched.adoptedare removed.Companion change for Antigravity / WorkBuddy is pushed to #10140.
Related Issue / 关联 Issue
Related to #10140
Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查 (no frontend change)pnpm format:checkpasses / 通过代码格式检查 (no frontend change)cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)Local:
cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test(lib 5224 + integration 233) all pass. Tests use temp dirs and an in-memory credential store; not tested against a real keychain yet.