Fix: Prevent saving path during tab switch

Co-authored-by: ijamespine <ijamespine@me.com>
This commit is contained in:
Cursor Agent
2025-12-24 18:54:58 +00:00
parent ab858bd023
commit 0dd4e688cf
2 changed files with 11 additions and 2 deletions

BIN
bun.lockb
View File

Binary file not shown.

View File

@@ -1,4 +1,4 @@
import { useEffect } from "react";
import { useEffect, useRef } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { useTabManager } from "./useTabManager";
@@ -17,8 +17,17 @@ export function TabNavigationSync() {
const activeTab = tabs.find((t) => t.id === activeTabId);
const currentPath = location.pathname + location.search;
// Save current location to active tab
// Track previous activeTabId to detect tab switches
const prevActiveTabIdRef = useRef(activeTabId);
// Save current location to active tab (only for in-tab navigation)
useEffect(() => {
// Skip saving during tab switch - currentPath belongs to the old tab
if (prevActiveTabIdRef.current !== activeTabId) {
prevActiveTabIdRef.current = activeTabId;
return;
}
if (activeTab && currentPath !== activeTab.savedPath) {
updateTabPath(activeTabId, currentPath);
}