MCPcopy Create free account
hub / github.com/bytebase/bytebase / closeTab

Function closeTab

frontend/src/react/stores/sqlEditor/tab.ts:236–265  ·  view source on GitHub ↗
(tabId)

Source from the content-addressed store, hash-verified

234 },
235
236 closeTab(tabId) {
237 const position = get().openTmpTabList.findIndex(
238 (item) => item.id === tabId
239 );
240 if (position < 0) return;
241
242 const wasCurrent = tabId === get().currentTabId;
243
244 set((s) => {
245 s.openTmpTabList.splice(position, 1);
246 s.tabsById.delete(tabId);
247 if (wasCurrent) {
248 const nextIndex = Math.min(position, s.openTmpTabList.length - 1);
249 s.currentTabId = s.openTmpTabList[nextIndex]?.id ?? "";
250 }
251 });
252
253 persistOpenTabs(get().openTmpTabList);
254 if (wasCurrent) {
255 persistCurrentTabId(get().currentTabId);
256 }
257
258 // Dynamic import avoids a static cycle with the web terminal
259 // service module (which transitively re-imports this module).
260 void import("@/react/stores/sqlEditor/webTerminal-service").then(
261 ({ disposeWebTerminalQuerySession }) => {
262 disposeWebTerminalQuerySession(tabId);
263 }
264 );
265 },
266
267 updateTab(id, payload) {
268 if (!get().tabsById.has(id)) return undefined;

Callers

nothing calls this directly

Calls 7

getFunction · 0.85
setFunction · 0.85
persistOpenTabsFunction · 0.85
persistCurrentTabIdFunction · 0.85
findIndexMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected