Repository navigation
Show Positron's Viewer stop button for Quarto previews - #1193
Merged
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
seeM
approved these changes
Oct 19, 2026
seeM
left a comment
Collaborator
There was a problem hiding this comment.
Works well! I left a review with some feedback in the Positron PR.
juliasilge
added a commit
to posit-dev/positron
that referenced
this pull request
Oct 19, 2026
…stoppable`) (#16602) - Addresses #10753 - Related to quarto-dev/quarto#1193 ### Summary Extensions that show content with `positron.window.createPreviewPanel` can now show a stop button in the Viewer, with the first example being the Quarto extension. <img width="1476" height="946" alt="Screenshot 2026-10-12 at 6 21 49 PM" src="https://github.com/user-attachments/assets/83dd4d91-c355-442b-ae7a-e6f73bf760a0" /> Before this PR, the Viewer had no stop button for a Quarto preview. This PR adds two members to `PreviewPanel`: - `stoppable`: the extension sets this to `true` while its process runs, and to `false` when the process stops. While it is `true`, the Viewer shows a toolbar with a stop button and a clear button. - `onDidRequestStop`: fires when the user clicks the stop button. The Viewer hides the button before it fires the event. The extension stops its process, and also decides if the preview closes. The Viewer does not try to find out if the process runs and instead, the extension owns that state. Panels from `previewUrl` keep their current stop button, which uses a `PreviewSource`. ### The approaches I tried before I had tried some other approaches for this, and WOW, they did not work out well. In one version, I gave `createPreviewPanel` panels a `PreviewSource`, the same as `previewUrl` panels. Positron found the terminal from the PID and watched it, showing the button while a process ran in the terminal, sending <kbd>Ctrl+C</kbd> on a click, and closing the preview when the process stopped. It did NOT work well and was QUITE a lot of code; having the extension in charge here turned out a lot better. ### Release Notes #### New Features - Extensions that use `positron.window.createPreviewPanel` can show a stop button in the Viewer with `PreviewPanel.stoppable` and `onDidRequestStop` (#10753) #### Bug Fixes - N/A ### Validation Steps @:viewer @:apps @:quarto Together with the Quarto PR at quarto-dev/quarto#1193: 1. Install the Quarto extension from the branch of the Quarto PR. 2. Open a `.qmd` file and run _Quarto: Preview_. 3. Make sure that the Viewer shows a stop button on the right side of its toolbar. 4. Save the document. Make sure that the button stays and that the toolbar does not move. 5. Click the stop button. Make sure that the preview server stops and that the preview closes. 6. Run _Quarto: Preview_ again. Press <kbd>Ctrl+C</kbd> in the Quarto Preview terminal. 7. Make sure that the stop button goes away and that the preview stays open. 8. Start a Shiny or Streamlit app with the App Launcher. Make sure that the URL bar and its stop button work as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PreviewPanel.stoppable) posit-dev/positron#16602In Positron, the Viewer now shows a stop button for Quarto previews. Before this PR, the only way to stop
quarto previewwas to find the Quarto Preview terminal and press Ctrl+C or close the terminal.The Positron PR adds
PreviewPanel.stoppableandonDidRequestStopto the Positron API. The extension setsstoppablewhile the preview server runs, and Positron shows the button and reports clicks. Quarto starts and stops the server, so Quarto decides when the button shows.The extension uses feature detection (
"onDidRequestStop" in panel), not a version check. On older Positron versions and in VS Code, nothing changes. A local type covers the new members until@posit-dev/positronships them, soengines.positrondoes not change.Some known limitations:
cmdpath), Ctrl+C in the terminal leaves the button visible until the terminal closes. A click on this button does no harm, and it closes the preview.Verification
yarn build-test: passes, includingtsc --noEmit.yarn test(labelmain): the 6 new tests pass. 178 passing, 3 pending, 1 failing. The failure is the notebook renderer build test, which fails on stale chunks in my localout/markdownit. This PR does not change that code.