MCPcopy
hub / github.com/coder/mux / ensureDefaultLayoutTabs

Function ensureDefaultLayoutTabs

src/browser/utils/rightSidebarLayout.ts:110–123  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

108 * tabs are left where the user moved them.
109 */
110function 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). */
126function appendTabsToTabset(

Callers 1

Calls 5

getDefaultLayoutTabIdsFunction · 0.90
collectAllTabsFunction · 0.85
findFirstTabsetIdFunction · 0.85
appendTabsToTabsetFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected