MCPcopy
hub / github.com/wavetermdev/waveterm / uxCloseBlock

Function uxCloseBlock

frontend/app/store/keymodel.ts:147–180  ·  view source on GitHub ↗
(blockId: string)

Source from the content-addressed store, hash-verified

145}
146
147function uxCloseBlock(blockId: string) {
148 const workspaceLayoutModel = WorkspaceLayoutModel.getInstance();
149 const isAIPanelOpen = workspaceLayoutModel.getAIPanelVisible();
150 if (isAIPanelOpen && getStaticTabBlockCount() === 1) {
151 const aiModel = WaveAIModel.getInstance();
152 const shouldSwitchToAI = !globalStore.get(aiModel.isChatEmptyAtom) || aiModel.hasNonEmptyInput();
153 if (shouldSwitchToAI) {
154 replaceBlock(blockId, { meta: { view: "launcher" } }, false);
155 setTimeout(() => WaveAIModel.getInstance().focusInput(), 50);
156 return;
157 }
158 }
159
160 const blockAtom = WOS.getWaveObjectAtom<Block>(WOS.makeORef("block", blockId));
161 const blockData = globalStore.get(blockAtom);
162 const isAIFileDiff = blockData?.meta?.view === "aifilediff";
163
164 // If this is the last block, closing it will close the tab — route through simpleCloseStaticTab
165 // so the tab:confirmclose setting is respected.
166 if (getStaticTabBlockCount() === 1) {
167 simpleCloseStaticTab();
168 return;
169 }
170
171 const layoutModel = getLayoutModelForStaticTab();
172 const node = layoutModel.getNodeByBlockId(blockId);
173 if (node) {
174 fireAndForget(() => layoutModel.closeNode(node.id));
175
176 if (isAIFileDiff && isAIPanelOpen) {
177 setTimeout(() => WaveAIModel.getInstance().focusInput(), 50);
178 }
179 }
180}
181
182function genericClose() {
183 const focusType = FocusManager.getInstance().getFocusType();

Callers 2

handleHeaderContextMenuFunction · 0.90

Calls 12

replaceBlockFunction · 0.90
fireAndForgetFunction · 0.90
getStaticTabBlockCountFunction · 0.85
simpleCloseStaticTabFunction · 0.85
getAIPanelVisibleMethod · 0.80
getMethod · 0.80
hasNonEmptyInputMethod · 0.80
focusInputMethod · 0.80
getNodeByBlockIdMethod · 0.80
closeNodeMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected