feat(sidebar): add onChatsClick handler to sidebar components for improved navigation

This commit is contained in:
Anish Sarkar 2026-07-15 21:16:38 +05:30
parent a466fdcf5d
commit 8aaf9cadbe
4 changed files with 31 additions and 1 deletions

View file

@ -631,6 +631,9 @@ export function LayoutDataProvider({
const isArtifactsPage = pathname?.endsWith("/artifacts") === true;
const isPlaygroundPage = pathname?.includes("/playground") === true;
const isAllChatsPage = pathname?.endsWith("/chats") === true;
const handleChatsClick = useCallback(() => {
router.push(`/dashboard/${workspaceId}/chats`);
}, [router, workspaceId]);
const handleViewAllChats = useCallback(() => {
router.push(
isAllChatsPage ? `/dashboard/${workspaceId}/new-chat` : `/dashboard/${workspaceId}/chats`
@ -671,6 +674,7 @@ export function LayoutDataProvider({
onChatRename={handleChatRename}
onChatDelete={handleChatDelete}
onChatArchive={handleChatArchive}
onChatsClick={handleChatsClick}
onViewAllChats={handleViewAllChats}
user={{
email: user?.email || "",

View file

@ -106,6 +106,7 @@ interface LayoutShellProps {
onChatRename?: (chat: ChatItem) => void;
onChatDelete?: (chat: ChatItem) => void;
onChatArchive?: (chat: ChatItem) => void;
onChatsClick?: () => void;
onViewAllChats?: () => void;
user: User;
onSettings?: () => void;
@ -208,6 +209,7 @@ export function LayoutShell({
onChatRename,
onChatDelete,
onChatArchive,
onChatsClick,
onViewAllChats,
user,
onSettings,
@ -289,6 +291,7 @@ export function LayoutShell({
onChatRename={onChatRename}
onChatDelete={onChatDelete}
onChatArchive={onChatArchive}
onChatsClick={onChatsClick}
onViewAllChats={onViewAllChats}
isAllChatsActive={isAllChatsPage}
user={user}
@ -388,6 +391,7 @@ export function LayoutShell({
onChatRename={onChatRename}
onChatDelete={onChatDelete}
onChatArchive={onChatArchive}
onChatsClick={onChatsClick}
onViewAllChats={onViewAllChats}
isAllChatsActive={isAllChatsPage}
user={user}

View file

@ -28,6 +28,7 @@ interface MobileSidebarProps {
onChatRename?: (chat: ChatItem) => void;
onChatDelete?: (chat: ChatItem) => void;
onChatArchive?: (chat: ChatItem) => void;
onChatsClick?: () => void;
onViewAllChats?: () => void;
isAllChatsActive?: boolean;
user: User;
@ -77,6 +78,7 @@ export function MobileSidebar({
onChatRename,
onChatDelete,
onChatArchive,
onChatsClick,
onViewAllChats,
isAllChatsActive = false,
user,
@ -194,6 +196,14 @@ export function MobileSidebar({
onChatRename={onChatRename}
onChatDelete={onChatDelete}
onChatArchive={onChatArchive}
onChatsClick={
onChatsClick
? () => {
onOpenChange(false);
onChatsClick();
}
: undefined
}
onViewAllChats={
onViewAllChats
? () => {

View file

@ -1,6 +1,6 @@
"use client";
import { CreditCard, SquarePen, Zap } from "lucide-react";
import { CreditCard, MessageCircleMore, SquarePen, Zap } from "lucide-react";
import Link from "next/link";
import { useParams } from "next/navigation";
import { useTranslations } from "next-intl";
@ -62,6 +62,7 @@ interface SidebarProps {
onChatRename?: (chat: ChatItem) => void;
onChatDelete?: (chat: ChatItem) => void;
onChatArchive?: (chat: ChatItem) => void;
onChatsClick?: () => void;
onViewAllChats?: () => void;
isAllChatsActive?: boolean;
user: User;
@ -101,6 +102,7 @@ export function Sidebar({
onChatRename,
onChatDelete,
onChatArchive,
onChatsClick,
onViewAllChats,
isAllChatsActive = false,
user,
@ -222,6 +224,16 @@ export function Sidebar({
onScroll={(event) => setIsSidebarNavScrolled(event.currentTarget.scrollTop > 0)}
>
<div className="flex flex-col gap-0.5 pt-0.5 pb-1.5">
{onChatsClick && (
<SidebarButton
icon={MessageCircleMore}
label={t("chats") || "Chats"}
onClick={onChatsClick}
isCollapsed={isCollapsed}
isActive={isAllChatsActive}
tooltipContent={isCollapsed ? t("chats") || "Chats" : undefined}
/>
)}
{automationsItem && (
<SidebarButton
icon={automationsItem.icon}