Allow viewer apps to run in Console sessions#12545
Conversation
|
E2E Tests 🚀 |
cb587f7 to
92c5ba6
Compare
e751e43 to
e51c0f6
Compare
| private readonly _runApplicationSequencerByName = new SequencerByKey<string>(); | ||
| private readonly _runApplicationDisposableByName = new Map<string, vscode.Disposable>(); | ||
| private readonly _appServers = new Map<string, { terminalPid: number | undefined; proxyUri: vscode.Uri }>(); | ||
| private readonly _consoleSessionByName = new Map<string, { session: positron.LanguageRuntimeSession; listener: vscode.Disposable }>(); |
There was a problem hiding this comment.
This needs to be stored somewhere so that we maintain the mapping between consoles and running applications when the window reloads/extension host restarts.
There was a problem hiding this comment.
Done! I opted for a simple approach where we prune stale sessions from the persisting memento on each lookup. Should be fine since there should only be a handful of known sessions at any given time.
8151db1 to
7337a79
Compare
| } | ||
| } | ||
| if (pruned) { | ||
| await this._globalState.update(PositronRunAppApiImpl.CONSOLE_SESSIONS_KEY, persisted); |
There was a problem hiding this comment.
Here and elsewhere: the set of console sessions should be stored in workspace state rather than global state. If they're in global state then two Positron windows opened at once will continually delete each others' entries.
https://code.visualstudio.com/api/references/vscode-api#ExtensionContext.workspaceState
There was a problem hiding this comment.
Done! Thanks for walking me through all these pitfalls, first time I'm using persistent storage.
There's another failure mode though: if two different windows open the same workspace (e.g. via the duplicate command), we'd still get corruption.
It seems like the best setup for this sort of use cases would be to have storage space whose lifecycle exactly matches the console sessions (and is not persisted on disk). I've experimented with this in #12636.
There was a problem hiding this comment.
Did you observe the corruption? It is not possible AFAIK to have the same workspace open in two windows. When you use the duplicate workspace command, what you get is a second (untitled) workspace with its own distinct workspace storage.
However I've been meaning to add a way for extensions to access ephemeral storage for months, and as you note it is an even better match than workspace storage since ephemeral state goes away when you close Positron. Thanks for adding that!
There was a problem hiding this comment.
I didn't! Should have checked.
So that's what "duplicate" means in that command. Makes a ton of sense.
22fe806 to
ae751a8
Compare
Addresses #12556
Refactored positron-run-app extension to add a new
runApplicationInConsole()entry point. The internals are shared between the terminal and console paths (in particular I extractedAppUrlDetectorfor URL detection in app output), and now handle errors a bit more consistently.Sessions are reused and restarted when app is started again. To make the implementation easier,
positron.runtime.restartSession()now returns a boolean indicating whether the session restart was cancelled by the user. When cancelled, the app restart is cancelled too. When the session is already restarting, we wait for the restart to finish (new behaviour) and return true. These changes make the behaviour ofawait restartSession()clearer for callers:trueresult means the session is ready,falsemeans the restart was cancelled, error means the restart couldn't be completed.If there are breakpoints and app runner specified a debugger type, we wait for the configuration of that debugger to be done before starting the app. The
configurationDoneevent only fires after initialsetBreakpointsrequests ( one per file) are successful, and this is exactly what we need to ensure that Ark's DAP has fully started up and knows about breakpoints before sourcing the Shiny app files.The viewer's stop button gains support for console sessions. It sends console interrupts via the console service.
Once posit-dev/shiny-vscode#108 is merged and released, we can bump the bundled version and merge this PR.
Release Notes
New Features
Bug Fixes
QA Notes
Screen.Recording.2026-03-17.at.18.38.44.mov
@:apps