* Ensure every `inDefaultLayout: true` tab from the registry is present in * `state`. Missing tabs are appended to the first tabset (the natural * upper-left landing spot) without changing the active tab. Already-present * tabs are left where the user moved them.
(state: RightSidebarLayoutState)
| 108 | * tabs are left where the user moved them. |
| 109 | */ |
| 110 | function ensureDefaultLayoutTabs(state: RightSidebarLayoutState): RightSidebarLayoutState { |
| 111 | const required = getDefaultLayoutTabIds(); |
| 112 | if (required.length === 0) return state; |
| 113 | |
| 114 | const present = new Set<TabType>(collectAllTabs(state.root)); |
| 115 | const missing: TabType[] = required.filter((tab) => !present.has(tab)); |
| 116 | if (missing.length === 0) return state; |
| 117 | |
| 118 | const firstTabsetId = findFirstTabsetId(state.root); |
| 119 | if (!firstTabsetId) return state; |
| 120 | |
| 121 | const root = appendTabsToTabset(state.root, firstTabsetId, missing); |
| 122 | return root === state.root ? state : { ...state, root }; |
| 123 | } |
| 124 | |
| 125 | /** Append tabs to the named tabset, returning a new tree (or the original if unchanged). */ |
| 126 | function appendTabsToTabset( |
no test coverage detected