From 7ae8a70c8d04fe2672212974850014aeeb082d2a Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sat, 12 Sep 2026 18:07:03 -0700 Subject: [PATCH] perf: avoid flattening tabs for smart-sort liveness check (#20279) Co-authored-by: Orca Worker --- src/renderer/src/components/sidebar/smart-sort.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/sidebar/smart-sort.ts b/src/renderer/src/components/sidebar/smart-sort.ts index ffebad8cf75..012012eb53b 100644 --- a/src/renderer/src/components/sidebar/smart-sort.ts +++ b/src/renderer/src/components/sidebar/smart-sort.ts @@ -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)