From 2e8bf9240856f4e4f7600aab90a2185a8f9ae007 Mon Sep 17 00:00:00 2001 From: amosblomqvist Date: Sat, 26 Sep 2026 00:51:16 +0300 Subject: [PATCH] fix(answer): stash the answer input event before addToolOutput MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The onSubmitAnswer path was the one Wave B send site missing its stash: addToolOutput triggers the SDK's automatic continuation send, the transport found nothing stashed, and threw — the answer never POSTed, so the question stayed open. One line (plus the contract comment). Caught live by the owner; the suite drives answer events directly at the handler, so this client seam stays untested until Wave D's client work. --- components/chat.tsx | 6 ++++++ next-env.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/chat.tsx b/components/chat.tsx index 5ea3890..c63e1b1 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -1310,6 +1310,12 @@ export function Chat({ } onSubmitAnswer={(output) => { if (!pending) return; + // THE INPUT-EVENTS CONTRACT (Wave B): the answer ride order is + // stash-then-send — addToolOutput triggers the SDK's automatic + // continuation send (sendAutomaticallyWhen), and the transport + // consumes THIS stash to build {chatId, input}. Dismissals ride + // the same callback (QuestionAnswerData.dismissed). + stashInput({ type: "answer", toolCallId: pending.toolCallId, answer: output }); void addToolOutput({ tool: pending.tool as "quiz" | "ask_user_question", toolCallId: pending.toolCallId, diff --git a/next-env.d.ts b/next-env.d.ts index ce4e94a..a419cbe 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,7 +1,7 @@ /// /// -import "./.next/types/routes.d.ts"; -import "./.next/types/root-params.d.ts"; +import "./.next/dev/types/routes.d.ts"; +import "./.next/dev/types/root-params.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.