diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx index e1ab264463e..4aedec088c9 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx @@ -22,7 +22,7 @@ import { type NebulaContext, promptNebula } from "../api/chat"; import { createSession, updateSession } from "../api/session"; import type { SessionInfo } from "../api/types"; import { examplePrompts } from "../data/examplePrompts"; -import { newChatPageUrlStore, newSessionsStore } from "../stores"; +import { newSessionsStore } from "../stores"; import { ChatBar, type WalletMeta } from "./ChatBar"; import { type ChatMessage, Chats } from "./Chats"; import { EmptyStateChatPageContent } from "./EmptyStateChatPageContent"; @@ -164,7 +164,7 @@ export function ChatPageContent(props: { props.initialParams?.q, ]); - const [sessionId, _setSessionId] = useState( + const [sessionId, setSessionId] = useState( props.session?.id, ); @@ -172,25 +172,6 @@ export function ChatPageContent(props: { AbortController | undefined >(); - const setSessionId = useCallback( - (sessionId: string) => { - _setSessionId(sessionId); - // update page URL without reloading - // THIS DOES NOT WORK ANYMORE!! - NEXT JS IS MONKEY PATCHING THIS TOO - // Until we find a better solution, we are just not gonna update the URL - // window.history.replaceState({}, "", `/chat/${sessionId}`); - - // if the current page is landing page, link to /chat - // if current page is new /chat page, link to landing page - if (props.type === "landing") { - newChatPageUrlStore.setValue("/chat"); - } else { - newChatPageUrlStore.setValue("/"); - } - }, - [props.type], - ); - const [isChatStreaming, setIsChatStreaming] = useState(false); const [enableAutoScroll, setEnableAutoScroll] = useState(false); const [showConnectModal, setShowConnectModal] = useState(false); @@ -202,7 +183,7 @@ export function ChatPageContent(props: { }); setSessionId(session.id); return session; - }, [contextFilters, props.authToken, setSessionId]); + }, [contextFilters, props.authToken]); const handleSendMessage = useCallback( async (message: string) => { diff --git a/apps/dashboard/src/app/nebula-app/(app)/hooks/useNewChatPageLink.ts b/apps/dashboard/src/app/nebula-app/(app)/hooks/useNewChatPageLink.ts index ce95320bca8..aafd6dfdaed 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/hooks/useNewChatPageLink.ts +++ b/apps/dashboard/src/app/nebula-app/(app)/hooks/useNewChatPageLink.ts @@ -1,9 +1,8 @@ "use client"; -import { useStore } from "@/lib/reactive"; -import { newChatPageUrlStore } from "../stores"; +import { useSelectedLayoutSegment } from "next/navigation"; export function useNewChatPageLink() { - const newChatPage = useStore(newChatPageUrlStore); - return newChatPage || "/chat"; + const selectedLayout = useSelectedLayoutSegment(); + return selectedLayout === "chat" ? "/" : "/chat"; } diff --git a/apps/dashboard/src/app/nebula-app/(app)/stores.ts b/apps/dashboard/src/app/nebula-app/(app)/stores.ts index 8e4304cc853..11a3327e04f 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/stores.ts +++ b/apps/dashboard/src/app/nebula-app/(app)/stores.ts @@ -1,8 +1,6 @@ import { createStore } from "@/lib/reactive"; import type { TruncatedSessionInfo } from "./api/types"; -export const newChatPageUrlStore = createStore(undefined); - export const newSessionsStore = createStore([]); // array of deleted session ids