AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
fix(ui): show 👍/👎 on replies in the main chat
Rufusfc01a8b32d87
diff --git a/packages/ui/src/components/Chat.tsx b/packages/ui/src/components/Chat.tsxindex 5adb6cb4..daed5d6e 100644--- a/packages/ui/src/components/Chat.tsx+++ b/packages/ui/src/components/Chat.tsx@@ -18,6 +18,7 @@ import {DebugEvent,FALLBACK_ACTIVITY_LABEL,getSuggestedPrompts,+ setMessageFeedback,streamChat,} from "@/lib/api";import { isAbortError, useStoppableTurn } from "@/lib/use-stoppable-turn";@@ -197,6 +198,9 @@ export default function Chat({ onDebugEvent, initialMessages, initialSessionId,// message without depending on the async setState applying first.const turnActions: ActionTaken[] = [];let wasStopped = false;+ // Row id of the persisted reply, from `done`; it is what makes the reply+ // rateable with 👍/👎.+ let replyId: number | undefined;try {for await (const item of streamChat(message, sessionId, {@@ -243,6 +247,7 @@ export default function Chat({ onDebugEvent, initialMessages, initialSessionId,serverAcknowledgedStop();if (item.session_id) adoptSessionId(item.session_id);} else if (item.type === "done") {+ if (item.message_id) replyId = item.message_id;if (item.session_id) {adoptSessionId(item.session_id);onTurnComplete?.(item.session_id);@@ -276,6 +281,7 @@ export default function Chat({ onDebugEvent, initialMessages, initialSessionId,content: accumulated,actions: turnActions.length > 0 ? turnActions : undefined,stopped: wasStopped || undefined,+ id: replyId,},]);}@@ -319,6 +325,18 @@ export default function Chat({ onDebugEvent, initialMessages, initialSessionId,}}+ // 👍/👎 on a persisted reply, applied optimistically and rolled back if+ // the save fails. Clicking the active rating again clears it.+ function handleFeedback(index: number, value: "up" | "down" | null) {+ const target = messages[index];+ if (!sessionId || target?.role !== "assistant" || !target.id) return;+ const previous = target.feedback ?? null;+ const apply = (v: "up" | "down" | null) =>+ setMessages((prev) => prev.map((m, i) => (i === index ? { ...m, feedback: v } : m)));+ apply(value);+ setMessageFeedback(sessionId, target.id, value).catch(() => apply(previous));+ }+function handleKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {if (e.key === "Enter" && !e.shiftKey) {e.preventDefault();@@ -409,6 +427,12 @@ export default function Chat({ onDebugEvent, initialMessages, initialSessionId,content={msg.content}actions={msg.role === "assistant" ? msg.actions : undefined}stopped={msg.role === "assistant" ? msg.stopped : undefined}+ feedback={msg.role === "assistant" ? msg.feedback : undefined}+ onFeedback={+ msg.role === "assistant" && msg.id && sessionId+ ? (v) => handleFeedback(i, v)+ : undefined+ }/>))}diff --git a/packages/ui/src/lib/api.ts b/packages/ui/src/lib/api.tsindex 7a1fdf34..a758f2fb 100644--- a/packages/ui/src/lib/api.ts+++ b/packages/ui/src/lib/api.ts@@ -815,6 +815,11 @@ export interface ChatMessage {// `chat_messages.stopped`, so the marker survives a reload rather than// letting a truncated reply read as a complete one.stopped?: boolean;+ // Assistant rows only: the persisted row id (from the stream's `done`+ // event, or from a reloaded session) and any 👍/👎 on it. The id is what+ // lets the reply be rated.+ id?: number;+ feedback?: "up" | "down" | null;}export interface Decision {