fix: boot to landing before shutting down active worktree (#749)

This commit is contained in:
Neil 2026-04-16 22:56:01 -07:00 committed by GitHub
parent fd4f986c59
commit 6e1cb1c6cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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(() => {