fix: boot to landing page before shutting down active worktree terminals

Shutting down the active worktree from the context menu killed its PTYs
while TerminalPane was still visible, causing a flicker/"reboot" effect
and occasional crashes as PTY exit callbacks raced against the live
xterm instance. Reorder the context-menu handler to clear the active
worktree first, then tear down terminals.
This commit is contained in:
Neil 2026-04-16 22:53:51 -07:00
parent eec2f9137e
commit 68f5b0f650

View file

@ -98,10 +98,17 @@ const WorktreeContextMenu = React.memo(function WorktreeContextMenu({ worktree,
}, [worktree.id, worktree.displayName, worktree.linkedIssue, worktree.comment, openModal])
const handleCloseTerminals = useCallback(async () => {
await shutdownWorktreeTerminals(worktree.id)
// Why: shutting down the currently active worktree while its TerminalPane
// is still visible causes a visible "reboot" flicker and can crash the
// pane. clearTransientTerminalState nulls each tab's ptyId in place
// without bumping generation, so TerminalPane stays mounted while its
// PTYs are being killed; PTY exit callbacks then race against the live
// xterm instance. Boot the user to the landing page FIRST so the visible
// surface is detached before the async teardown runs.
if (activeWorktreeId === worktree.id) {
setActiveWorktree(null)
}
await shutdownWorktreeTerminals(worktree.id)
}, [worktree.id, shutdownWorktreeTerminals, activeWorktreeId, setActiveWorktree])
const handleDelete = useCallback(() => {