()
| 232 | } |
| 233 | |
| 234 | async function cleanup() { |
| 235 | // Careful to avoid race conditions, since this |
| 236 | // function can be called from multiple places. |
| 237 | if (isCleanedUp) { |
| 238 | return |
| 239 | } |
| 240 | isCleanedUp = true |
| 241 | |
| 242 | // Don't fail if this fails |
| 243 | try { |
| 244 | await closeTabInIDE(tabName, ideClient) |
| 245 | } catch (e) { |
| 246 | logError(e as Error) |
| 247 | } |
| 248 | |
| 249 | process.off('beforeExit', cleanup) |
| 250 | toolUseContext.abortController.signal.removeEventListener('abort', cleanup) |
| 251 | } |
| 252 | |
| 253 | // Cleanup if the user hits esc to cancel the tool call - or on exit |
| 254 | toolUseContext.abortController.signal.addEventListener('abort', cleanup) |
no test coverage detected