polish folder picker list and instance focus

This commit is contained in:
Shantur Rathore
2025-11-08 22:47:29 +00:00
parent 03ff2779b0
commit 0a77feac7a
2 changed files with 69 additions and 45 deletions

View File

@@ -64,15 +64,34 @@ function updateInstance(id: string, updates: Partial<Instance>) {
}
function removeInstance(id: string) {
let nextActiveId: string | null = null
setInstances((prev) => {
if (!prev.has(id)) {
return prev
}
const keys = Array.from(prev.keys())
const index = keys.indexOf(id)
const next = new Map(prev)
next.delete(id)
if (activeInstanceId() === id) {
if (index > 0) {
nextActiveId = keys[index - 1]
} else {
const remainingKeys = Array.from(next.keys())
nextActiveId = remainingKeys.length > 0 ? remainingKeys[0] : null
}
}
return next
})
removeLogContainer(id)
if (activeInstanceId() === id) {
setActiveInstanceId(null)
setActiveInstanceId(nextActiveId)
}
// Clean up session indexes and drafts for removed instance