[BUG] Session titles revert to last-prompt text after session close, overriding custom-title entries
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [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?
These chat sessions that worked with the 'first line as title', were critical to me correlating work in Claude Code chat sessions <-> kanbn task manager used for the project.
So now I'm having to have Claude try to rename the things that it is automatically renaming, that I already had a solid title for in the very first line.
Chat sessions get renamed seemingly at random, and are then mostly un-searchable as the 'session title' has been auto-edited to some arbitrarily-chosen text 'somewhere in the chat session' by (Claude Code, VScode ???).
After a session ends, the Claude Code VS Code extension writes a last-prompt entry to the session's JSONL file. This entry becomes the final entry in the file, and the sidebar then displays the lastPrompt text (the user's final message) as the session title — overriding any custom-title entry that was written earlier in the file.
Previously, the sidebar used the first user message as the session title by default. Now, closed sessions display their last message text instead. This makes sessions unrecognisable in the sidebar, especially for users who rely on writing a descriptive title as the first line of their first message (e.g. "Task: Task 186.1 - LLM Scoring Heatmap Load Performance — Backend Query Optimisation and Caching" to identify sessions and pick up e.g. kanbn Task cards to continue the work.
What Should Happen?
The session sidebar should display the custom-title entry as the title regardless of whether a last-prompt entry was appended afterward.
Previously, sessions were titled by their first user message line, and the title persisted correctly across VS Code restarts and session close/reopen cycles. The last-prompt entry should not override a custom-title entry when displaying session names in the sidebar.
Manual renames (via the edit icon in the sidebar) do work correctly because VS Code appends the new custom-title after last-prompt, making it the final entry. This confirms the sidebar is using "last entry wins" logic rather than "custom-title wins" logic. The fix would be to prioritise any custom-title entry over last-prompt for display purposes.
But again, this adds a lot of friction, when 'first line is title' worked fine, with no more overhead than pasting in the task card title that I was working on.
Error Messages/Logs
No error messages. The behaviour is silent — sessions simply display the wrong title (last message text instead of the session's custom-title).
Example JSONL file tail showing the problem:
...conversation entries...
{"type":"custom-title","sessionId":"25e59705-...","customTitle":"Find the chat session where we added a custom hook or script..."}
{"type":"last-prompt","lastPrompt":"Good, will test by restarting / reloading window shortly...","sessionId":"25e59705-..."}
Sidebar displays: "Good, will test by restarting / reloading window shortly..."
Expected display: "Find the chat session where we added a custom hook or script..."
Steps to Reproduce
- Open Claude Code in VS Code and start a new session.
- Type a descriptive first message (e.g. "Task: Task 149 - My Task Name").
- Have a multi-turn conversation.
- Close the session (close the tab or open a new session, or reopen VScode).
- Observe the closed session in the sidebar — it now displays the text of your last message, not your first message or any previously set custom-title.
- Restart VS Code — the wrong title persists across restarts.
Root cause (confirmed by inspection of JSONL files): the extension appends a {"type":"last-prompt","lastPrompt":"..."} entry when a session closes. The sidebar then displays lastPrompt because it is the final entry in the file, taking precedence over earlier custom-title entries.
Manual renames via the sidebar edit icon do persist correctly, because VS Code appends the new custom-title after last-prompt — confirming the issue is position-dependent, not a reading failure.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Unknown — noticed after a recent extension update. Last known working behaviour: sessions displayed the first line of the first user message as the title by default, and this persisted correctly after session close and VS Code restart.
Claude Code Version
2.1.62 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
VS Code version: 1.109.5 (x64)
The workaround we implemented locally:
- A systemd user timer runs
find-session.py --fix-last-promptevery 2 minutes - It detects sessions where
last-promptis the final JSONL entry and nocustom-titlefollows it - Appends a compact
custom-title(from the session's first user message line) afterlast-prompt - Restores the original file mtime afterward to preserve sidebar sort order
This workaround works, but it means sessions show the wrong title for up to 2 minutes after closing, and requires external tooling to compensate for what should be (or was, now isn't, but could be again...) built-in behaviour.
Impact: users who rely on descriptive first-line titles to identify sessions (a natural workflow given the sidebar shows session titles) will find all their closed sessions display meaningless last-message text instead. With 500+ sessions, this makes the session list unusable without the workaround.
System Details Report
---
Report details
- Date generated: 2026-03-08 14:52:19
Hardware Information:
- Hardware Model: Gigabyte Technology Co., Ltd. X870E AORUS ELITE WIFI7
- Memory: 128.0 GiB
- Processor: AMD Ryzen™ 9 7900X × 24
- Graphics: AMD Radeon™ Pro WX 3200 Series
- Graphics 1: AMD Radeon™ Pro WX 3200 Series
- Disk Capacity: 13.0 TB
Software Information:
- Firmware Version: FA6d
- OS Name: Ubuntu 24.04.4 LTS
- OS Build: (null)
- OS Type: 64-bit
- GNOME Version: 46
- Windowing System: Wayland
- Kernel Version: Linux 6.17.0-14-generic
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗