From 44621c345fe7ce7cfa5d8e5286290d9c8dc20ce5 Mon Sep 17 00:00:00 2001 From: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com> Date: Tue, 11 Aug 2026 21:56:24 +0530 Subject: [PATCH] feat(web): add back buttons for the pull requests and usage pages in the sidebar footer (#6031) Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com> --- .../src/components/sidebar/SidebarChrome.tsx | 57 ++++++++++++++++--- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsx index e9d3dcbc4362294384fc236aa9975cf93767e968..48479d8372a86bfece4cdaefebf835075568154d 100644 --- a/apps/web/src/components/sidebar/SidebarChrome.tsx +++ b/apps/web/src/components/sidebar/SidebarChrome.tsx @@ -1,6 +1,11 @@ -import { ChartNoAxesColumnIcon, GitPullRequestIcon, SettingsIcon } from "lucide-react"; +import { + ArrowLeftIcon, + ChartNoAxesColumnIcon, + GitPullRequestIcon, + SettingsIcon, +} from "lucide-react"; import { memo, useCallback } from "react"; -import { Link, useNavigate } from "@tanstack/react-router"; +import { Link, useCanGoBack, useLocation, useNavigate } from "@tanstack/react-router"; import { useEnvironmentIdentificationMode } from "../../hooks/useSettings"; import { cn } from "../../lib/utils"; @@ -114,6 +119,15 @@ function T3Wordmark() { export const SidebarChromeFooter = memo(function SidebarChromeFooter() { const navigate = useNavigate(); const { isMobile, setOpenMobile } = useSidebar(); + const canGoBack = useCanGoBack(); + const currentFooterPage = useLocation({ + select: (location) => + location.pathname === "/usage" + ? "usage" + : location.pathname === "/pull-requests" + ? "pull-requests" + : null, + }); const primaryEnvironment = usePrimaryEnvironment(); const pullRequestsSupported = primaryEnvironment?.serverConfig?.environment.capabilities.pullRequests === true; @@ -138,12 +152,28 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() { void navigate({ to: "/usage" }); }, [isMobile, navigate, setOpenMobile]); + const handleBackClick = useCallback(() => { + closeMobileSidebar(); + if (canGoBack) { + window.history.back(); + return; + } + void navigate({ to: "/" }); + }, [canGoBack, closeMobileSidebar, navigate]); + return ( - {pullRequestsSupported ? ( + {currentFooterPage === "pull-requests" ? ( + + + + Back + + + ) : pullRequestsSupported ? ( @@ -151,12 +181,21 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() { ) : null} - - - - Usage - - + {currentFooterPage === "usage" ? ( + + + + Back + + + ) : ( + + + + Usage + + + )} -- 2.54.0