mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-12 20:45:20 +02:00
feat(chat): enhance thread component with active thread handling and improve message loading logic
This commit is contained in:
parent
b4c6061353
commit
e7762cda97
2 changed files with 14 additions and 6 deletions
|
|
@ -758,6 +758,9 @@ export default function NewChatPage() {
|
|||
const loadedMessages = reconcileInterruptedAssistantMessages(messagesResponse.messages).map(
|
||||
convertToThreadMessage
|
||||
);
|
||||
if (messages.length > 0 && loadedMessages.length < messages.length) {
|
||||
return;
|
||||
}
|
||||
setMessages(loadedMessages);
|
||||
|
||||
tokenUsageStore.clear();
|
||||
|
|
@ -778,6 +781,7 @@ export default function NewChatPage() {
|
|||
}, [
|
||||
activeThreadId,
|
||||
isRunning,
|
||||
messages.length,
|
||||
setMessageDocumentsMap,
|
||||
threadMessagesQuery.data,
|
||||
tokenUsageStore,
|
||||
|
|
@ -2569,7 +2573,7 @@ export default function NewChatPage() {
|
|||
>
|
||||
<div key={searchSpaceId} className="flex h-full overflow-hidden">
|
||||
<div className="relative flex-1 flex flex-col min-w-0 overflow-hidden">
|
||||
<Thread />
|
||||
<Thread hasActiveThread={!!activeThreadId} />
|
||||
{isThreadMessagesLoading ? (
|
||||
<div className="absolute inset-0 z-10 bg-panel">
|
||||
<ThreadMessagesSkeleton />
|
||||
|
|
|
|||
|
|
@ -144,11 +144,15 @@ function getComposerSuggestionAnchorPoint(
|
|||
};
|
||||
}
|
||||
|
||||
export const Thread: FC = () => {
|
||||
return <ThreadContent />;
|
||||
interface ThreadProps {
|
||||
hasActiveThread?: boolean;
|
||||
}
|
||||
|
||||
export const Thread: FC<ThreadProps> = ({ hasActiveThread = false }) => {
|
||||
return <ThreadContent hasActiveThread={hasActiveThread} />;
|
||||
};
|
||||
|
||||
const ThreadContent: FC = () => {
|
||||
const ThreadContent: FC<ThreadProps> = ({ hasActiveThread = false }) => {
|
||||
return (
|
||||
<ThreadPrimitive.Root
|
||||
className="aui-root aui-thread-root @container flex h-full min-h-0 flex-col bg-main-panel"
|
||||
|
|
@ -158,13 +162,13 @@ const ThreadContent: FC = () => {
|
|||
>
|
||||
<ChatViewport
|
||||
footer={
|
||||
<AuiIf condition={({ thread }) => !thread.isEmpty}>
|
||||
<AuiIf condition={({ thread }) => hasActiveThread || !thread.isEmpty}>
|
||||
<PremiumQuotaPinnedAlert />
|
||||
<Composer />
|
||||
</AuiIf>
|
||||
}
|
||||
>
|
||||
<AuiIf condition={({ thread }) => thread.isEmpty}>
|
||||
<AuiIf condition={({ thread }) => !hasActiveThread && thread.isEmpty}>
|
||||
<ThreadWelcome />
|
||||
</AuiIf>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue