perf: add tabIds(inPane:) so callers stop building tabs to read ids
Summary
Adds tabIds(inPane:) for callers that want identity or ordering and nothing else.
tabs(inPane:) builds a Tab per tab, and Tab.init(from:) copies all fourteen TabItem properties. A caller asking for tabs so it can read their ids pays for thirteen fields it discards, per tab, on every call. One of those copied fields is the tab title, so a caller reading ids inside a SwiftUI view body ends up observing titles it never looks at, and re-renders whenever one changes.
public func tabIds(inPane paneId: PaneID) -> [TabID] {
guard let pane = internalController.paneState(for: paneId) else {
return []
}
return pane.tabs.map { TabID(id: $0.id) }
}
Tests
TabIdListingTests pins the new call to the ordering tabs(inPane:) already produces, across moves and closes, so the cheap call and the expensive one cannot disagree. An empty or unknown pane returns [], matching tabs(inPane:).
Why now
cmux's Workspace.sidebarOrderedPanelIds() is the caller that motivated it. It asks for tabs purely to collect ids, from inside sidebar view bodies, so an animating tab title invalidates the sidebar for an ordering that never looks at a title. The cmux-side change depends on this method, so this lands first.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Adds tabIds(inPane:) so callers can read tab ordering or identity without building full Tab objects. The old tabs(inPane:) path copied all fourteen TabItem fields per tab, including titles, which caused SwiftUI views that only needed IDs to re-render on title changes they never read.
New Features
tabIds(inPane:)returns tab IDs in tab order and reads nothing else.- Empty or unknown panes return
[], matchingtabs(inPane:). - New tests pin the ID ordering to
tabs(inPane:)across moves, closes, and renames so the cheap call and the expensive one cannot disagree.
Summary by CodeRabbit
-
New Features
- Added a public query to retrieve tab identifiers in their pane order.
- Unknown or empty panes return an empty list.
-
Tests
- Added coverage for tab ordering and consistency after creating, moving, closing, and renaming tabs.