Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -164,33 +164,14 @@ export function ChatPageContent(props: {
props.initialParams?.q,
]);

const [sessionId, _setSessionId] = useState<string | undefined>(
const [sessionId, setSessionId] = useState<string | undefined>(
props.session?.id,
);

const [chatAbortController, setChatAbortController] = useState<
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);
Expand All @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
2 changes: 0 additions & 2 deletions apps/dashboard/src/app/nebula-app/(app)/stores.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createStore } from "@/lib/reactive";
import type { TruncatedSessionInfo } from "./api/types";

export const newChatPageUrlStore = createStore<string | undefined>(undefined);

export const newSessionsStore = createStore<TruncatedSessionInfo[]>([]);

// array of deleted session ids
Expand Down
Loading