Skip to content

Commit 385dedf

Browse files
big-guyclaude
andcommitted
refactor(shell): simplify selectTab background-clear + autoclose lookup
- panes-fsm selectTab: replace the destructure + `void _bg` + `as TerminalTab` cast ceremony with a plain `{ ...tab, background: undefined }` patch. - shell-autoclose-monitor locate(): collapse findLeafByTabId + redundant leaf.tabs.find re-search into one optional-chained lookup. No behavior change. Typecheck, build, and 71 reducer/FSM tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 359f611 commit 385dedf

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/main/panes-fsm.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,11 @@ export class PanesFSM {
494494
// `background` flag so its title stops rendering italic.
495495
const i = leaf.tabs.findIndex((t) => t.id === tabId)
496496
if (i !== -1 && leaf.tabs[i].background) {
497-
const { background: _bg, ...rest } = leaf.tabs[i]
498-
void _bg
497+
const promoted: TerminalTab = { ...leaf.tabs[i], background: undefined }
499498
return {
500499
...leaf,
501500
activeTabId: tabId,
502-
tabs: [...leaf.tabs.slice(0, i), rest as TerminalTab, ...leaf.tabs.slice(i + 1)]
501+
tabs: [...leaf.tabs.slice(0, i), promoted, ...leaf.tabs.slice(i + 1)]
503502
}
504503
}
505504
return { ...leaf, activeTabId: tabId }

src/main/shell-autoclose-monitor.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ export class ShellAutoCloseMonitor {
7373
const panes = this.store.getSnapshot().state.terminals.panes
7474
for (const [wtPath, tree] of Object.entries(panes)) {
7575
const leaf = findLeafByTabId(tree, id)
76-
if (!leaf) continue
77-
const tab = leaf.tabs.find((t) => t.id === id)
78-
if (!tab) continue
79-
return { wtPath, tab, activeTabId: leaf.activeTabId }
76+
const tab = leaf?.tabs.find((t) => t.id === id)
77+
if (leaf && tab) return { wtPath, tab, activeTabId: leaf.activeTabId }
8078
}
8179
return null
8280
}

0 commit comments

Comments
 (0)