Repository navigation
[bugfix] agent: show Claude Code auth failures instead of an empty interrupted reply (#557) #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Birfy
wants to merge
4
commits into
ThinkFlowLab:main
Choose a base branch
from
Birfy:fix/557-claude-auth-visible
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
890c95a
[bugfix] agent: show Claude Code auth failures instead of an empty in…
Birfy d42be1b
Merge remote-tracking branch 'origin/main' into fix/557-claude-auth-v…
Birfy 75ecba0
Merge branch 'main' into fix/557-claude-auth-visible
FayeSpica 273ecc6
[bugfix] agent: keep Claude Code selectable with gateway credentials
Birfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { ChatMessage } from "../backend/chat"; | ||
| import type { Translate } from "../i18n/I18nProvider.tsx"; | ||
|
|
||
| /** Visible reason for a failed assistant turn, or null when the empty-reply placeholder applies. */ | ||
| export function assistantReplyFailure(message: ChatMessage, t: Translate): string | null { | ||
| if (message.errorCode === "authentication_failed") { | ||
| return t("assistant.reply.authenticationFailed"); | ||
| } | ||
| if (message.error && message.status !== "streaming") return message.error; | ||
| return null; | ||
| } | ||
|
|
||
| export function isAuthenticationFailure(message: ChatMessage): boolean { | ||
| return message.errorCode === "authentication_failed" || message.status === "failed"; | ||
| } |
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import type { ChatMessage } from "../src/backend/chat.ts"; | ||
| import { assistantReplyFailure, isAuthenticationFailure } from "../src/canvas/assistantReplyFailure.ts"; | ||
| import { setActiveLocale } from "../src/i18n/messages.ts"; | ||
| import { defaultTranslate } from "../src/canvas/assistantTranslate.ts"; | ||
|
|
||
| function message(overrides: Partial<ChatMessage>): ChatMessage { | ||
| return { | ||
| id: "reply", | ||
| role: "assistant", | ||
| text: "", | ||
| status: "interrupted", | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| test("authentication failure shows a bilingual reason instead of the empty placeholder", () => { | ||
| const failed = message({ status: "failed", errorCode: "authentication_failed", error: "server text" }); | ||
| setActiveLocale("en-US"); | ||
| assert.equal( | ||
| assistantReplyFailure(failed, defaultTranslate), | ||
| "Claude Code is not signed in. Run claude auth login in a terminal, then try again.", | ||
| ); | ||
| assert.equal(isAuthenticationFailure(failed), true); | ||
| setActiveLocale("zh-CN"); | ||
| assert.equal( | ||
| assistantReplyFailure(failed, defaultTranslate), | ||
| "助手未登录:请在终端执行 claude auth login 后重试。", | ||
| ); | ||
| }); | ||
|
|
||
| test("an empty completed reply still uses the empty placeholder", () => { | ||
| setActiveLocale("en-US"); | ||
| assert.equal(assistantReplyFailure(message({ status: "complete" }), defaultTranslate), null); | ||
| assert.equal(isAuthenticationFailure(message({ status: "interrupted" })), false); | ||
| }); |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude Code can authenticate through a third-party API gateway without an Anthropic account login. Please keep it selectable when valid gateway credentials are configured, even if
claude auth statusreportsloggedIn: false. Claude Code gateway docs