From 02c66970f53f0267016470b3e0b09e8e941f22cc Mon Sep 17 00:00:00 2001 From: Arjun <6592213+arkml@users.noreply.github.com> Date: Tue, 17 Feb 2026 11:39:17 +0530 Subject: [PATCH] default to new tab --- apps/x/apps/renderer/src/App.tsx | 42 +++++++++++-------- .../src/components/sidebar-content.tsx | 2 - 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index 7bb10c42..1e8ab581 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -2424,11 +2424,10 @@ function App() { handleNewChatTab() }, onSelectRun: (runIdToLoad) => { - // If run is already open in a tab, switch to that tab - const existingTab = openTabs.find(t => t.runId === runIdToLoad) - if (existingTab) { - switchToTab(existingTab.id) - // Also ensure we navigate to chat view + // If it's already the active tab's run, do nothing + const activeTab = openTabs.find(t => t.id === activeTabId) + if (activeTab?.runId === runIdToLoad) { + // Just ensure we're in chat view if (selectedPath || isGraphOpen || selectedBackgroundTask) { setSelectedPath(null) setIsGraphOpen(false) @@ -2437,9 +2436,26 @@ function App() { } return } - // Update current tab's runId - setOpenTabs(prev => prev.map(t => t.id === activeTabId ? { ...t, runId: runIdToLoad } : t)) - void navigateToView({ type: 'chat', runId: runIdToLoad }) + // If already open in another tab, switch to it + const existingTab = openTabs.find(t => t.runId === runIdToLoad) + if (existingTab) { + switchToTab(existingTab.id) + if (selectedPath || isGraphOpen || selectedBackgroundTask) { + setSelectedPath(null) + setIsGraphOpen(false) + setExpandedFrom(null) + setSelectedBackgroundTask(null) + } + return + } + // Open in a new tab + openInNewTab(runIdToLoad) + if (selectedPath || isGraphOpen || selectedBackgroundTask) { + setSelectedPath(null) + setIsGraphOpen(false) + setExpandedFrom(null) + setSelectedBackgroundTask(null) + } }, onDeleteRun: async (runIdToDelete) => { try { @@ -2462,16 +2478,6 @@ function App() { console.error('Failed to delete run:', err) } }, - onOpenInNewTab: (targetRunId) => { - openInNewTab(targetRunId) - // Ensure we're in chat view - if (selectedPath || isGraphOpen || selectedBackgroundTask) { - setSelectedPath(null) - setIsGraphOpen(false) - setExpandedFrom(null) - setSelectedBackgroundTask(null) - } - }, onSelectBackgroundTask: (taskName) => { void navigateToView({ type: 'task', name: taskName }) }, diff --git a/apps/x/apps/renderer/src/components/sidebar-content.tsx b/apps/x/apps/renderer/src/components/sidebar-content.tsx index 2b010fe0..255d46f0 100644 --- a/apps/x/apps/renderer/src/components/sidebar-content.tsx +++ b/apps/x/apps/renderer/src/components/sidebar-content.tsx @@ -8,7 +8,6 @@ import { ChevronsDownUp, ChevronsUpDown, Copy, - ExternalLink, FilePlus, FolderPlus, AlertTriangle, @@ -150,7 +149,6 @@ type TasksActions = { onNewChat: () => void onSelectRun: (runId: string) => void onDeleteRun: (runId: string) => void - onOpenInNewTab?: (runId: string) => void onSelectBackgroundTask?: (taskName: string) => void }