Skip to content

Commit a317772

Browse files
committed
[NEB-225] Fix Nebula new chat button link (#6912)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring the chat application by removing the usage of `newChatPageUrlStore` and replacing it with layout segment navigation. It streamlines the chat page link logic and cleans up unused code related to session ID management. ### Detailed summary - Removed `newChatPageUrlStore` from `stores.ts` and `useNewChatPageLink.ts`. - Updated `useNewChatPageLink` to use `useSelectedLayoutSegment` for navigation. - Removed session ID management logic from `ChatPageContent.tsx`. - Cleaned up unused state and callback related to session ID. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent cef477d commit a317772

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { type NebulaContext, promptNebula } from "../api/chat";
2222
import { createSession, updateSession } from "../api/session";
2323
import type { SessionInfo } from "../api/types";
2424
import { examplePrompts } from "../data/examplePrompts";
25-
import { newChatPageUrlStore, newSessionsStore } from "../stores";
25+
import { newSessionsStore } from "../stores";
2626
import { ChatBar, type WalletMeta } from "./ChatBar";
2727
import { type ChatMessage, Chats } from "./Chats";
2828
import { EmptyStateChatPageContent } from "./EmptyStateChatPageContent";
@@ -164,33 +164,14 @@ export function ChatPageContent(props: {
164164
props.initialParams?.q,
165165
]);
166166

167-
const [sessionId, _setSessionId] = useState<string | undefined>(
167+
const [sessionId, setSessionId] = useState<string | undefined>(
168168
props.session?.id,
169169
);
170170

171171
const [chatAbortController, setChatAbortController] = useState<
172172
AbortController | undefined
173173
>();
174174

175-
const setSessionId = useCallback(
176-
(sessionId: string) => {
177-
_setSessionId(sessionId);
178-
// update page URL without reloading
179-
// THIS DOES NOT WORK ANYMORE!! - NEXT JS IS MONKEY PATCHING THIS TOO
180-
// Until we find a better solution, we are just not gonna update the URL
181-
// window.history.replaceState({}, "", `/chat/${sessionId}`);
182-
183-
// if the current page is landing page, link to /chat
184-
// if current page is new /chat page, link to landing page
185-
if (props.type === "landing") {
186-
newChatPageUrlStore.setValue("/chat");
187-
} else {
188-
newChatPageUrlStore.setValue("/");
189-
}
190-
},
191-
[props.type],
192-
);
193-
194175
const [isChatStreaming, setIsChatStreaming] = useState(false);
195176
const [enableAutoScroll, setEnableAutoScroll] = useState(false);
196177
const [showConnectModal, setShowConnectModal] = useState(false);
@@ -202,7 +183,7 @@ export function ChatPageContent(props: {
202183
});
203184
setSessionId(session.id);
204185
return session;
205-
}, [contextFilters, props.authToken, setSessionId]);
186+
}, [contextFilters, props.authToken]);
206187

207188
const handleSendMessage = useCallback(
208189
async (message: string) => {
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"use client";
22

3-
import { useStore } from "@/lib/reactive";
4-
import { newChatPageUrlStore } from "../stores";
3+
import { useSelectedLayoutSegment } from "next/navigation";
54

65
export function useNewChatPageLink() {
7-
const newChatPage = useStore(newChatPageUrlStore);
8-
return newChatPage || "/chat";
6+
const selectedLayout = useSelectedLayoutSegment();
7+
return selectedLayout === "chat" ? "/" : "/chat";
98
}

apps/dashboard/src/app/nebula-app/(app)/stores.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { createStore } from "@/lib/reactive";
22
import type { TruncatedSessionInfo } from "./api/types";
33

4-
export const newChatPageUrlStore = createStore<string | undefined>(undefined);
5-
64
export const newSessionsStore = createStore<TruncatedSessionInfo[]>([]);
75

86
// array of deleted session ids

0 commit comments

Comments
 (0)