Skip to content
9 changes: 6 additions & 3 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -9,6 +9,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 onMenuAction = window.desktopBridge?.onMenuAction;
Expand All @@ -18,7 +21,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") });
Comment thread
jamesx0416 marked this conversation as resolved.
Outdated
}
});

Expand Down
Loading