mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-21 14:12:42 +02:00
Improve chat page performance (#3347)
* Simplify /manage/indexing-status * Rename endpoint
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Modal } from "../../Modal";
|
||||
import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
import { CCPairBasicInfo } from "@/lib/types";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export function NoCompleteSourcesModal({
|
||||
ccPairs,
|
||||
}: {
|
||||
ccPairs: CCPairBasicInfo[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isHidden, setIsHidden] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
router.refresh();
|
||||
}, 5000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [router]);
|
||||
|
||||
if (isHidden) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const totalDocs = ccPairs.reduce(
|
||||
(acc, ccPair) => acc + ccPair.docs_indexed,
|
||||
0
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
className="max-w-4xl"
|
||||
title="⏳ None of your connectors have finished a full sync yet"
|
||||
onOutsideClick={() => setIsHidden(true)}
|
||||
>
|
||||
<div className="text-sm">
|
||||
<div>
|
||||
<div>
|
||||
You've connected some sources, but none of them have finished
|
||||
syncing. Depending on the size of the knowledge base(s) you've
|
||||
connected to Danswer, it can take anywhere between 30 seconds to a
|
||||
few days for the initial sync to complete. So far we've synced{" "}
|
||||
<b>{totalDocs}</b> documents.
|
||||
<br />
|
||||
<br />
|
||||
To view the status of your syncing connectors, head over to the{" "}
|
||||
<Link className="text-link" href="admin/indexing/status">
|
||||
Existing Connectors page
|
||||
</Link>
|
||||
.
|
||||
<br />
|
||||
<br />
|
||||
<p
|
||||
className="text-link cursor-pointer inline"
|
||||
onClick={() => {
|
||||
setIsHidden(true);
|
||||
}}
|
||||
>
|
||||
Or, click here to continue and ask questions on the partially
|
||||
synced knowledge set.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
@@ -26,7 +26,7 @@ export async function fetchAssistantEditorInfoSS(
|
||||
| [null, string]
|
||||
> {
|
||||
const tasks = [
|
||||
fetchSS("/manage/indexing-status"),
|
||||
fetchSS("/manage/connector-status"),
|
||||
fetchSS("/manage/document-set"),
|
||||
fetchSS("/llm/provider"),
|
||||
// duplicate fetch, but shouldn't be too big of a deal
|
||||
|
@@ -30,7 +30,7 @@ export async function fetchAssistantData(): Promise<AssistantData> {
|
||||
|
||||
// Parallel fetch of additional data
|
||||
const [ccPairsResponse, llmProviders] = await Promise.all([
|
||||
fetchSS("/manage/indexing-status").catch((error) => {
|
||||
fetchSS("/manage/connector-status").catch((error) => {
|
||||
console.error("Failed to fetch connectors:", error);
|
||||
return null;
|
||||
}),
|
||||
|
@@ -52,7 +52,7 @@ export async function fetchChatData(searchParams: {
|
||||
const tasks = [
|
||||
getAuthTypeMetadataSS(),
|
||||
getCurrentUserSS(),
|
||||
fetchSS("/manage/indexing-status"),
|
||||
fetchSS("/manage/connector-status"),
|
||||
fetchSS("/manage/document-set"),
|
||||
fetchSS("/chat/get-user-chat-sessions"),
|
||||
fetchSS("/query/valid-tags"),
|
||||
|
@@ -70,7 +70,7 @@ export async function fetchSomeChatData(
|
||||
const taskMap: Record<FetchOption, () => Promise<any>> = {
|
||||
user: getCurrentUserSS,
|
||||
chatSessions: () => fetchSS("/chat/get-user-chat-sessions"),
|
||||
ccPairs: () => fetchSS("/manage/indexing-status"),
|
||||
ccPairs: () => fetchSS("/manage/connector-status"),
|
||||
documentSets: () => fetchSS("/manage/document-set"),
|
||||
assistants: fetchAssistantsSS,
|
||||
tags: () => fetchSS("/query/valid-tags"),
|
||||
@@ -229,9 +229,7 @@ export async function fetchSomeChatData(
|
||||
result.shouldDisplaySourcesIncompleteModal =
|
||||
hasAnyConnectors &&
|
||||
!result.shouldShowWelcomeModal &&
|
||||
!result.ccPairs.some(
|
||||
(ccPair) => ccPair.has_successful_run && ccPair.docs_indexed > 0
|
||||
) &&
|
||||
!result.ccPairs.some((ccPair) => ccPair.has_successful_run) &&
|
||||
(!user || user.role === "admin");
|
||||
}
|
||||
|
||||
|
@@ -136,7 +136,6 @@ export interface ConnectorIndexingStatus<
|
||||
}
|
||||
|
||||
export interface CCPairBasicInfo {
|
||||
docs_indexed: number;
|
||||
has_successful_run: boolean;
|
||||
source: ValidSources;
|
||||
}
|
||||
|
Reference in New Issue
Block a user