Skip to content

fix(app): preserve prompt drafts across session switches#31201

Open
ualtinok wants to merge 3 commits into
anomalyco:devfrom
ualtinok:fix/desktop-prompt-draft-persistence
Open

fix(app): preserve prompt drafts across session switches#31201
ualtinok wants to merge 3 commits into
anomalyco:devfrom
ualtinok:fix/desktop-prompt-draft-persistence

Conversation

@ualtinok

@ualtinok ualtinok commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #31200

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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, so prompt.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/session cache 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.ts from packages/app
  • bun typecheck from packages/app
  • pre-push bun turbo typecheck

Screenshots / recordings

N/A; state persistence bug.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@ualtinok ualtinok requested a review from adamdotdevin as a code owner June 7, 2026 06:03
@thdxr thdxr requested review from Brendonovich and Hona as code owners June 11, 2026 00:17
@ualtinok ualtinok force-pushed the fix/desktop-prompt-draft-persistence branch 3 times, most recently from 1c9b0e0 to e428cd9 Compare June 16, 2026 15:05
@ualtinok ualtinok force-pushed the fix/desktop-prompt-draft-persistence branch from 6be4650 to b281702 Compare June 24, 2026 21:21
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop loses unsent prompt drafts when switching sessions

1 participant