Skip to content

Commit 4bec834

Browse files
committed
chat: show counter on compact chat hamburger menu
1 parent f629866 commit 4bec834

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/packages/frontend/chat/chatroom.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,19 @@ export function ChatPanel({
537537
);
538538
};
539539

540+
const humanThreads = useMemo(
541+
() => threads.filter((thread) => !thread.isAI),
542+
[threads],
543+
);
544+
const aiThreads = useMemo(
545+
() => threads.filter((thread) => thread.isAI),
546+
[threads],
547+
);
548+
const totalUnread = useMemo(
549+
() => threads.reduce((sum, thread) => sum + thread.unreadCount, 0),
550+
[threads],
551+
);
552+
540553
const renderSidebarContent = () => (
541554
<>
542555
<div style={THREAD_SIDEBAR_HEADER}>
@@ -592,16 +605,8 @@ export function ChatPanel({
592605
</>
593606
)}
594607
</div>
595-
{renderThreadSection(
596-
"Humans",
597-
"users",
598-
threads.filter((thread) => !thread.isAI),
599-
)}
600-
{renderThreadSection(
601-
"AI",
602-
"robot",
603-
threads.filter((thread) => thread.isAI),
604-
)}
608+
{renderThreadSection("Humans", "users", humanThreads)}
609+
{renderThreadSection("AI", "robot", aiThreads)}
605610
</>
606611
);
607612

@@ -812,7 +817,7 @@ export function ChatPanel({
812817
fontSize: "14px",
813818
}}
814819
>
815-
<div>
820+
<div style={{ textAlign: "center" }}>
816821
{threads.length === 0
817822
? "No chats yet. Start a new conversation."
818823
: "Select a chat or start a new conversation."}
@@ -957,6 +962,14 @@ export function ChatPanel({
957962
onClick={() => setSidebarVisible(true)}
958963
>
959964
Chats
965+
<Badge
966+
count={totalUnread}
967+
overflowCount={99}
968+
style={{
969+
backgroundColor: COLORS.GRAY_L0,
970+
color: COLORS.GRAY_D,
971+
}}
972+
/>
960973
</Button>
961974
<Button
962975
type={!selectedThreadKey ? "primary" : "default"}

0 commit comments

Comments
 (0)