cmux/Sources/Panels
Eray Bozoglu 2712cabac9
Fix orphaned child processes when closing workspace tabs (#889)
* Fix orphaned child processes when closing workspace tabs

When closing a workspace tab via the sidebar X button, child processes
(login → zsh → claude) survived as orphans because TabManager.closeWorkspace()
only removed the workspace from the tabs array without explicitly freeing
Ghostty surfaces. It relied on ARC to cascade deallocation, but SwiftUI views
and Combine publishers held references, delaying or preventing
ghostty_surface_free() (which sends SIGHUP) from ever running.

This adds explicit teardown on the workspace close path:
- TerminalSurface.teardownSurface(): idempotent method to free the Ghostty
  runtime surface eagerly, matching the existing deinit logic
- TerminalPanel.close() now calls teardownSurface() to ensure SIGHUP is sent
- Workspace.teardownAllPanels() iterates all panels and closes them
- TabManager.closeWorkspace() calls teardownAllPanels() before removing
  the workspace from the tabs array

* Harden workspace teardown and ownership checks

* Address follow-up teardown review feedback

---------

Co-authored-by: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com>
2026-03-04 20:00:35 -08:00
..
BrowserPanel.swift Fix terminal link opens to stay in source workspace (#912) 2026-03-04 19:21:45 -08:00
BrowserPanelView.swift Fix browser panel lifecycle after WebContent process termination (#892) 2026-03-04 16:23:22 -08:00
CmuxWebView.swift feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
MarkdownPanel.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
MarkdownPanelView.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
Panel.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
PanelContentView.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
TerminalPanel.swift Fix orphaned child processes when closing workspace tabs (#889) 2026-03-04 20:00:35 -08:00
TerminalPanelView.swift Fix terminal Cmd+F overlay layering and add regression guardrails 2026-02-22 15:25:30 -08:00