fix(app): preserve prompt drafts across session switches#31201
Open
ualtinok wants to merge 3 commits into
Open
fix(app): preserve prompt drafts across session switches#31201ualtinok wants to merge 3 commits into
ualtinok wants to merge 3 commits into
Conversation
1c9b0e0 to
e428cd9
Compare
6be4650 to
b281702
Compare
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Key prompt sessions by server scope, add an in-memory fallback prompt state for routes without a draft/dir scope, and expose readiness as a lazy promise-bearing accessor so drafts survive session switches instead of being reset. Adds unit coverage for the new scope/cache/readiness helpers. Ported from anomalyco#31201 (already current-structure; applied as-is). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Issue for this PR
Closes #31200
Type of change
What does this PR do?
Fixes Desktop prompt drafts being treated as ready before async storage has loaded.
PromptProvider.ready()currently returns the session readiness accessor instead of calling it, soprompt.ready()is always truthy. Desktop can then render the composer against the default empty prompt while the persisted session draft is still loading.This also scopes the in-memory prompt session cache with the same server scope used by persisted prompt storage. That keeps local, WSL, SSH, and remote server prompt drafts from sharing the same
dir/sessioncache entry.How did you verify your code works?
bun test src/context/prompt.test.ts src/utils/persist.test.ts src/context/terminal.test.ts src/context/server.test.ts src/context/server-sdk.test.tsfrompackages/appbun typecheckfrompackages/appbun turbo typecheckScreenshots / recordings
N/A; state persistence bug.
Checklist