From 14b074c03c2f1cc5f97e43ab32e31e455745f7b1 Mon Sep 17 00:00:00 2001 From: d-kimsuon Date: Sat, 30 Aug 2025 16:00:10 +0900 Subject: [PATCH] feat: implement sessions sidebar --- .../projects/[projectId]/hooks/useProject.ts | 2 + .../components/SessionPageContent.tsx | 65 +++++---- .../conversationList/ConversationList.tsx | 26 ++-- .../SidechainConversationModal.tsx | 6 +- .../sessionSidebar/SessionSidebar.tsx | 134 ++++++++++++++++++ src/server/service/session/getSessionMeta.ts | 2 +- src/server/service/session/getSessions.ts | 10 +- src/server/service/types.ts | 2 +- 8 files changed, 195 insertions(+), 52 deletions(-) create mode 100644 src/app/projects/[projectId]/sessions/[sessionId]/components/sessionSidebar/SessionSidebar.tsx diff --git a/src/app/projects/[projectId]/hooks/useProject.ts b/src/app/projects/[projectId]/hooks/useProject.ts index 5824501..964722b 100644 --- a/src/app/projects/[projectId]/hooks/useProject.ts +++ b/src/app/projects/[projectId]/hooks/useProject.ts @@ -11,5 +11,7 @@ export const useProject = (projectId: string) => { return await response.json(); }, + refetchOnReconnect: true, + refetchInterval: 10 * 1000, }); }; diff --git a/src/app/projects/[projectId]/sessions/[sessionId]/components/SessionPageContent.tsx b/src/app/projects/[projectId]/sessions/[sessionId]/components/SessionPageContent.tsx index c20c962..07c286d 100644 --- a/src/app/projects/[projectId]/sessions/[sessionId]/components/SessionPageContent.tsx +++ b/src/app/projects/[projectId]/sessions/[sessionId]/components/SessionPageContent.tsx @@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button"; import { firstCommandToTitle } from "../../../services/firstCommandToTitle"; import { useSession } from "../hooks/useSession"; import { ConversationList } from "./conversationList/ConversationList"; +import { SessionSidebar } from "./sessionSidebar/SessionSidebar"; export const SessionPageContent: FC<{ projectId: string; @@ -18,37 +19,43 @@ export const SessionPageContent: FC<{ ); return ( -
-
- +
+ -
- -

- {session.meta.firstCommand !== null - ? firstCommandToTitle(session.meta.firstCommand) - : sessionId} -

+
+
+
+ + +
+ +

+ {session.meta.firstCommand !== null + ? firstCommandToTitle(session.meta.firstCommand) + : sessionId} +

+
+

+ Session ID: {sessionId} +

+
+ +
+ +
-

- Session ID: {sessionId} -

-
- -
- -
+
); }; diff --git a/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationList/ConversationList.tsx b/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationList/ConversationList.tsx index d224252..c45ff53 100644 --- a/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationList/ConversationList.tsx +++ b/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationList/ConversationList.tsx @@ -51,28 +51,22 @@ export const ConversationList: FC = ({ /> ); + const isSidechain = + conversation.type !== "summary" && conversation.isSidechain; + return [
  • -
    - {elm} -
    +
    {elm}
  • , ]; })} diff --git a/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationModal/SidechainConversationModal.tsx b/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationModal/SidechainConversationModal.tsx index 55047f1..063eed9 100644 --- a/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationModal/SidechainConversationModal.tsx +++ b/src/app/projects/[projectId]/sessions/[sessionId]/components/conversationModal/SidechainConversationModal.tsx @@ -63,7 +63,11 @@ export const SidechainConversationModal: FC< return ( - + + + + + + + {isCollapsed && ( +
    + +
    + )} + + + + ); +}; diff --git a/src/server/service/session/getSessionMeta.ts b/src/server/service/session/getSessionMeta.ts index 6f78f8e..e9ef335 100644 --- a/src/server/service/session/getSessionMeta.ts +++ b/src/server/service/session/getSessionMeta.ts @@ -96,7 +96,7 @@ export const getSessionMeta = async ( messageCount: lines.length, firstCommand: getFirstCommand(jsonlFilePath, lines), lastModifiedAt: lastModifiedUnixTime - ? new Date(lastModifiedUnixTime) + ? new Date(lastModifiedUnixTime).toISOString() : null, }; diff --git a/src/server/service/session/getSessions.ts b/src/server/service/session/getSessions.ts index 07e8a4f..9f4be4b 100644 --- a/src/server/service/session/getSessions.ts +++ b/src/server/service/session/getSessions.ts @@ -5,6 +5,11 @@ import { decodeProjectId } from "../project/id"; import type { Session } from "../types"; import { getSessionMeta } from "./getSessionMeta"; +const getTime = (date: string | null) => { + if (date === null) return 0; + return new Date(date).getTime(); +}; + export const getSessions = async ( projectId: string, ): Promise<{ sessions: Session[] }> => { @@ -27,10 +32,7 @@ export const getSessions = async ( return { sessions: sessions.sort((a, b) => { - return ( - (b.meta.lastModifiedAt?.getTime() ?? 0) - - (a.meta.lastModifiedAt?.getTime() ?? 0) - ); + return getTime(b.meta.lastModifiedAt) - getTime(a.meta.lastModifiedAt); }), }; }; diff --git a/src/server/service/types.ts b/src/server/service/types.ts index f32c4c9..f76ffb4 100644 --- a/src/server/service/types.ts +++ b/src/server/service/types.ts @@ -23,7 +23,7 @@ export type Session = { export type SessionMeta = { messageCount: number; firstCommand: ParsedCommand | null; - lastModifiedAt: Date | null; + lastModifiedAt: string | null; }; export type SessionDetail = Session & {