Skip to content

Commit 2b87b7b

Browse files
committed
[NEB-246] Nebula: handle aborted session with no messages (#7025)
<!-- ## 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 enhancing the `ChatSidebar`, `useSessionsWithLocalOverrides`, and `ChatPageContent` components. It improves session handling, updates the chat sidebar title, and adds a user-friendly message for sessions without messages. ### Detailed summary - Updated `title` prop in `<ChatSidebarLink>` to default to "Untitled Chat". - Merged new sessions with existing ones in `useSessionsWithLocalOverrides`. - Introduced a message and icon for sessions with no messages in `ChatPageContent`. - Conditional rendering of `<Chats>` based on message availability. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent d99a985 commit 2b87b7b

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

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

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
DialogTitle,
1010
} from "@/components/ui/dialog";
1111
import { useThirdwebClient } from "@/constants/thirdweb.client";
12-
import { ArrowRightIcon } from "lucide-react";
12+
import { ArrowRightIcon, MessageSquareXIcon } from "lucide-react";
1313
import Link from "next/link";
1414
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
1515
import {
@@ -263,8 +263,11 @@ export function ChatPageContent(props: {
263263
const showEmptyState =
264264
!userHasSubmittedMessage &&
265265
messages.length === 0 &&
266+
!props.session &&
266267
!props.initialParams?.q;
267268

269+
const sessionWithNoMessages = props.session && messages.length === 0;
270+
268271
const connectedWalletsMeta: WalletMeta[] = connectedWallets.map((x) => ({
269272
address: x.getAccount()?.address || "",
270273
walletId: x.id,
@@ -318,17 +321,35 @@ export function ChatPageContent(props: {
318321
</div>
319322
) : (
320323
<div className="fade-in-0 relative z-[0] flex max-h-full flex-1 animate-in flex-col overflow-hidden">
321-
<Chats
322-
messages={messages}
323-
isChatStreaming={isChatStreaming}
324-
authToken={props.authToken}
325-
sessionId={sessionId}
326-
className="min-w-0 pt-6 pb-32"
327-
client={client}
328-
enableAutoScroll={enableAutoScroll}
329-
setEnableAutoScroll={setEnableAutoScroll}
330-
sendMessage={handleSendMessage}
331-
/>
324+
{sessionWithNoMessages && (
325+
<div className="container flex max-h-full max-w-[800px] flex-1 flex-col justify-center py-8">
326+
<div className="flex flex-col items-center justify-center p-4">
327+
<div className="mb-5 rounded-full border bg-card p-3">
328+
<MessageSquareXIcon className="size-6 text-muted-foreground" />
329+
</div>
330+
<p className="mb-1 text-center text-foreground">
331+
No messages found
332+
</p>
333+
<p className="text-balance text-center text-muted-foreground text-sm">
334+
This session was aborted before receiving any messages
335+
</p>
336+
</div>
337+
</div>
338+
)}
339+
340+
{messages.length > 0 && (
341+
<Chats
342+
messages={messages}
343+
isChatStreaming={isChatStreaming}
344+
authToken={props.authToken}
345+
sessionId={sessionId}
346+
className="min-w-0 pt-6 pb-32"
347+
client={client}
348+
enableAutoScroll={enableAutoScroll}
349+
setEnableAutoScroll={setEnableAutoScroll}
350+
sendMessage={handleSendMessage}
351+
/>
352+
)}
332353

333354
<div className="container max-w-[800px]">
334355
<ChatBar

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function ChatSidebar(props: {
8787
return (
8888
<ChatSidebarLink
8989
sessionId={session.id}
90-
title={session.title || session.id}
90+
title={session.title || "Untitled Chat"}
9191
key={session.id}
9292
authToken={props.authToken}
9393
/>

apps/dashboard/src/app/nebula-app/(app)/hooks/useSessionsWithLocalOverrides.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ export function useSessionsWithLocalOverrides(
77
) {
88
const newAddedSessions = useStore(newSessionsStore);
99
const deletedSessions = useStore(deletedSessionsStore);
10-
return [...newAddedSessions, ..._sessions].filter((s) => {
10+
const mergedSessions = [..._sessions];
11+
12+
for (const session of newAddedSessions) {
13+
// if adding a new session that has same id as existing session, update the existing session
14+
const index = mergedSessions.findIndex((s) => s.id === session.id);
15+
if (index !== -1) {
16+
mergedSessions[index] = session;
17+
} else {
18+
mergedSessions.push(session);
19+
}
20+
}
21+
22+
return mergedSessions.filter((s) => {
1123
return !deletedSessions.some((d) => d === s.id);
1224
});
1325
}

0 commit comments

Comments
 (0)