* Kills/closes a specific pane using the it2 CLI. * Also removes the pane from tracked session IDs so subsequent spawns * don't try to split from a dead session.
(
paneId: PaneId,
_useExternalSession?: boolean,
)
| 318 | * don't try to split from a dead session. |
| 319 | */ |
| 320 | async killPane( |
| 321 | paneId: PaneId, |
| 322 | _useExternalSession?: boolean, |
| 323 | ): Promise<boolean> { |
| 324 | // -f (force) is required: without it, iTerm2 respects the "Confirm before |
| 325 | // closing" preference and either shows a dialog or refuses when the session |
| 326 | // still has a running process (the shell always is). tmux kill-pane has no |
| 327 | // such prompt, which is why this was only broken for iTerm2. |
| 328 | const result = await runIt2(['session', 'close', '-f', '-s', paneId]) |
| 329 | // Clean up module state regardless of close result — even if the pane is |
| 330 | // already gone (e.g., user closed it manually), removing the stale ID is correct. |
| 331 | const idx = teammateSessionIds.indexOf(paneId) |
| 332 | if (idx !== -1) { |
| 333 | teammateSessionIds.splice(idx, 1) |
| 334 | } |
| 335 | if (teammateSessionIds.length === 0) { |
| 336 | firstPaneUsed = false |
| 337 | } |
| 338 | return result.code === 0 |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Stub for hiding a pane - not supported in iTerm2 backend. |