diff --git a/ui/src/chat/ChatAskCard.vue b/ui/src/chat/ChatAskCard.vue index 404658c39..dafda83f4 100644 --- a/ui/src/chat/ChatAskCard.vue +++ b/ui/src/chat/ChatAskCard.vue @@ -5,22 +5,37 @@ import { ref } from "vue"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"; +import { ReadError } from "@/components/ui/read-error"; import ChatQuestionnaire from "./ChatQuestionnaire.vue"; -import { answerAsk, type ChatAsk } from "./state"; +import { answerAsk, askError, type ChatAsk } from "./state"; defineProps<{ ask: ChatAsk }>(); const reply = ref(""); -function sendReply() { +// The last answer tried, so a failed send can be retried from the error. +const lastAnswer = ref(""); + +async function answer(value: string): Promise { + lastAnswer.value = value; + return answerAsk(value); +} + +async function sendReply(): Promise { const text = reply.value.trim(); if (!text) return; - reply.value = ""; - void answerAsk(text); + // The answer stays filled in until the server accepts it. + if (await answer(text)) reply.value = ""; +} + +function retry(): void { + if (lastAnswer.value) void answer(lastAnswer.value); }