fix(frontend): avoid using route new as thread id (#1967)
Co-authored-by: luoxiao6645 <luoxiao6645@gmail.com>
This commit is contained in:
parent
24805200f0
commit
85b7ed3cec
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue