default to new tab

This commit is contained in:
Arjun 2026-02-17 11:39:17 +05:30 committed by tusharmagar
parent c3603f32f2
commit 02c66970f5
2 changed files with 24 additions and 20 deletions

View file

@ -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 })
},

View file

@ -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
}