Skip to content

Add ephemeral storage for extensions#12636

Open
lionel- wants to merge 8 commits intofeature/shiny-sessionfrom
feature/window-storage
Open

Add ephemeral storage for extensions#12636
lionel- wants to merge 8 commits intofeature/shiny-sessionfrom
feature/window-storage

Conversation

@lionel-
Copy link
Contributor

@lionel- lionel- commented Mar 20, 2026

Branched from #12545 (base branch still set to main so CI runs tests)

Experimental addition of a new kind of persistent storage context.ephemeralState that is:

  • Unique per workspace and process.
  • Stored in-memory only

This storage matches exactly the scope/lifetime of console sessions, and is thus an ideal place for extensions to store metadata about console sessions.

The positron-run-app extension now uses this storage to keep track of sessions (see #12545). This has these advantages:

  • Extension state written to workspace storage could be invalidated / corrupted when multiple windows with the same workspace are opened (e.g. via "Duplicate as workspace in new window" command). The ephemeral storage prevents this sort of races by design.

    Edit: As pointed out by Jonathan, this is not true. There is a file-lock mechanism for workspace storage and the duplicate as workspace command creates a new, separate workspace with its own storage.

  • Not taking up disk space for state that is only relevant in the context of a running instance and that could easily be leaked forever. For the app runner, we still prune console sessions when we look them up to avoid unbounded growth while the instance is running. If it didn't prune though, the ephemeral storage guarantees the state is cleaned up on shutdown, rather than leaked on disk.

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

@github-actions
Copy link

github-actions bot commented Mar 20, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@lionel- lionel- changed the base branch from feature/shiny-session to main March 20, 2026 14:38
@lionel- lionel- force-pushed the feature/window-storage branch from fbfc2fc to 7b17b52 Compare March 20, 2026 14:38
@lionel- lionel- changed the title Add window-scoped persistent storage for extensions Add ephemeral storage for extensions Mar 20, 2026
@lionel- lionel- force-pushed the feature/window-storage branch from 57afcc0 to 1ad24e8 Compare March 20, 2026 15:15
To avoid exposing RPCs to extensions
@lionel- lionel- marked this pull request as ready for review March 20, 2026 15:53
jmcphers
jmcphers previously approved these changes Mar 20, 2026
Copy link
Collaborator

@jmcphers jmcphers left a comment

Choose a reason for hiding this comment

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

Thank you for doing this, I've been meaning to do so for months!

Two small requests:

  • Update the comment re: workspace corruption; it is my understanding that workspace state is appropriate for per-window operations because you can't open the same workspace in two windows at once.
  • Putting an API in vscode.d.ts makes it difficult/impossible for third party extensions to use, because, unlike positron.d.ts, we do not publish our modified copy of these types anywhere. What do you think about moving this to positron.d.ts? Realize then it can't be part of ExtensionContext, but we get the extension ID as part of every API call so it could just live on e.g. namespace window.

@lionel- lionel- changed the base branch from main to feature/shiny-session March 21, 2026 09:19
@lionel- lionel- requested a review from jmcphers March 21, 2026 09:20
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