JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(web): carry question text back in ask_user answers
cjh_jinduoxia253c6ed564dd
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InlineQuestionCard.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InlineQuestionCard.tsxindex 7d6ca5d8fa..7e92d338e3 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InlineQuestionCard.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InlineQuestionCard.tsx@@ -70,11 +70,11 @@ export function InlineQuestionCard({ onSubmit }: InlineQuestionCardProps) {// Other:清空 selected_options,把用户输入放进 custom_input,// 命中后端 interface.py 的 `elif custom_input` 分支。if (sel === OTHER_VALUE) {- return { selected_options: [], custom_input: (customInputs.get(idx) || '').trim() };+ return { question: q.question, selected_options: [], custom_input: (customInputs.get(idx) || '').trim() };}- if (sel) return { selected_options: [sel] };+ if (sel) return { question: q.question, selected_options: [sel] };const firstOption = q.options[0];- return { selected_options: firstOption ? [firstOption.value || firstOption.label] : [] };+ return { question: q.question, selected_options: firstOption ? [firstOption.value || firstOption.label] : [] };});},[pendingQuestion, customInputs]diff --git a/jiuwenswarm/channels/web/frontend/src/components/InteractionSlot/InteractionPrompt.tsx b/jiuwenswarm/channels/web/frontend/src/components/InteractionSlot/InteractionPrompt.tsxindex 247b75fad6..55a5bd228f 100644--- a/jiuwenswarm/channels/web/frontend/src/components/InteractionSlot/InteractionPrompt.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/InteractionSlot/InteractionPrompt.tsx@@ -107,7 +107,7 @@ export function InteractionPrompt({ pending, onSubmit }: InteractionPromptProps)const q = questions[idx];const s = overrides?.[idx] ?? states[idx] ?? emptyPage();const customText = s.custom.trim();- const answer: UserAnswer = { selected_options: [...s.selected] };+ const answer: UserAnswer = { question: q?.question, selected_options: [...s.selected] };if (customText) answer.custom_input = customText;// 兜底:既无选择也无输入时,默认第一个普通选项(避免后端拿到空答案)。if (answer.selected_options.length === 0 && !customText) {diff --git a/jiuwenswarm/channels/web/frontend/src/features/UserQuestionModal/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/UserQuestionModal/index.tsxindex a437d30c83..e3c2b985cc 100644--- a/jiuwenswarm/channels/web/frontend/src/features/UserQuestionModal/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/features/UserQuestionModal/index.tsx@@ -26,6 +26,7 @@ export function UserQuestionModal({ onSubmit }: UserQuestionModalProps) {setAnswers((prev) => {const newAnswers = new Map(prev);const current = newAnswers.get(questionIndex) || {+ question: pendingQuestion?.questions[questionIndex]?.question,selected_options: [],};@@ -50,7 +51,7 @@ export function UserQuestionModal({ onSubmit }: UserQuestionModalProps) {return newAnswers;});},- []+ [pendingQuestion]);// 处理自定义输入@@ -59,6 +60,7 @@ export function UserQuestionModal({ onSubmit }: UserQuestionModalProps) {setAnswers((prev) => {const newAnswers = new Map(prev);const current = newAnswers.get(questionIndex) || {+ question: pendingQuestion?.questions[questionIndex]?.question,selected_options: [],};newAnswers.set(questionIndex, {@@ -68,7 +70,7 @@ export function UserQuestionModal({ onSubmit }: UserQuestionModalProps) {return newAnswers;});},- []+ [pendingQuestion]);// 提交回答@@ -79,10 +81,11 @@ export function UserQuestionModal({ onSubmit }: UserQuestionModalProps) {(q, index) => {const answer = answers.get(index);if (answer) {- return answer;+ return { ...answer, question: answer.question ?? q.question };}// 默认选择第一个选项return {+ question: q.question,selected_options: q.options.length > 0 ? [q.options[0].label] : [],};}diff --git a/jiuwenswarm/channels/web/frontend/src/types/websocket.ts b/jiuwenswarm/channels/web/frontend/src/types/websocket.tsindex e57ff4a81a..bd6d8068d4 100644--- a/jiuwenswarm/channels/web/frontend/src/types/websocket.ts+++ b/jiuwenswarm/channels/web/frontend/src/types/websocket.ts@@ -159,6 +159,11 @@ export interface AskUserQuestionPayload {* 用户回答*/export interface UserAnswer {+ /**+ * 服务端下发的原始问题文本。+ * ask_user_interrupt 场景必填,后端据此把答案归属到对应问题。+ */+ question?: string;selected_options: string[];custom_input?: string;}