fix(chat): surface PolicyDecision feedback on send failure

This commit is contained in:
zetaloop
2026-02-23 10:09:59 +08:00
parent c9579c1b8d
commit 90f1245ff1
+8 -2
View File
@@ -11,6 +11,7 @@ import { Input } from "@/components/ui/input"
import { ScrollArea } from "@/components/ui/scroll-area"
import { sendImageMessage, sendTextMessage } from "@/lib/api/chat"
import { cn } from "@/lib/utils"
import { notifyInfo } from "@/lib/toast"
import { useAuthStore } from "@/store/auth"
import { useChatStore } from "@/store/chat"
@@ -146,7 +147,8 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
onChange={(event) => {
const file = event.target.files?.[0]
if (!file) return
sendImageMessage(session.id, URL.createObjectURL(file))
const result = sendImageMessage(session.id, URL.createObjectURL(file))
if (result && !result.ok) notifyInfo(result.message ?? "发送失败")
event.target.value = ""
}}
/>
@@ -157,7 +159,11 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
const text = input.trim()
if (!text) return
sendTextMessage(session.id, text)
const result = sendTextMessage(session.id, text)
if (result && !result.ok) {
notifyInfo(result.message ?? "发送失败")
return
}
setInput("")
}}
>