From dd120967c318deac863517b08ccf27150ed9c279 Mon Sep 17 00:00:00 2001 From: Ipriyankrajai Date: Thu, 2 Apr 2026 02:09:53 +0530 Subject: [PATCH] fix(desktop): always find existing file viewer pane regardless of open mode Decouples the reuse-existing-pane lookup from the openInNewTab flag so that an already-open file is always located first. The pane is still only reused in-place when openInNewTab is false, preventing duplicate panes when the user's file-open mode is set to "new-tab". --- apps/desktop/src/renderer/stores/tabs/store.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/renderer/stores/tabs/store.ts b/apps/desktop/src/renderer/stores/tabs/store.ts index 8fc0f13a086..82c893bf794 100644 --- a/apps/desktop/src/renderer/stores/tabs/store.ts +++ b/apps/desktop/src/renderer/stores/tabs/store.ts @@ -756,9 +756,7 @@ export const useTabsStore = create()( const tabPaneIds = extractPaneIdsFromLayout(activeTab.layout); const reuseExisting = options.reuseExisting ?? "workspace"; - const canReuseExistingPane = - !options.openInNewTab && reuseExisting !== "none"; - const existingFileViewerPane = canReuseExistingPane + const existingFileViewerPane = reuseExisting !== "none" ? findReusableFileViewerPane({ workspaceId, activeTabId: activeTab.id, @@ -828,7 +826,7 @@ export const useTabsStore = create()( // If we found an unpinned (preview) file-viewer pane, reuse it // (skip reuse when explicitly requesting a new tab, e.g. cmd+click) - if (fileViewerPanes.length > 0 && canReuseExistingPane) { + if (fileViewerPanes.length > 0 && !options.openInNewTab && reuseExisting !== "none") { const paneToReuse = fileViewerPanes[0]; const existingFileViewer = paneToReuse.fileViewer; if (!existingFileViewer) {