fix(feedback): use real threadId and refresh after stream

- Pass threadId prop to MessageListItem instead of reading "new" from URL params
- Invalidate thread-feedback query on stream finish so buttons appear immediately
- Show feedback buttons always visible, copy button on hover only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
rayhpeng 2026-04-10 18:54:06 +08:00
parent 95d5c156a1
commit 6476eabdf5
3 changed files with 16 additions and 2 deletions

View File

@ -36,11 +36,13 @@ import { MarkdownContent } from "./markdown-content";
export function MessageListItem({
className,
threadId,
message,
isLoading,
threadId,
}: {
className?: string;
threadId?: string;
message: Message;
isLoading?: boolean;
threadId: string;
@ -61,10 +63,13 @@ export function MessageListItem({
<MessageToolbar
className={cn(
isHuman ? "-bottom-9 justify-end" : "-bottom-8",
"absolute right-0 left-0 z-20 opacity-0 transition-opacity delay-200 duration-300 group-hover/conversation-message:opacity-100",
"absolute right-0 left-0 z-20",
!isHuman && runId && threadId
? "opacity-100"
: "opacity-0 transition-opacity delay-200 duration-300 group-hover/conversation-message:opacity-100",
)}
>
<div className="flex gap-1">
<div className="flex gap-1 opacity-0 transition-opacity delay-200 duration-300 group-hover/conversation-message:opacity-100">
<CopyButton
clipboardData={
extractContentFromMessage(message) ??
@ -73,6 +78,13 @@ export function MessageListItem({
}
/>
</div>
{!isHuman && runId && threadId && (
<FeedbackButtons
threadId={threadId}
runId={runId}
initialFeedback={feedback ?? null}
/>
)}
</MessageToolbar>
)}
</AIElementMessage>

View File

@ -77,6 +77,7 @@ export function MessageList({
return (
<MessageListItem
key={`${group.id}/${msg.id}`}
threadId={threadId}
message={msg}
isLoading={thread.isLoading}
runId={runId}

View File

@ -294,6 +294,7 @@ export function useThreadStream({
onFinish(state) {
listeners.current.onFinish?.(state.values);
void queryClient.invalidateQueries({ queryKey: ["threads", "search"] });
void queryClient.invalidateQueries({ queryKey: ["thread-feedback"] });
},
});