mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-19 23:23:40 +00:00
feat(feedback): wire feedback data into message rendering for history echo
Adds useThreadFeedback hook that fetches run-level feedback from the messages API and builds a runId->FeedbackData map. MessageList now calls this hook and passes feedback and runId to each MessageListItem so previously-submitted thumbs are pre-filled when revisiting a thread. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
77491f2801
commit
18393b55d1
@ -678,3 +678,37 @@ export function useRenameThread() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useThreadFeedback(threadId: string | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ["thread-feedback", threadId],
|
||||
queryFn: async () => {
|
||||
if (!threadId) return {};
|
||||
const res = await fetchWithAuth(
|
||||
`${getBackendBaseURL()}/api/threads/${encodeURIComponent(threadId)}/messages?limit=200`,
|
||||
);
|
||||
if (!res.ok) return {};
|
||||
const messages: Array<{
|
||||
run_id: string;
|
||||
event_type: string;
|
||||
feedback?: {
|
||||
feedback_id: string;
|
||||
rating: number;
|
||||
comment: string | null;
|
||||
} | null;
|
||||
}> = await res.json();
|
||||
const feedbackMap: Record<
|
||||
string,
|
||||
{ feedback_id: string; rating: number; comment: string | null }
|
||||
> = {};
|
||||
for (const msg of messages) {
|
||||
if (msg.feedback && msg.run_id) {
|
||||
feedbackMap[msg.run_id] = msg.feedback;
|
||||
}
|
||||
}
|
||||
return feedbackMap;
|
||||
},
|
||||
enabled: !!threadId,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user