[BUG] VS Code extension: unsent prompt draft is discarded when switching sessions and back
Preflight Checklist
- [x] I have searched existing issues and this is not covered by an open issue
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In the Claude Code VS Code extension, text typed into the prompt input but not yet submitted is lost when you switch to another session and then switch back. The input box returns empty — there is no autosave or per-session draft persistence.
This was previously reported for the same surface in #55134 ("Current prompt & file visibility do not persist session switches"), which was auto-closed as stale (not fixed) and is now locked, so it can no longer be reopened or reacted to. Filing fresh per that issue's own auto-close message ("please file a new issue and reference this one"). The web surface has the same defect in #77010 (its steps "B").
What Should Happen?
Unsent draft text should be preserved per-session (locally at minimum) so it survives switching to another session and back. Checking on — or approving an action in — another session is a routine multi-session workflow and should not destroy an in-progress prompt.
Error Messages/Logs
None.
Steps to Reproduce
- In the VS Code extension, type a prompt into the input box. Do not press Enter.
- Switch to another session (via Session History / the session switcher).
- Switch back to the original session.
- The prompt is gone — the input box is empty.
Reproducible every time.
Claude Model
N/A — this is a UI bug, independent of the model.
Is this a regression?
I don't know — the same behavior was reported against 2.1.119 in #55134 and is still present in 2.1.234.
Last Working Version
_No response_
Claude Code Version
2.1.234 (VS Code extension)
Platform
Anthropic API
Operating System
Windows 11
Terminal/Shell
VS Code integrated terminal
Additional Information
Related:
- #55134 — same bug on the VS Code extension, closed as stale and locked.
- #77010 — same draft-loss defect on Claude Code for web.
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Confirming this is still present in 2.1.250, and it affects Cursor as well as VS Code (same extension). Codex's input preserves unsent drafts across session switches, so this is also a parity gap.
The root cause is that the prompt input is a contenteditable whose text lives in per-session component state that resets when you switch the active session. There's no local draft persistence, and the only save path is a live keystroke, so switching away drops whatever wasn't submitted (the "close tab / reload" case in the report has the same cause).
A small userland fix works reliably: on input, save the text to
localStoragekeyed by the session id; on session switch, restore it when the box is empty; clear it on send. I've run exactly this as a local patch on 2.1.247-2.1.250 across both editors and it survives multi-session switching without losing drafts, which suggests the in-product fix is small and localized. Per-session local persistence (as the report requests) would also cover reloads and restarts.Happy to share more detail if useful.
I can confirm the bug exists in version 2.1.259 even though the circumstances were a bit different.
I had Claude look into it and this is the generated report:
Same defect, different trigger, and a worse outcome. Reporting it here rather
than as a new issue since the root cause looks identical: the input box draft is
held in memory only.
Trigger: authentication failed while a long prompt was being composed and had
not been submitted. After re-authenticating, the input box was empty. No session
switch was involved.
Impact: more than an hour of writing lost. It was a detailed set of review
comments on a customer document, so it could not be reconstructed from memory.
Environment
| | |
|---|---|
| Extension |
anthropic.claude-code2.1.259 || VS Code | 1.131.0, commit e4c7e7b1d6d060162f4aa7f8225271b67ce1df75, x64 |
| OS | Windows 11 Enterprise, build 10.0.26200 |
| Session | Long-running. Transcript was 4,730 JSONL lines / 17 MB at the time |
Timing. The workspace
state.vscdbwas written at 13:39:01. Credentials wererewritten a minute later as authentication was re-established:
So the panel state save did run — it simply did not include the input text.
Not recoverable from anywhere on disk. Checked afterwards:
| Location | Result |
|---|---|
|
~/.claude/history.jsonl| Stale, months old ||
~/.claude/projects/<project>/<session>.jsonl| Submitted messages only; the draft was never submitted || Workspace
state.vscdb, keychat.untitledInputState| Empty, and it belongs to VS Code's built-in chat, not to this extension || Global
state.vscdb, keyAnthropic.claude-code| Settings and experiment flags only ||
%APPDATA%\Code\User\globalStorage| No Anthropic or Claude directory exists at all ||
%APPDATA%\Code\Backups| Empty ||
%APPDATA%\Code\logs| Nothing written during the incident |Two things worth adding to the case for fixing this
The risk scales with session length. A long session is where prompts get longest
and most detailed, and it is also where a token refresh is most likely to fall
due. The two peak together.
The suggested workaround — compose in a file and paste — is a workaround for a
defect, not a workflow. The input box is where the product invites you to type,
file references and completion work there, and long structured prompts are what
the product is good at.
On the fix. VS Code's own chat persists its draft under
chat.untitledInputStatein workspace state, so the pattern already exists inthe host. Debounced persistence plus restore on panel load would cover this
trigger and the session-switch one in the same change. Not tearing down the
input on an auth failure would be better still: re-authentication is not a reason
to discard user text.
Still reproducing on Claude Code 2.1.220 (VS Code extension, macOS 15.6 / Darwin 25.6.0).
Repro is exactly as described: type into the prompt input without submitting, switch to another session, switch back — the input is empty.
Adding a note on impact, since this is easy to read as a minor annoyance: the sessions worth switching away from are usually the ones where another session needs an approval or a quick check, so the draft that gets destroyed tends to be a long, carefully-written one composed mid-task. There's no undo in the input box and no indication the text was ever there, so the work is simply gone. A per-session local draft would be enough — it doesn't need to sync anywhere.