microsoft / microsoft/vscode

Chat session history intermittently lost/truncated after closing VS Code (possibly related to closing while a chat is open)

Open
#333,143 0 comments 0 reactions 1 assignee Claimed by @roblourens View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

*Environment**

- VS Code version: `1.135.0` (Stable), Windows

- Chat: built-in Copilot Chat, version `0.63.0`

**Summary**

On more than one occasion, a chat session with substantial accumulated history (built up over multiple days/restarts) has been found completely empty after or lost closing and reopening VS Code. This is intermittent and I don't have a 100% reliable repro, but it consistently seems to happen around closing VS Code while a chat session is open (e.g. pinned/active in the editor area or panel), not during normal use.

**What I observed on one occurrence**

- Inspected the session file directly at

`%APPDATA%\Code\User\workspaceStorage\\chatSessions\.jsonl`

- The file's embedded `creationDate` corresponded to several days before the loss — confirming it was a genuine long-running session, not a new/empty one.

- Despite that, at the moment history disappeared, the file on disk contained only a single line: the initial session snapshot (`"kind":0`) with an empty `"requests":[]` array — as if the session had been reset to its initial state rather than preserving its accumulated log.

- The file's last-write timestamp lined up with a period of extension host instability in that session (an unrelated `Not allowed to create elements in child window...` error had occurred shortly before, which made the extension host briefly unresponsive) — so I suspect the loss happens when a session save/compaction runs while the extension host or window is being torn down/closed in an unstable state, overwriting the log instead of appending to or preserving it.

**Steps to reproduce (best effort — intermittent)**

1. Use a chat session across multiple VS Code restarts so it accumulates real history.

2. At some point, close VS Code while that chat is open/active (in editor area or panel).

3. Reopen VS Code and reopen the same chat session from history.

4. Occasionally, the session is found empty or lost, containing only its initial snapshot.

**Expected behavior**

Closing VS Code (cleanly or otherwise) should never cause previously-persisted chat history to be lost. The session store should treat the on-disk log as append-only / write-ahead, so a save or compaction during shutdown can only add to it, never truncate or replace already-persisted history with an empty state.

**Actual behavior**

Chat session data is intermittently and silently truncated to its initial empty state, with no error shown to the user, discoverable only by inspecting the raw session file.

**Additional notes**

- I also found a related but separate issue for the "Open Chat in New Window" child-window DOM error, which I suspect may be one (but not the only) trigger for extension-host instability that precedes this data loss.

- Because this is intermittent, I don't have a minimal/reliable repro — happy to share the raw (redacted) `.jsonl` session file from an occurrence if useful for diagnosis.

-on opening vs code, when I click on a chat session. The chat opens blank in a new window. After I close it the chat disappears from session history. After opening some other chat and after going back, the chat is visible under sessions again.

Please look into this as I lost many important chats many times.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.