diff --git a/app/(admin)/settings/admin-settings-client.tsx b/app/(admin)/settings/admin-settings-client.tsx
index 57ed39331..ac6b03e4e 100644
--- a/app/(admin)/settings/admin-settings-client.tsx
+++ b/app/(admin)/settings/admin-settings-client.tsx
@@ -12345,11 +12345,11 @@ export function AdminSettingsClient() {
开启并配置接口后,右侧对话框模式菜单显示
- Clawd模式;Token 仅保存在服务端,不会下发到前端。
+ Clawd;Token 仅保存在服务端,不会下发到前端。
;
+ const nestedError =
+ raw.error && typeof raw.error === "object"
+ ? (raw.error as Record)
+ : null;
+ const code = nestedError?.code || raw.code;
+ return typeof code === "string" ? code.trim() : "";
+}
+
export async function POST(request: Request) {
const session = await auth().catch(() => null);
@@ -67,7 +78,7 @@ export async function POST(request: Request) {
const config = await readOpenClawConfig();
if (!config.enabled) {
- return NextResponse.json({ error: "Clawd 模式未启用" }, { status: 403 });
+ return NextResponse.json({ error: "Clawd 未启用" }, { status: 403 });
}
if (!config.baseUrl || !config.token) {
return NextResponse.json(
@@ -127,9 +138,14 @@ export async function POST(request: Request) {
upstreamPayload = await response.json().catch(() => null);
if (!response.ok) {
+ const errorCode = getOpenClawErrorCode(upstreamPayload);
return NextResponse.json(
{
- error: getOpenClawErrorMessage(upstreamPayload, "大龙虾聊天接口调用失败"),
+ error:
+ response.status === 429
+ ? "正在处理中,请稍后重试"
+ : getOpenClawErrorMessage(upstreamPayload, "大龙虾聊天接口调用失败"),
+ code: errorCode || undefined,
},
{ status: response.status }
);
diff --git a/components/canvas/CanvasChatPanel.tsx b/components/canvas/CanvasChatPanel.tsx
index 18ecff45c..d02e0c9f9 100644
--- a/components/canvas/CanvasChatPanel.tsx
+++ b/components/canvas/CanvasChatPanel.tsx
@@ -3384,7 +3384,7 @@ export function CanvasChatPanel({
);
const activeModeLabel =
activeComposerMode === "clawd"
- ? "Clawd模式"
+ ? "Clawd"
: activeComposerMode === "video"
? "视频"
: activeComposerMode === "detail"
@@ -3713,7 +3713,7 @@ export function CanvasChatPanel({
hiddenPromptRef.current = null;
autoContextRef.current = null;
if (mode === "clawd" && !isClawdModeEnabled) {
- toast.error("Clawd模式未开启");
+ toast.error("Clawd 未开启");
return;
}
activeComposerModeRef.current = mode;
@@ -8579,7 +8579,7 @@ export function CanvasChatPanel({
return;
}
if (attachments.length > 0) {
- toast.error("Clawd模式当前仅支持文本对话");
+ toast.error("Clawd 当前仅支持文本对话");
return;
}
@@ -8671,6 +8671,9 @@ export function CanvasChatPanel({
hasHydratedHistoryRef.current = true;
} catch (error) {
console.error("[CanvasChat] Clawd request failed:", error);
+ setMessages((previousMessages) =>
+ previousMessages.filter((message) => message.id !== userMessageId)
+ );
toast.error(error instanceof Error ? error.message : "Clawd 请求失败");
const currentEditorText = (editableDiv?.textContent || "")
.replace(/\u200b/g, " ")
@@ -12555,7 +12558,7 @@ export function CanvasChatPanel({
className={getComposerModeMenuItemClass("clawd")}
>
- Clawd模式
+ Clawd
{activeComposerMode === "clawd" ? (
) : null}