From 413e9165745c5321b6979e987aba711cc580c1aa Mon Sep 17 00:00:00 2001 From: Nil2000 Date: Thu, 8 Jan 2026 21:53:38 +0530 Subject: [PATCH 1/5] show user chat history --- .../chat/components/chatHistoryCard.tsx | 77 +++++++++++++++++++ packages/web/src/app/[domain]/chat/page.tsx | 29 ++++++- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx diff --git a/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx b/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx new file mode 100644 index 000000000..7c05660c7 --- /dev/null +++ b/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx @@ -0,0 +1,77 @@ +import React from "react"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Lock, Globe, Clock, ArrowRight } from "lucide-react"; +import { MessageSquare } from "lucide-react"; +import Link from "next/link"; +import { Badge } from "@/components/ui/badge"; + +export default function ChatHistoryCard({ + chat, + domain, +}: { + chat: any; + domain: string; +}) { + const formatDate = (date: Date) => { + const now = new Date(); + const diffInMs = now.getTime() - date.getTime(); + const diffInHours = diffInMs / (1000 * 60 * 60); + const diffInDays = diffInMs / (1000 * 60 * 60 * 24); + + if (diffInHours < 24) { + return 'Today'; + } else if (diffInDays < 7) { + return `${Math.floor(diffInDays)} days ago`; + } else { + return date.toLocaleDateString('en-US', { + month: 'short', + day: 'numeric', + year: date.getFullYear() !== now.getFullYear() ? 'numeric' : undefined + }); + } + }; + + return ( + + + +
+
+
+ +
+
+ + {chat.name || "Untitled Chat"} + +
+
+
+
+ +
+ + {formatDate(new Date(chat.createdAt))} +
+ {chat.visibility === 'PRIVATE' ? ( + + + Private + + ) : ( + + + Public + + )} +
+
+ + ); +} diff --git a/packages/web/src/app/[domain]/chat/page.tsx b/packages/web/src/app/[domain]/chat/page.tsx index 5317328d9..75c3feb89 100644 --- a/packages/web/src/app/[domain]/chat/page.tsx +++ b/packages/web/src/app/[domain]/chat/page.tsx @@ -1,6 +1,6 @@ import { getRepos, getReposStats, getSearchContexts } from "@/actions"; import { SourcebotLogo } from "@/app/components/sourcebotLogo"; -import { getConfiguredLanguageModelsInfo } from "@/features/chat/actions"; +import { getConfiguredLanguageModelsInfo, getUserChatHistory } from "@/features/chat/actions"; import { CustomSlateEditor } from "@/features/chat/customSlateEditor"; import { ServiceErrorException } from "@/lib/serviceError"; import { isServiceError, measure } from "@/lib/utils"; @@ -12,6 +12,8 @@ import { DemoCards } from "./components/demoCards"; import { env } from "@sourcebot/shared"; import { loadJsonFile } from "@sourcebot/shared"; import { DemoExamples, demoExamplesSchema } from "@/types"; +import { auth } from "@/auth"; +import ChatHistoryCard from "./components/chatHistoryCard"; interface PageProps { params: Promise<{ @@ -24,6 +26,8 @@ export default async function Page(props: PageProps) { const languageModels = await getConfiguredLanguageModelsInfo(); const searchContexts = await getSearchContexts(params.domain); const allRepos = await getRepos(); + const session = await auth(); + const chatHistory = session ? await getUserChatHistory() : []; const carouselRepos = await getRepos({ where: { @@ -52,6 +56,10 @@ export default async function Page(props: PageProps) { throw new ServiceErrorException(repoStats); } + if (isServiceError(chatHistory)) { + throw new ServiceErrorException(chatHistory); + } + const demoExamples = env.SOURCEBOT_DEMO_EXAMPLES_PATH ? await (async () => { try { return (await measure(() => loadJsonFile(env.SOURCEBOT_DEMO_EXAMPLES_PATH!, demoExamplesSchema), 'loadExamplesJsonFile')).data; @@ -100,6 +108,25 @@ export default async function Page(props: PageProps) { )} + {chatHistory.length > 0 && ( + <> +
+ +
+
+

Recent Chats

+
+ {chatHistory.map((chat) => ( + + ))} +
+
+ + )} ) From 48ae05eb85fe5697dca4b1acf2c2751729f0d031 Mon Sep 17 00:00:00 2001 From: Nil2000 Date: Thu, 8 Jan 2026 22:04:38 +0530 Subject: [PATCH 2/5] limit chat history display to 3 recent chats --- packages/web/src/app/[domain]/chat/page.tsx | 3 ++- packages/web/src/lib/constants.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/web/src/app/[domain]/chat/page.tsx b/packages/web/src/app/[domain]/chat/page.tsx index 75c3feb89..9820e8665 100644 --- a/packages/web/src/app/[domain]/chat/page.tsx +++ b/packages/web/src/app/[domain]/chat/page.tsx @@ -14,6 +14,7 @@ import { loadJsonFile } from "@sourcebot/shared"; import { DemoExamples, demoExamplesSchema } from "@/types"; import { auth } from "@/auth"; import ChatHistoryCard from "./components/chatHistoryCard"; +import { CHAT_HISTORY_DISPLAY_LIMIT } from "@/lib/constants"; interface PageProps { params: Promise<{ @@ -116,7 +117,7 @@ export default async function Page(props: PageProps) {

Recent Chats

- {chatHistory.map((chat) => ( + {chatHistory.slice(0, CHAT_HISTORY_DISPLAY_LIMIT).map((chat) => ( Date: Fri, 9 Jan 2026 21:14:06 +0530 Subject: [PATCH 3/5] removed old cards and added existing chat sidebar --- .../chat/components/chatHistoryCard.tsx | 77 ------------- packages/web/src/app/[domain]/chat/page.tsx | 103 +++++++++--------- packages/web/src/lib/constants.ts | 2 - 3 files changed, 50 insertions(+), 132 deletions(-) delete mode 100644 packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx diff --git a/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx b/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx deleted file mode 100644 index 7c05660c7..000000000 --- a/packages/web/src/app/[domain]/chat/components/chatHistoryCard.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import React from "react"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { Lock, Globe, Clock, ArrowRight } from "lucide-react"; -import { MessageSquare } from "lucide-react"; -import Link from "next/link"; -import { Badge } from "@/components/ui/badge"; - -export default function ChatHistoryCard({ - chat, - domain, -}: { - chat: any; - domain: string; -}) { - const formatDate = (date: Date) => { - const now = new Date(); - const diffInMs = now.getTime() - date.getTime(); - const diffInHours = diffInMs / (1000 * 60 * 60); - const diffInDays = diffInMs / (1000 * 60 * 60 * 24); - - if (diffInHours < 24) { - return 'Today'; - } else if (diffInDays < 7) { - return `${Math.floor(diffInDays)} days ago`; - } else { - return date.toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - year: date.getFullYear() !== now.getFullYear() ? 'numeric' : undefined - }); - } - }; - - return ( - - - -
-
-
- -
-
- - {chat.name || "Untitled Chat"} - -
-
-
-
- -
- - {formatDate(new Date(chat.createdAt))} -
- {chat.visibility === 'PRIVATE' ? ( - - - Private - - ) : ( - - - Public - - )} -
-
- - ); -} diff --git a/packages/web/src/app/[domain]/chat/page.tsx b/packages/web/src/app/[domain]/chat/page.tsx index 9820e8665..2b7822dfb 100644 --- a/packages/web/src/app/[domain]/chat/page.tsx +++ b/packages/web/src/app/[domain]/chat/page.tsx @@ -13,8 +13,9 @@ import { env } from "@sourcebot/shared"; import { loadJsonFile } from "@sourcebot/shared"; import { DemoExamples, demoExamplesSchema } from "@/types"; import { auth } from "@/auth"; -import ChatHistoryCard from "./components/chatHistoryCard"; -import { CHAT_HISTORY_DISPLAY_LIMIT } from "@/lib/constants"; +import { ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; +import { ChatSidePanel } from "./components/chatSidePanel"; +import { AnimatedResizableHandle } from "@/components/ui/animatedResizableHandle"; interface PageProps { params: Promise<{ @@ -71,64 +72,60 @@ export default async function Page(props: PageProps) { })() : undefined; return ( -
+
+ + + + +
+
+ +
+ + + -
-
- -
- - - - -
- -
- - {demoExamples && ( - <> -
- -
- - + - - )} +
- {chatHistory.length > 0 && ( - <> -
- -
-
-

Recent Chats

-
- {chatHistory.slice(0, CHAT_HISTORY_DISPLAY_LIMIT).map((chat) => ( - - ))} + {demoExamples && ( + <> +
+
-
- - )} -
+ + + + )} +
+
+
) } \ No newline at end of file diff --git a/packages/web/src/lib/constants.ts b/packages/web/src/lib/constants.ts index d2175fa08..21bb97d54 100644 --- a/packages/web/src/lib/constants.ts +++ b/packages/web/src/lib/constants.ts @@ -34,6 +34,4 @@ export const SINGLE_TENANT_ORG_ID = 1; export const SINGLE_TENANT_ORG_DOMAIN = '~'; export const SINGLE_TENANT_ORG_NAME = 'default'; -export const CHAT_HISTORY_DISPLAY_LIMIT = 3; - export { SOURCEBOT_SUPPORT_EMAIL } from "@sourcebot/shared/client"; \ No newline at end of file From 3beb1fdd2d1a2f7020c0d0ba9b2de12cda17102f Mon Sep 17 00:00:00 2001 From: Nil2000 Date: Sat, 10 Jan 2026 00:59:23 +0530 Subject: [PATCH 4/5] allow scrolling --- packages/web/src/app/[domain]/chat/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/app/[domain]/chat/page.tsx b/packages/web/src/app/[domain]/chat/page.tsx index 2b7822dfb..27ce439c5 100644 --- a/packages/web/src/app/[domain]/chat/page.tsx +++ b/packages/web/src/app/[domain]/chat/page.tsx @@ -72,7 +72,7 @@ export default async function Page(props: PageProps) { })() : undefined; return ( -
+
From 50c594e1a149818bc45f3bb139f362aa6413d644 Mon Sep 17 00:00:00 2001 From: Nil2000 Date: Sat, 10 Jan 2026 20:16:40 +0530 Subject: [PATCH 5/5] small ui fix --- packages/web/src/app/[domain]/chat/page.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web/src/app/[domain]/chat/page.tsx b/packages/web/src/app/[domain]/chat/page.tsx index 27ce439c5..43ef9d063 100644 --- a/packages/web/src/app/[domain]/chat/page.tsx +++ b/packages/web/src/app/[domain]/chat/page.tsx @@ -78,6 +78,7 @@ export default async function Page(props: PageProps) { />