[VS Code] Renamed session titles occasionally revert on startup
Description
Renamed session titles in the Claude Code VS Code extension
occasionally revert to their original auto-generated title
after restarting VS Code. The issue is intermittent — it
does not happen every time, but frequently enough to be
annoying.
Environment
- Claude Code extension version: 2.1.101
- VS Code on Windows 10 Pro
- OS: Windows 10.0.19045
Reproduction
- Open Claude Code in VS Code
- Rename a session from the sidebar
- Close VS Code
- Reopen VS Code
- Observe: with some probability, the session label reverts
to the original AI-generated title
Investigation
I dug into the storage layer and found a likely root cause.
Two data sources for session titles
~/.claude/projects/<project>/sessions-index.json
— stores firstPrompt, used as the default title.
There is no customTitle or label field.
<VSCode>/workspaceStorage/<hash>/state.vscdb, key
agentSessions.model.cache
— stores the label field that the extension actually
renders in the sidebar. When I rename a session, the new
name gets written here.
The likely bug
Because sessions-index.json has no field for custom titles,
the VS Code extension stores the renamed title only inagentSessions.model.cache. On startup, the extension seems
to merge or sync data from both sources, and in some cases
the label in the cache gets overwritten by a freshly
derived title from sessions-index.json (likely based onfirstPrompt or a regenerated summary).
This creates a race between:
- Loading the persisted custom
labelfrom the SQLite cache - Regenerating the label from
firstPrompt
Whichever finishes last wins, which produces the intermittent
behavior.
Suggested fix
Use a single source of truth for custom titles:
- Add a
customTitle(oruserLabel) field to
sessions-index.json
- Write to this field only when the user explicitly renames
- On load, the VS Code extension should prefer
customTitle
and fall back to firstPrompt only when it is absent
This eliminates the race condition and makes renamed titles
durable across restarts.
Additional note
I also noticed that some non-ASCII labels inagentSessions.model.cache appear as mojibake, which might
be a related encoding issue (non-UTF-8 read as UTF-8), but
this may be a separate bug worth tracking.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗