perf: avoid flattening tabs for smart-sort liveness check (#20279)

Co-authored-by: Orca Worker <orca-worker@localhost>
This commit is contained in:
OrcaWin
2026-09-12 18:07:03 -07:00
committed by GitHub
co-authored by Orca Worker
parent 97ea501e4f
commit 7ae8a70c8d
@@ -188,9 +188,9 @@ export function sortWorktreesSmart(
// Why: `tabHasLivePty` (over `ptyIdsByTabId`) is the source of truth for
// liveness — slept terminals retain `tab.ptyId` as a wake hint, so reading
// it directly would falsely keep cold-start ordering off after restart.
const hasAnyLivePty = Object.values(tabsByWorktree)
.flat()
.some((tab) => tabHasLivePty(ptyIdsByTabId, tab.id))
const hasAnyLivePty = Object.values(tabsByWorktree).some((tabs) =>
tabs.some((tab) => tabHasLivePty(ptyIdsByTabId, tab.id))
)
const now = Date.now()
const labels = buildWorktreeSortLabels(worktrees)