From e9937ded6bf774e6ad2f122b5d02716c96895d8c Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 7 Nov 2026 01:23:10 +1100 Subject: [PATCH] fix(ui): a failed answer keeps the question card and its filled-in answer (#1728) answerAsk now clears the pending question only after api.chatAnswer accepts it, and resolves whether it did. On failure the new askError ref carries the message, shown on the card as a ReadError whose Retry resends the last answer; ChatAskCard keeps the typed reply until acceptance and routes every choice button through the same path, and the questionnaire submits through the card so its answers are retryable too. askError resets on turn start, on a new ask, and on conversation switch. --- ui/src/chat/ChatAskCard.vue | 35 ++++++++++++++++++++++--------- ui/src/chat/ChatQuestionnaire.vue | 9 ++++---- ui/src/chat/state.ts | 26 +++++++++++++++++++---- 3 files changed, 52 insertions(+), 18 deletions(-) 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); }