mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +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(
|
const loadedMessages = reconcileInterruptedAssistantMessages(messagesResponse.messages).map(
|
||||||
convertToThreadMessage
|
convertToThreadMessage
|
||||||
);
|
);
|
||||||
|
if (messages.length > 0 && loadedMessages.length < messages.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setMessages(loadedMessages);
|
setMessages(loadedMessages);
|
||||||
|
|
||||||
tokenUsageStore.clear();
|
tokenUsageStore.clear();
|
||||||
|
|
@ -778,6 +781,7 @@ export default function NewChatPage() {
|
||||||
}, [
|
}, [
|
||||||
activeThreadId,
|
activeThreadId,
|
||||||
isRunning,
|
isRunning,
|
||||||
|
messages.length,
|
||||||
setMessageDocumentsMap,
|
setMessageDocumentsMap,
|
||||||
threadMessagesQuery.data,
|
threadMessagesQuery.data,
|
||||||
tokenUsageStore,
|
tokenUsageStore,
|
||||||
|
|
@ -2569,7 +2573,7 @@ export default function NewChatPage() {
|
||||||
>
|
>
|
||||||
<div key={searchSpaceId} className="flex h-full overflow-hidden">
|
<div key={searchSpaceId} className="flex h-full overflow-hidden">
|
||||||
<div className="relative flex-1 flex flex-col min-w-0 overflow-hidden">
|
<div className="relative flex-1 flex flex-col min-w-0 overflow-hidden">
|
||||||
<Thread />
|
<Thread hasActiveThread={!!activeThreadId} />
|
||||||
{isThreadMessagesLoading ? (
|
{isThreadMessagesLoading ? (
|
||||||
<div className="absolute inset-0 z-10 bg-panel">
|
<div className="absolute inset-0 z-10 bg-panel">
|
||||||
<ThreadMessagesSkeleton />
|
<ThreadMessagesSkeleton />
|
||||||
|
|
|
||||||
|
|
@ -144,11 +144,15 @@ function getComposerSuggestionAnchorPoint(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Thread: FC = () => {
|
interface ThreadProps {
|
||||||
return <ThreadContent />;
|
hasActiveThread?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Thread: FC<ThreadProps> = ({ hasActiveThread = false }) => {
|
||||||
|
return <ThreadContent hasActiveThread={hasActiveThread} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThreadContent: FC = () => {
|
const ThreadContent: FC<ThreadProps> = ({ hasActiveThread = false }) => {
|
||||||
return (
|
return (
|
||||||
<ThreadPrimitive.Root
|
<ThreadPrimitive.Root
|
||||||
className="aui-root aui-thread-root @container flex h-full min-h-0 flex-col bg-main-panel"
|
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
|
<ChatViewport
|
||||||
footer={
|
footer={
|
||||||
<AuiIf condition={({ thread }) => !thread.isEmpty}>
|
<AuiIf condition={({ thread }) => hasActiveThread || !thread.isEmpty}>
|
||||||
<PremiumQuotaPinnedAlert />
|
<PremiumQuotaPinnedAlert />
|
||||||
<Composer />
|
<Composer />
|
||||||
</AuiIf>
|
</AuiIf>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<AuiIf condition={({ thread }) => thread.isEmpty}>
|
<AuiIf condition={({ thread }) => !hasActiveThread && thread.isEmpty}>
|
||||||
<ThreadWelcome />
|
<ThreadWelcome />
|
||||||
</AuiIf>
|
</AuiIf>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue