修正 Claude 登录失效后的账号判断与提示 - #716
Merged
Merged
Conversation
A refusal is kept for the credential it was made on (savedLogin.Refused) and holds only while the account still has that credential. One check, claudeSignedOut, decides whether a saved Claude login can be used, after syncClaudeDir has read what Claude Code keeps in the account's directory: a credential it refreshed to there is taken, and one it emptied (as Claude Code 2.1.x does after Anthropic answers invalid_grant) is refused. Token is the only gate: a saved account's directory, or the credential Claude Code itself holds for its own account. Lapsed accounts stay candidates, so the trace shows each one passed over and the agent is told to sign in again when none is left. This fixes four paths of the first version: a moment the own sign-in could not be read left it lapsed after it came back unchanged; a credential refreshed in the account's directory after a refusal was ignored; a switch could restore a copy Claude Code had emptied; and with every account refused the agent got "none of ... is ready" (404).
Owner
|
感谢这个 PR!核心思路(按凭据版本记录拒绝、Claude Code 清空凭据后不再写回、刷新/重新登录后自动恢复)我在沙盒里验证过,
改完后我再拉下来跑一遍。 |
Address the review of yetone#716: - A refused sign-in is failAuth only for a Claude account (failureOf); another vendor with the same words rests as before. - The account list's sign-in-required row is Claude's only, and the account Claude Code is signed in to offers no Remove. - Add the missing zh string for "its sign-in is gone; sign in again". - readOutput checks the error before reading Claude Code's sign-in, and the owner is parsed in one place (ownerAccount). TestSignInWordsFromAnotherVendorRest and the new browser case in claude-auth-status.test.cjs fail on the previous commit and pass.
Contributor
Author
|
感谢细致的 review!已按这 4 点修改(eceedde):
验证: |
Owner
|
已合并并随 v0.1.788 发布,感谢 @Koohoko!我把这 4 点修改拉下来合到当前 main 上跑了 go vet、三平台构建、全部 Go 测试,以及 claude-auth-status、account-*、keep-login 等 GUI 测试,都通过。 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code 返回
OAuth session expired and could not be refreshed后,magpie 仍把账号当作临时故障,显示“正在休息”并继续重试。连接测试成功时也没有注明测试的账号,容易让用户误以为所有账号都正常。多账号用户需要 magpie 跳过失效登录、继续使用其他账号,并明确说明哪些账号需要重新登录;凭据恢复后,也应该自动恢复使用。
本 PR:
OAuth 续期仍由 Claude Code 负责,本 PR 修正 magpie 对登录失效的判断和处理。
验证:全量 Go 测试、相关 race 检查、三平台构建及 16 项中英文浏览器测试通过。测试使用模拟凭据,尚未用真实失效账号做端到端验证。
关联 #53、#524。
🎬 界面预览
CI 用这个 PR 的代码构建并真实运行 magpie(沙盒环境,配置了真实的 DeepSeek key),按改动自动操作、截图和录屏 ·
eceedde· 运行记录改动(按代码):Claude 账号登录被 Anthropic 拒绝时,供应商页的账号行改为显示「需要重新登录」、禁用启用开关并提供「重新登录」按钮(不再计入可用账号、不再让位给暂停/设为首选),路由页为这类失败新增「需要重新登录」的说法与说明文案,连接测试结果会注明所测账号。
Note
沙盒里看不到:沙盒只有 DeepSeek 一个供应商,没有任何 Claude/Codex 订阅账号,也没有失效登录的数据:供应商页里的 Claude 账号行(「需要重新登录」标签、被禁用的圆点、「重新登录」/「移除」按钮)、连接测试结果里的「已测试 {user}:…」前缀、以及路由页请求步骤中的认证失败说明,都不会出现——路由页只有成功的 DeepSeek 请求,所以只能看到这些改动所在的位置。
供应商页:账号行与连接测试的位置
供应商列表:这个沙盒里只有 DeepSeek,没有带账号的 Claude Code 供应商
「测试」的结果行显示在这里(此处没有订阅账号可注明)
路由页:失败说明出现的位置
路由页的请求步骤列表:认证失败的说明会出现在这里
这条请求的路由步骤