From ea54c3d11285ddec9e42a39a46a80ab5c57c546b Mon Sep 17 00:00:00 2001 From: jamesx0416 Date: Tue, 19 May 2026 17:06:45 +1000 Subject: [PATCH 1/2] Replace settings route when reopening settings --- apps/web/src/components/AppSidebarLayout.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx index d98f30a1e5c..613263789bd 100644 --- a/apps/web/src/components/AppSidebarLayout.tsx +++ b/apps/web/src/components/AppSidebarLayout.tsx @@ -1,5 +1,5 @@ -import { useEffect, type ReactNode } from "react"; -import { useNavigate } from "@tanstack/react-router"; +import { useEffect, useRef, type ReactNode } from "react"; +import { useLocation, useNavigate } from "@tanstack/react-router"; import ThreadSidebar from "./Sidebar"; import { Sidebar, SidebarProvider, SidebarRail } from "./ui/sidebar"; @@ -13,6 +13,9 @@ const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16; const THREAD_MAIN_CONTENT_MIN_WIDTH = 40 * 16; export function AppSidebarLayout({ children }: { children: ReactNode }) { const navigate = useNavigate(); + const pathname = useLocation({ select: (location) => location.pathname }); + const pathnameRef = useRef(pathname); + pathnameRef.current = pathname; useEffect(() => { const onWindowKeyDown = (event: KeyboardEvent) => { @@ -44,7 +47,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) { const unsubscribe = onMenuAction((action) => { if (action === "open-settings") { - void navigate({ to: "/settings" }); + void navigate({ to: "/settings", replace: pathnameRef.current.startsWith("/settings") }); } }); From 916a1b25c1fc3c0ac6d1bd4c0dc8e3d672dbb1a4 Mon Sep 17 00:00:00 2001 From: jamesx0416 Date: Mon, 22 Jun 2026 10:27:10 +1000 Subject: [PATCH 2/2] fix: check settings route boundary --- apps/web/src/components/AppSidebarLayout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx index 0992e6b6e3f..40ea4e6bc6f 100644 --- a/apps/web/src/components/AppSidebarLayout.tsx +++ b/apps/web/src/components/AppSidebarLayout.tsx @@ -21,7 +21,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) { const unsubscribe = onMenuAction((action) => { if (action === "open-settings") { - void navigate({ to: "/settings", replace: pathnameRef.current.startsWith("/settings") }); + void navigate({ to: "/settings", replace: /^\/settings(\/|$)/.test(pathnameRef.current) }); } });