Uh oh!
There was an error while loading. Please reload this page.
feat(tui): ephemeral memory storage for plugins - #39916
Closed
kitlangton wants to merge 1 commit into
Closed
Conversation
kitlangton
commented
Jul 31, 2026
ContributorAuthor
Superseded: #39776 was merged with these changes included (the branch stacked on this one), so |
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 freeto 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.
What
Adds a second storage tier to the TUI plugin API:
context.storage.memory(key, { initial }). The existingstorage.storeis durable JSON persisted to disk;memoryis an ephemeral in-process reactive store — synchronous updates, values need not be JSON-serializable, gone when the TUI exits.The motivating consumer is plugin hot reload (split out of #39776): entries are memoized in the provider, above any single consumer's lifecycle, so a reloaded plugin generation re-acquires the same live store under the same key and its runtime state (timers' targets, positions, counters) survives the swap. This PR is useful standalone as cheap scratch state without a disk write per mutation.
How
packages/tui/src/context/storage.tsx:memorymap alongside the durableentries; each entry is acreateStore+produce-based synchronous updater, memoized per key.packages/plugin/src/tui/context.ts:Storage.memoryon the plugin-facing interface, plus doc comments contrasting the two tiers.packages/tui/src/plugin/context.tsx: plugin contexts expose it namespaced asplugin.<id>.<key>, same convention asstore.Scope
No persistence, no cross-instance sync, no eviction — by design. Hot-reload survival semantics are exercised end-to-end in #39776, which stacks on this.
Testing
bun typecheckinpackages/tuiandpackages/pluginbun test test/context/storage.test.tsx— new test covering synchronous updates, non-JSON values (aDatesurvives by identity), same-key store identity, and key isolation.