mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 01:02:39 +02:00
show avatar for newly sent messages in shared chats
This commit is contained in:
parent
54568a62e0
commit
142e72c030
1 changed files with 21 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ import {
|
||||||
// extractWriteTodosFromContent,
|
// extractWriteTodosFromContent,
|
||||||
hydratePlanStateAtom,
|
hydratePlanStateAtom,
|
||||||
} from "@/atoms/chat/plan-state.atom";
|
} from "@/atoms/chat/plan-state.atom";
|
||||||
|
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
|
||||||
import { Thread } from "@/components/assistant-ui/thread";
|
import { Thread } from "@/components/assistant-ui/thread";
|
||||||
import { ChatHeader } from "@/components/new-chat/chat-header";
|
import { ChatHeader } from "@/components/new-chat/chat-header";
|
||||||
import type { ThinkingStep } from "@/components/tool-ui/deepagent-thinking";
|
import type { ThinkingStep } from "@/components/tool-ui/deepagent-thinking";
|
||||||
|
|
@ -251,6 +252,9 @@ export default function NewChatPage() {
|
||||||
const setMessageDocumentsMap = useSetAtom(messageDocumentsMapAtom);
|
const setMessageDocumentsMap = useSetAtom(messageDocumentsMapAtom);
|
||||||
const hydratePlanState = useSetAtom(hydratePlanStateAtom);
|
const hydratePlanState = useSetAtom(hydratePlanStateAtom);
|
||||||
|
|
||||||
|
// Get current user for author info in shared chats
|
||||||
|
const { data: currentUser } = useAtomValue(currentUserAtom);
|
||||||
|
|
||||||
// Create the attachment adapter for file processing
|
// Create the attachment adapter for file processing
|
||||||
const attachmentAdapter = useMemo(() => createAttachmentAdapter(), []);
|
const attachmentAdapter = useMemo(() => createAttachmentAdapter(), []);
|
||||||
|
|
||||||
|
|
@ -455,13 +459,27 @@ export default function NewChatPage() {
|
||||||
|
|
||||||
// Add user message to state
|
// Add user message to state
|
||||||
const userMsgId = `msg-user-${Date.now()}`;
|
const userMsgId = `msg-user-${Date.now()}`;
|
||||||
|
|
||||||
|
// Include author metadata for shared chats
|
||||||
|
const authorMetadata =
|
||||||
|
currentThread?.visibility === "SEARCH_SPACE" && currentUser
|
||||||
|
? {
|
||||||
|
custom: {
|
||||||
|
author: {
|
||||||
|
displayName: currentUser.display_name ?? null,
|
||||||
|
avatarUrl: currentUser.avatar_url ?? null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const userMessage: ThreadMessageLike = {
|
const userMessage: ThreadMessageLike = {
|
||||||
id: userMsgId,
|
id: userMsgId,
|
||||||
role: "user",
|
role: "user",
|
||||||
content: message.content,
|
content: message.content,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
// Include attachments so they can be displayed
|
|
||||||
attachments: message.attachments || [],
|
attachments: message.attachments || [],
|
||||||
|
metadata: authorMetadata,
|
||||||
};
|
};
|
||||||
setMessages((prev) => [...prev, userMessage]);
|
setMessages((prev) => [...prev, userMessage]);
|
||||||
|
|
||||||
|
|
@ -891,6 +909,8 @@ export default function NewChatPage() {
|
||||||
setMentionedDocuments,
|
setMentionedDocuments,
|
||||||
setMessageDocumentsMap,
|
setMessageDocumentsMap,
|
||||||
queryClient,
|
queryClient,
|
||||||
|
currentThread,
|
||||||
|
currentUser,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue