fix: shorten Clawd labels
This commit is contained in:
parent
8c6bd2ad03
commit
eec59f51fc
@ -12345,11 +12345,11 @@ export function AdminSettingsClient() {
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="openClawChatEnabled">
|
||||
无限画布 Clawd模式
|
||||
无限画布 Clawd
|
||||
</Label>
|
||||
<div className="text-muted-foreground text-xs">
|
||||
开启并配置接口后,右侧对话框模式菜单显示
|
||||
Clawd模式;Token 仅保存在服务端,不会下发到前端。
|
||||
Clawd;Token 仅保存在服务端,不会下发到前端。
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
|
||||
@ -53,6 +53,17 @@ function getOpenClawErrorMessage(payload: unknown, fallback: string) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function getOpenClawErrorCode(payload: unknown) {
|
||||
if (!payload || typeof payload !== "object") return "";
|
||||
const raw = payload as Record<string, unknown>;
|
||||
const nestedError =
|
||||
raw.error && typeof raw.error === "object"
|
||||
? (raw.error as Record<string, unknown>)
|
||||
: 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 }
|
||||
);
|
||||
|
||||
@ -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")}
|
||||
>
|
||||
<MessageCircle className="h-5 w-5" />
|
||||
<span className="flex-1">Clawd模式</span>
|
||||
<span className="flex-1">Clawd</span>
|
||||
{activeComposerMode === "clawd" ? (
|
||||
<Check className={cn("h-4 w-4", isVideoWorkspace ? "text-primary" : "text-[#1f2937]")} />
|
||||
) : null}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user