Skip to content

Commit 4094b84

Browse files
committed
feat: improve Claude Code auth error message with settings link
- Detect Claude Code authentication errors in ChatRow and show user-friendly message - Add internal URL handling (roocode://settings) to navigate to settings panel - Add i18n strings for Claude Code auth error and Settings link text - Replace generic 'Unknown API error' with actionable guidance
1 parent 96d1ded commit 4094b84

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,30 +1089,36 @@ export const ChatRowContent = ({
10891089
let body = t(`chat:apiRequest.failed`)
10901090
let retryInfo, rawError, code, docsURL
10911091
if (message.text !== undefined) {
1092-
// Try to show richer error message for that code, if available
1093-
const potentialCode = parseInt(message.text.substring(0, 3))
1094-
if (!isNaN(potentialCode) && potentialCode >= 400) {
1095-
code = potentialCode
1096-
const stringForError = `chat:apiRequest.errorMessage.${code}`
1097-
if (i18n.exists(stringForError)) {
1098-
body = t(stringForError)
1099-
// Fill this out in upcoming PRs
1100-
// Do not remove this
1101-
// switch(code) {
1102-
// case ERROR_CODE:
1103-
// docsURL = ???
1104-
// break;
1105-
// }
1092+
// Check for Claude Code authentication error first
1093+
if (message.text.includes("Not authenticated with Claude Code")) {
1094+
body = t("chat:apiRequest.errorMessage.claudeCodeNotAuthenticated")
1095+
docsURL = "roocode://settings?provider=claude-code"
1096+
} else {
1097+
// Try to show richer error message for that code, if available
1098+
const potentialCode = parseInt(message.text.substring(0, 3))
1099+
if (!isNaN(potentialCode) && potentialCode >= 400) {
1100+
code = potentialCode
1101+
const stringForError = `chat:apiRequest.errorMessage.${code}`
1102+
if (i18n.exists(stringForError)) {
1103+
body = t(stringForError)
1104+
// Fill this out in upcoming PRs
1105+
// Do not remove this
1106+
// switch(code) {
1107+
// case ERROR_CODE:
1108+
// docsURL = ???
1109+
// break;
1110+
// }
1111+
} else {
1112+
body = t("chat:apiRequest.errorMessage.unknown")
1113+
docsURL = "mailto:[email protected]?subject=Unknown API Error"
1114+
}
1115+
} else if (message.text.indexOf("Connection error") === 0) {
1116+
body = t("chat:apiRequest.errorMessage.connection")
11061117
} else {
1118+
// Non-HTTP-status-code error message - store full text as errorDetails
11071119
body = t("chat:apiRequest.errorMessage.unknown")
11081120
docsURL = "mailto:[email protected]?subject=Unknown API Error"
11091121
}
1110-
} else if (message.text.indexOf("Connection error") === 0) {
1111-
body = t("chat:apiRequest.errorMessage.connection")
1112-
} else {
1113-
// Non-HTTP-status-code error message - store full text as errorDetails
1114-
body = t("chat:apiRequest.errorMessage.unknown")
1115-
docsURL = "mailto:[email protected]?subject=Unknown API Error"
11161122
}
11171123

11181124
// This isn't pretty, but since the retry logic happens at a lower level

webview-ui/src/components/chat/ErrorRow.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,19 @@ export const ErrorRow = memo(
203203
className="text-sm flex items-center gap-1 transition-opacity opacity-0 group-hover:opacity-100"
204204
onClick={(e) => {
205205
e.preventDefault()
206-
vscode.postMessage({ type: "openExternal", url: docsURL })
206+
// Handle internal navigation to settings
207+
if (docsURL.startsWith("roocode://settings")) {
208+
vscode.postMessage({ type: "switchTab", tab: "settings" })
209+
} else {
210+
vscode.postMessage({ type: "openExternal", url: docsURL })
211+
}
207212
}}>
208213
<BookOpenText className="size-3 mt-[3px]" />
209-
{t("chat:apiRequest.errorMessage.docs")}
214+
{docsURL.startsWith("roocode://settings")
215+
? t("chat:apiRequest.errorMessage.goToSettings", {
216+
defaultValue: "Settings",
217+
})
218+
: t("chat:apiRequest.errorMessage.docs")}
210219
</a>
211220
)}
212221
{errorDetails && (

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@
147147
"errorTitle": "API Error {{code}}",
148148
"errorMessage": {
149149
"docs": "Docs",
150+
"goToSettings": "Settings",
150151
"400": "The provider couldn't process the request as made. Stop the task and try a different approach.",
151152
"401": "Couldn't authenticate with provider. Please check your API key configuration.",
152153
"402": "You seem to have run out of funds/credits in your account. Go to your provider and add more to continue.",
153154
"403": "Unauthorized. Your API key is valid, but the provider refused to complete this request.",
154155
"429": "Too many requests. You're being rate-limited by the provider. Please wait a bit before your next API call.",
155156
"500": "Provider server error. Something is wrong on the provider side, there's nothing wrong with your request.",
156157
"connection": "Connection error. Make sure you have a working internet connection.",
157-
"unknown": "Unknown API error. Please contact Roo Code support."
158+
"unknown": "Unknown API error. Please contact Roo Code support.",
159+
"claudeCodeNotAuthenticated": "You need to sign in to use Claude Code. Go to Settings and click \"Sign in to Claude Code\" to authenticate."
158160
}
159161
},
160162
"checkpoint": {

0 commit comments

Comments
 (0)