>;
};
- setDraft(
- Array.from(result.results ?? [])
- .map((item) => item[0]?.transcript ?? "")
- .join(""),
- );
+ const transcript = Array.from(result.results ?? [])
+ .map((item) => item[0]?.transcript ?? "")
+ .join("");
+ setDraft((current) => ({ ...current, [slot]: transcript }));
};
recognition.onerror = () => {
- setError("语音输入失败,请检查麦克风权限。");
+ reportSlotError(slot, "语音输入失败,请检查麦克风权限。");
setVoiceListening(false);
};
recognition.onend = () => setVoiceListening(false);
@@ -713,9 +748,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
})
.then(() => void refresh())
.catch((reason) =>
- setError(
- errorMessage(reason),
- ),
+ reportSlotError(selectedSlot, errorMessage(reason)),
);
}}
>
@@ -764,7 +797,10 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
{message.streaming ? 生成中 : null}
{message.content ? (
-
+
) : (
正在生成…
)}
@@ -826,9 +862,9 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
})
)}
- {error ? (
+ {visibleError ? (
- {error}
+ {visibleError}
) : null}
@@ -856,20 +892,21 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
{voiceListening ? "停止录音" : "语音输入"}
- {pendingAttachments.length > 0 ? (
+ {selectedAttachments.length > 0 ? (
- {pendingAttachments.map((attachment) => (
+ {selectedAttachments.map((attachment) => (
{attachment.fileName}