fix(frontend): avoid using route new as thread id (#1967)

Co-authored-by: luoxiao6645 <luoxiao6645@gmail.com>
This commit is contained in:
2026-04-08 10:08:55 +08:00 committed by GitHub
parent 24805200f0
commit 85b7ed3cec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,5 @@
import type { Message } from "@langchain/langgraph-sdk"; import type { Message } from "@langchain/langgraph-sdk";
import { FileIcon, Loader2Icon } from "lucide-react"; import { FileIcon, Loader2Icon } from "lucide-react";
import { useParams } from "next/navigation";
import { memo, useMemo, type ImgHTMLAttributes } from "react"; import { memo, useMemo, type ImgHTMLAttributes } from "react";
import rehypeKatex from "rehype-katex"; import rehypeKatex from "rehype-katex";
@ -39,10 +38,12 @@ export function MessageListItem({
className, className,
message, message,
isLoading, isLoading,
threadId,
}: { }: {
className?: string; className?: string;
message: Message; message: Message;
isLoading?: boolean; isLoading?: boolean;
threadId: string;
}) { }) {
const isHuman = message.type === "human"; const isHuman = message.type === "human";
return ( return (
@ -54,6 +55,7 @@ export function MessageListItem({
className={isHuman ? "w-fit" : "w-full"} className={isHuman ? "w-fit" : "w-full"}
message={message} message={message}
isLoading={isLoading} isLoading={isLoading}
threadId={threadId}
/> />
{!isLoading && ( {!isLoading && (
<MessageToolbar <MessageToolbar
@ -111,21 +113,22 @@ function MessageContent_({
className, className,
message, message,
isLoading = false, isLoading = false,
threadId,
}: { }: {
className?: string; className?: string;
message: Message; message: Message;
isLoading?: boolean; isLoading?: boolean;
threadId: string;
}) { }) {
const rehypePlugins = useRehypeSplitWordsIntoSpans(isLoading); const rehypePlugins = useRehypeSplitWordsIntoSpans(isLoading);
const isHuman = message.type === "human"; const isHuman = message.type === "human";
const { thread_id } = useParams<{ thread_id: string }>();
const components = useMemo( const components = useMemo(
() => ({ () => ({
img: (props: ImgHTMLAttributes<HTMLImageElement>) => ( img: (props: ImgHTMLAttributes<HTMLImageElement>) => (
<MessageImage {...props} threadId={thread_id} maxWidth="90%" /> <MessageImage {...props} threadId={threadId} maxWidth="90%" />
), ),
}), }),
[thread_id], [threadId],
); );
const rawContent = extractContentFromMessage(message); const rawContent = extractContentFromMessage(message);
@ -151,8 +154,8 @@ function MessageContent_({
}, [rawContent, isHuman]); }, [rawContent, isHuman]);
const filesList = const filesList =
files && files.length > 0 && thread_id ? ( files && files.length > 0 ? (
<RichFilesList files={files} threadId={thread_id} /> <RichFilesList files={files} threadId={threadId} />
) : null; ) : null;
// Uploading state: mock AI message shown while files upload // Uploading state: mock AI message shown while files upload

View File

@ -63,6 +63,7 @@ export function MessageList({
key={`${group.id}/${msg.id}`} key={`${group.id}/${msg.id}`}
message={msg} message={msg}
isLoading={thread.isLoading} isLoading={thread.isLoading}
threadId={threadId}
/> />
); );
}); });