(blockId: string)
| 145 | } |
| 146 | |
| 147 | function 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 | |
| 182 | function genericClose() { |
| 183 | const focusType = FocusManager.getInstance().getFocusType(); |
no test coverage detected