Skip to content

Commit

Permalink
Dupe welcome modal logic (onyx-dot-app#2656)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx authored Oct 2, 2024
1 parent bd40328 commit 07aeea6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 0 additions & 2 deletions web/src/app/prompts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrapper";
import { fetchChatData } from "@/lib/chat/fetchChatData";
import { unstable_noStore as noStore } from "next/cache";
import { redirect } from "next/navigation";
Expand All @@ -23,7 +22,6 @@ export default async function GalleryPage({
assistants,
folders,
openedFolders,
shouldShowWelcomeModal,
toggleSidebar,
} = data;

Expand Down
24 changes: 9 additions & 15 deletions web/src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
} from "@/lib/constants";
import WrappedSearch from "./WrappedSearch";
import { SearchProvider } from "@/components/context/SearchContext";
import { ProviderContextProvider } from "@/components/chat_search/ProviderContext";
import { fetchLLMProvidersSS } from "@/lib/llm/fetchLLMs";
import { LLMProviderDescriptor } from "../admin/configuration/llm/interfaces";

export default async function Home() {
// Disable caching so we always get the up to date connector / document set / persona info
Expand All @@ -49,8 +50,8 @@ export default async function Home() {
fetchSS("/manage/document-set"),
fetchAssistantsSS(),
fetchSS("/query/valid-tags"),
fetchSS("/search-settings/get-all-search-settings"),
fetchSS("/query/user-searches"),
fetchLLMProvidersSS(),
];

// catch cases where the backend is completely unreachable here
Expand All @@ -62,8 +63,9 @@ export default async function Home() {
| AuthTypeMetadata
| FullEmbeddingModelResponse
| FetchAssistantsResponse
| LLMProviderDescriptor[]
| null
)[] = [null, null, null, null, null, null];
)[] = [null, null, null, null, null, null, null, null];
try {
results = await Promise.all(tasks);
} catch (e) {
Expand All @@ -76,8 +78,8 @@ export default async function Home() {
const [initialAssistantsList, assistantsFetchError] =
results[4] as FetchAssistantsResponse;
const tagsResponse = results[5] as Response | null;
const embeddingModelResponse = results[6] as Response | null;
const queryResponse = results[7] as Response | null;
const queryResponse = results[6] as Response | null;
const llmProviders = (results[7] || []) as LLMProviderDescriptor[];

const authDisabled = authTypeMetadata?.authType === "disabled";
if (!authDisabled && !user) {
Expand Down Expand Up @@ -130,16 +132,6 @@ export default async function Home() {
console.log(`Failed to fetch tags - ${tagsResponse?.status}`);
}

const embeddingModelVersionInfo =
embeddingModelResponse && embeddingModelResponse.ok
? ((await embeddingModelResponse.json()) as FullEmbeddingModelResponse)
: null;

const currentEmbeddingModelName =
embeddingModelVersionInfo?.current_model_name;
const nextEmbeddingModelName =
embeddingModelVersionInfo?.secondary_model_name;

// needs to be done in a non-client side component due to nextjs
const storedSearchType = cookies().get("searchType")?.value as
| string
Expand All @@ -151,7 +143,9 @@ export default async function Home() {
: SearchType.SEMANTIC; // default to semantic

const hasAnyConnectors = ccPairs.length > 0;

const shouldShowWelcomeModal =
!llmProviders.length &&
!hasCompletedWelcomeFlowSS() &&
!hasAnyConnectors &&
(!user || user.role === "admin");
Expand Down

0 comments on commit 07aeea6

Please sign in to comment.