[FEATURE] VS Code extension: keep unsent prompt drafts on disk and restore them after tab close, VS Code restart or extension host restart
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When I type a prompt in a Claude Code tab of the VS Code extension and do not send it yet, the text is lost as soon as one of these happens:
- the Claude Code tab gets closed
- VS Code is closed or crashes
- extension host restarts (Reload Window, an extension update, Restart Extension Host)
- I switch to another chat and come back, or hit the new chat shortcut (Cmd/Ctrl+N) by accident
The tabs come back after a restart. The draft does not, and nothing warns me before it is thrown away.
This wastes a lot of time and it hits long prompts the hardest, which are usually the ones that matter most. A long prompt is where I collect file paths, paste error output, spell out the constraints and the things Claude must not touch, then reread it and fix the wording. That can take a good while. Losing it to a reload means writing it again from memory, and the second version is often worse because half of the details are gone by then. So it is not only the minutes; the stamina and focus that went into it go in vain too, and it happens very easily. After it happened to me a few times I started writing longer prompts in a separate editor tab and pasting them in, which kind of defeats the point of the input box.
This was reported several times before. Every one of those issues was closed by stale bot, either for inactivity or as a duplicate of #34596 (which itself was closed for inactivity), and then locked, so nobody can add to them anymore. None of them got fixed; the behaviour is the same on my machine with 2.1.300. So I am filing it again, this time with a concrete proposal.
Proposed Solution
Treat the input box as a draft that belongs to its session:
- Save the draft per session while typing (debounced, e.g. 500 ms after the last keystroke) and also when the webview is hidden or disposed. Text, cursor position, attachments and a timestamp are enough
- Keep it on disk, e.g. ~/.claude/drafts/{session-id}.json. VS Code globalState would work as well (as #69199 suggested), but a file under ~/.claude survives a reinstall of the extension and could be shared with the CLI later
- Restore the draft when the tab comes back: after reopening it, VS Code restart, crash or extension host restart, and when switching back to that chat
- Delete it when the prompt is sent
- If a tab was closed for good, keep its draft for a few days and show a small "Restore unsent draft from 14:32 (2,340 characters)" offer when a new tab opens in the same folder. A Claude Code: Recover unsent drafts command that lists recent drafts would cover the rest
- Ask before discarding a non-empty draft on Cmd/Ctrl+N or when switching sessions from history (#43536)
Alternative Solutions
- I tried to build this myself as a Claude Code mod (the function hooks plugin API). It cannot work for the panel. The panel draws its own composer, so the engine never sees the text before Enter. Per the API types in 2.1.300, $.prompt.read() answers an empty box there, $.prompt.fill() is refused with no_composer for "a surface that draws its own composer", and the prompt.change origin app (a remote surface's own composer) is marked reserved, raised by nothing as shipped. If the extension forwarded its composer changes to the engine (raise prompt.change with origin app, let $.prompt.fill write into the panel) users could build this and similar things themselves. Would be a good second step even if drafts get fixed natively
- A mod could cover claude running in a terminal, where prompt.edit and prompt.change do fire. But most of my work is in the panel, so that does not help much
- Workaround for now: write long prompts in a separate editor tab and paste them. Works, but it is clumsy and easy to forget exactly when it matters
Priority
High - Significant impact on productivity
Feature Category
Other
Use Case Example
Use Case Example
- I open a Claude Code tab in a large repo and start a long prompt: bug description, two stack traces, the files involved, what I already tried and what must stay unchanged
- Before I send it, VS Code asks to reload for an extension update (or it crashes, or I press Ctrl+N by accident)
- Today: the tab comes back empty and the prompt is gone for good
- Expected: the tab comes back with the draft as is and the cursor where I left it. And if I had closed the tab itself, a new tab in the same folder offers to restore it
Additional Context
- Claude Code 2.1.300, VS Code extension, Windows 11
- Earlier reports of the same problem: #34596, #61515, #69081, #69199, #74846
- Related: #43536 (switching sessions via history drops the input without warning), #55578 (draft text persisting between chats), #60834 (draft lost after pressing Arrow Up, which was fixed in May 2026)