fix(desktop): translate the AI chat error title and default chat titles

The error bubble in AI chat always said "Error occurred", and a chat
without a title was named "<date> chat" or "<date> timeline summary" with
the date in the UI language but the rest in English. Both now come from
the locale files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DIYgod
2026-10-12 19:33:25 +08:00
parent 9971384b27
commit d04e63710c
7 changed files with 22 additions and 18 deletions
@@ -1,8 +1,8 @@
import { Spring } from "@follow/components/constants/spring.js"
import { cn } from "@follow/utils"
import { ExceptionCodeMap } from "@follow-app/client-sdk"
import { m } from "motion/react"
import * as React from "react"
import { useTranslation } from "react-i18next"
import { getErrorMessage, parseAIError } from "~/modules/ai-chat/utils/error"
@@ -17,6 +17,7 @@ interface ErrorMessageProps {
* Note: Rate limit errors are handled separately by RateLimitNotice component
*/
export const ErrorMessage: React.FC<ErrorMessageProps> = ({ error, className }) => {
const { t } = useTranslation("ai")
const parsedError = React.useMemo(() => parseAIError(error), [error])
if (parsedError.isRateLimitError) {
@@ -36,20 +37,6 @@ export const ErrorMessage: React.FC<ErrorMessageProps> = ({ error, className })
}
}
const getErrorTitle = () => {
if (parsedError.isBusinessError) {
switch (errorCode) {
case ExceptionCodeMap.AIRateLimitExceeded: {
return "AI Rate Limit Exceeded"
}
default: {
return "Error occurred"
}
}
}
return "Error occurred"
}
const contextualInfo = getContextualInfo()
return (
@@ -66,7 +53,9 @@ export const ErrorMessage: React.FC<ErrorMessageProps> = ({ error, className })
{/* Header with subtle icon */}
<div className="flex items-center gap-2">
<i className="i-mgc-information-cute-re size-4 text-text-tertiary" />
<span className="text-xs font-medium text-text-secondary">{getErrorTitle()}</span>
<span className="text-xs font-medium text-text-secondary">
{t("chat.error.occurred")}
</span>
</div>
{/* Error message - always visible but subtle */}
@@ -266,7 +266,7 @@ class AIPersistServiceStatic {
const referenceDate = timestamps?.updatedAt ?? timestamps?.createdAt ?? new Date()
const formattedDateTime = this.formatDateTime(referenceDate, i18n.language)
return `${formattedDateTime} chat`
return i18n.t("chat.default_title.chat", { ns: "ai", time: formattedDateTime })
}
const datePart = chatId.slice(prefix.length)
@@ -287,7 +287,7 @@ class AIPersistServiceStatic {
const formattedDateTime = this.formatDateTime(targetDate, i18n.language)
return `${formattedDateTime} timeline summary`
return i18n.t("chat.default_title.timeline_summary", { ns: "ai", time: formattedDateTime })
}
private formatDateTime(date: Date, locale?: string): string {
+3
View File
@@ -55,7 +55,10 @@
"chat.context.additional": "Additional Context",
"chat.context.unread_only": "Unread Only",
"chat.context.upload_files": "Upload Files",
"chat.default_title.chat": "{{time}} chat",
"chat.default_title.timeline_summary": "{{time}} timeline summary",
"chat.error.description": "Don't worry! You can try again or reload the chat to continue your conversation.",
"chat.error.occurred": "Error occurred",
"chat.error.reload_page": "Reload Page",
"chat.error.stream_timeout": "The reply stopped arriving, so it was ended. Retry your message to try again.",
"chat.error.title": "AI Chat Encountered an Error",
+3
View File
@@ -55,7 +55,10 @@
"chat.context.additional": "Contexte supplémentaire",
"chat.context.unread_only": "Non lus uniquement",
"chat.context.upload_files": "Importer des fichiers",
"chat.default_title.chat": "Discussion du {{time}}",
"chat.default_title.timeline_summary": "Résumé de la chronologie du {{time}}",
"chat.error.description": "Pas d'inquiétude ! Vous pouvez réessayer ou recharger la discussion pour poursuivre votre conversation.",
"chat.error.occurred": "Une erreur s'est produite",
"chat.error.reload_page": "Recharger la page",
"chat.error.stream_timeout": "La réponse a cessé d'arriver et a été interrompue. Réessayez votre message.",
"chat.error.title": "La discussion IA a rencontré une erreur",
+3
View File
@@ -55,7 +55,10 @@
"chat.context.additional": "その他のコンテキスト",
"chat.context.unread_only": "未読のみ",
"chat.context.upload_files": "ファイルをアップロード",
"chat.default_title.chat": "{{time}} のチャット",
"chat.default_title.timeline_summary": "{{time}} のタイムラインの要約",
"chat.error.description": "ご安心ください。再試行するか、チャットを再読み込みすると会話を続けられます。",
"chat.error.occurred": "エラーが発生しました",
"chat.error.reload_page": "ページを再読み込み",
"chat.error.stream_timeout": "応答が途中で届かなくなったため終了しました。メッセージを再試行してください。",
"chat.error.title": "AI チャットでエラーが発生しました",
+3
View File
@@ -55,7 +55,10 @@
"chat.context.additional": "其他上下文",
"chat.context.unread_only": "仅未读",
"chat.context.upload_files": "上传文件",
"chat.default_title.chat": "{{time}} 对话",
"chat.default_title.timeline_summary": "{{time}} 时间线摘要",
"chat.error.description": "别担心!您可以重试或重新加载对话,继续之前的交流。",
"chat.error.occurred": "出错了",
"chat.error.reload_page": "重新加载页面",
"chat.error.stream_timeout": "回复长时间没有新内容,已结束。请重试你的消息。",
"chat.error.title": "AI 对话出错了",
+3
View File
@@ -55,7 +55,10 @@
"chat.context.additional": "其他上下文",
"chat.context.unread_only": "僅未讀",
"chat.context.upload_files": "上傳檔案",
"chat.default_title.chat": "{{time}} 對話",
"chat.default_title.timeline_summary": "{{time}} 時間軸摘要",
"chat.error.description": "別擔心!您可以重試或重新載入對話,繼續先前的交流。",
"chat.error.occurred": "發生錯誤",
"chat.error.reload_page": "重新載入頁面",
"chat.error.stream_timeout": "回覆長時間沒有新內容,已結束。請重試你的訊息。",
"chat.error.title": "AI 對話發生錯誤",