Skip to content

Terminate Quarto preview when terminal is closed externally#947

Merged
vezwork merged 2 commits intomainfrom
trashcan-icon-exit-quarto
Apr 14, 2026
Merged

Terminate Quarto preview when terminal is closed externally#947
vezwork merged 2 commits intomainfrom
trashcan-icon-exit-quarto

Conversation

@juliasilge
Copy link
Copy Markdown
Collaborator

Addresses posit-dev/positron#13006.

When a user closes the Quarto Preview terminal via the trash icon, the underlying Quarto process was not terminated cleanly. This left behind intermediate .quarto_ipynb files, and repeated previews would accumulate *.quarto_ipynb_1, *.quarto_ipynb_2, etc.

This was happening because VS Code's trash icon sends SIGHUP to the shell process only. Quarto, as a child process, typically survives as an orphan and never receives the signal needed to trigger cleanup. Ctrl+C works because it sends SIGINT to the entire foreground process group.

This PR registers an onDidCloseTerminal listener in PreviewManager. When the preview terminal is closed by any external means, it sends the same HTTP termination request that killPreview() already uses, giving Quarto the chance to clean up before it exits. To avoid a duplicate request when the extension itself kills the terminal, this.terminal_ is cleared before killTerminal() is called, so the event handler's identity check short-circuits.

@juliasilge juliasilge requested a review from vezwork April 14, 2026 15:00
@vezwork
Copy link
Copy Markdown
Collaborator

vezwork commented Apr 14, 2026

This change looks good to me. Thank you for the clear explanation of the problem and solution.

I didn't test this PR locally, as I understand it will be verified that the issue was resolved separately.

@vezwork vezwork merged commit e3d9958 into main Apr 14, 2026
4 checks passed
@juliasilge juliasilge deleted the trashcan-icon-exit-quarto branch April 14, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants