diff --git a/ui/src/chat/ChatAskCard.vue b/ui/src/chat/ChatAskCard.vue index 1518ce78f..befce5b09 100644 --- a/ui/src/chat/ChatAskCard.vue +++ b/ui/src/chat/ChatAskCard.vue @@ -3,74 +3,41 @@ import { ShieldQuestion } from "@lucide/vue"; 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, askError, askErrorID, type ChatAsk } from "./state"; +import { errors } from "@/copy/errors"; +import { describeError } from "@/lib/api"; +import { answerAsk } from "./state"; +import type { ChatAsk } from "./types"; const props = defineProps<{ ask: ChatAsk }>(); -const reply = ref(""); -// The last answer tried, so a failed send can be retried from the error. -const lastAnswer = ref(""); +const error = ref(""); +// The last answer tried, so a failed answer can be retried from the error. +let lastAnswer = false; -async function answer(value: string): Promise { - lastAnswer.value = value; - return answerAsk(value, props.ask); -} - -async function sendReply(): Promise { - const text = reply.value.trim(); - if (!text) return; - // 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); +async function answer(approve: boolean): Promise { + lastAnswer = approve; + try { + await answerAsk(props.ask, approve); + error.value = ""; + } catch (err) { + error.value = describeError(err, errors.chat.ask.answer); + } } diff --git a/ui/src/chat/ChatAttachment.vue b/ui/src/chat/ChatAttachment.vue deleted file mode 100644 index e93b5f5a8..000000000 --- a/ui/src/chat/ChatAttachment.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/ui/src/chat/ChatBar.vue b/ui/src/chat/ChatBar.vue index 5d4ffd356..45841c77f 100644 --- a/ui/src/chat/ChatBar.vue +++ b/ui/src/chat/ChatBar.vue @@ -1,13 +1,14 @@ - - diff --git a/ui/src/chat/ChatComposer.vue b/ui/src/chat/ChatComposer.vue index ea8ab074a..6ba70719a 100644 --- a/ui/src/chat/ChatComposer.vue +++ b/ui/src/chat/ChatComposer.vue @@ -1,5 +1,5 @@