Skip to content

Show Positron's Viewer stop button for Quarto previews - #1193

Merged
juliasilge merged 4 commits into
mainfrom
feature/preview-panel-stop
Oct 19, 2026
Merged

juliasilge merged 4 commits into
mainfrom
feature/preview-panel-stop

Conversation

@juliasilge

Copy link
Copy Markdown
Collaborator

In Positron, the Viewer now shows a stop button for Quarto previews. Before this PR, the only way to stop quarto preview was to find the Quarto Preview terminal and press Ctrl+C or close the terminal.

Screenshot 2026-10-12 at 6 21 49 PM

The Positron PR adds PreviewPanel.stoppable and onDidRequestStop to the Positron API. The extension sets stoppable while 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/positron ships them, so engines.positron does not change.

Some known limitations:

  • Without shell integration (for example, the Windows cmd path), 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.
  • A re-render restarts the server. If the user clicks stop during this short time, the new server can still start and open the preview again. A second click stops it.

Verification

  • yarn build-test: passes, including tsc --noEmit.
  • yarn test (label main): 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 local out/markdownit. This PR does not change that code.
  • ESLint on the changed files: no new warnings.
  • Manual test in Positron, built from the branch of the Positron PR:
    • Preview a document. The stop button shows on the right side of the Viewer toolbar.
    • Save the document. The button stays, and the toolbar does not move.
    • Click stop. The server stops, the terminal closes, and the preview closes.
    • Press Ctrl+C in the Quarto Preview terminal. The button goes away, and the preview stays.
    • Close the Quarto Preview terminal. The button goes away.

@posit-snyk-bot

posit-snyk-bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@juliasilge
juliasilge requested a review from seeM October 15, 2026 00:57

@seeM seeM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@juliasilge
juliasilge merged commit ea5c677 into main Oct 19, 2026
7 checks passed
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.

3 participants