diff --git a/apps/desktop/src/renderer/index.tsx b/apps/desktop/src/renderer/index.tsx
index 3d45899fe16..3b917ecc559 100644
--- a/apps/desktop/src/renderer/index.tsx
+++ b/apps/desktop/src/renderer/index.tsx
@@ -2,7 +2,6 @@ import { initSentry } from "./lib/sentry";
initSentry();
-import React from "react";
import ReactDom from "react-dom/client";
import { ThemedToaster } from "./components/ThemedToaster";
@@ -12,10 +11,8 @@ import { AppRoutes } from "./routes";
import "./globals.css";
ReactDom.createRoot(document.querySelector("app") as HTMLElement).render(
-
-
-
-
-
- ,
+
+
+
+ ,
);
diff --git a/apps/desktop/src/renderer/stores/tabs/store.ts b/apps/desktop/src/renderer/stores/tabs/store.ts
index b1c1b0d66fc..764e6e7f1a9 100644
--- a/apps/desktop/src/renderer/stores/tabs/store.ts
+++ b/apps/desktop/src/renderer/stores/tabs/store.ts
@@ -382,8 +382,32 @@ export const useTabsStore = create()(
return paneId;
}
- // Look for an existing unpinned (preview) file-viewer pane in the active tab
const tabPaneIds = extractPaneIdsFromLayout(activeTab.layout);
+
+ // First, check if the file is already open in a pinned pane - if so, just focus it
+ const existingPinnedPane = tabPaneIds
+ .map((id) => state.panes[id])
+ .find(
+ (p) =>
+ p?.type === "file-viewer" &&
+ p.fileViewer?.isPinned &&
+ p.fileViewer.filePath === options.filePath &&
+ p.fileViewer.diffCategory === options.diffCategory &&
+ p.fileViewer.commitHash === options.commitHash,
+ );
+
+ if (existingPinnedPane) {
+ // File is already open in a pinned pane, just focus it
+ set({
+ focusedPaneIds: {
+ ...state.focusedPaneIds,
+ [activeTab.id]: existingPinnedPane.id,
+ },
+ });
+ return existingPinnedPane.id;
+ }
+
+ // Look for an existing unpinned (preview) file-viewer pane in the active tab
const fileViewerPanes = tabPaneIds
.map((id) => state.panes[id])
.filter(