瀏覽代碼

fix: Playground sendMessage onSuccess now renders bot reply

The sendMessage mutation's onSuccess only called setIsTyping(false),
silently discarding Ellie's reply. Now adds the bot message to the
chat list and updates the Execution Path with the response source
(flow/knowledge/llm).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tony T 5 天之前
父節點
當前提交
154d2b569a
共有 1 個文件被更改,包括 14 次插入1 次删除
  1. 14 1
      client/src/pages/Playground.tsx

+ 14 - 1
client/src/pages/Playground.tsx

@@ -61,7 +61,20 @@ export default function Playground() {
   );
 
   const sendMessage = trpc.chat.sendMessage.useMutation({
-    onSuccess: () => setIsTyping(false),
+    onSuccess: (data) => {
+      setIsTyping(false);
+      if (data.reply) {
+        setFlowPath(prev => [...prev, data.source ?? data.status ?? "reply"]);
+        setMessages(prev => [...prev, {
+          id: Date.now(),
+          sender: "bot",
+          content: data.reply as string,
+          timestamp: new Date().toISOString(),
+          flowStep: data.source === "flow" ? "Flow: matched" : data.source === "knowledge" ? "KB: matched" : `LLM: ${data.status}`,
+        }]);
+        setShowGreeting(false);
+      }
+    },
     onError: () => setIsTyping(false),
   });