Repository navigation
Description
Problem
When using Claude Code in VS Code with agentic workflows, it's useful to name sessions by the issue/task number being worked on. Currently this requires manual renaming via the UI.
I investigated making Claude rename its own session programmatically by appending custom-title entries to the session .jsonl file (which is what the extension's renameSession() does internally). This partially works but has two issues:
1. Session list titles lost on long sessions
The session list (listSessions) reads titles by scanning only the last 64KB of each .jsonl file for "customTitle" entries. On long sessions (common with agentic workflows), the custom-title entry gets pushed outside this 64KB tail window by subsequent conversation messages, and the title is lost from the session list.
2. No way to update the live tab title
The editor tab title is set via an internal rename_tab webview message. There's no registered VS Code command to trigger this externally. Even if the file-based title is correct, the active tab title can't be updated without going through the extension's internal message channel.
Proposed Solution
Expose a VS Code command like claude-vscode.renameSession that:
- Appends the
custom-titleentry to the.jsonlfile (already implemented internally) - Updates the in-memory
customTitlesMap - Sends a
rename_tabmessage to update the live tab title - Refreshes the session list sidebar
This would allow Claude itself (or other extensions/tools) to set meaningful session names programmatically.
Alternative for #1 alone
Store custom titles in a separate lightweight index (e.g., sessions-index.json or a small sidecar file) rather than relying on scanning the tail of potentially large .jsonl files.
Use Case
Agentic workflows where each session maps to a GitHub issue. Having Claude auto-name the session (e.g., "941-fix-supabase-release") at the start of a workflow would save manual effort and improve session organization.
Activity
mgerasolo commentedon Mar 16, 2026
Historically, I only saw the first 24 characters as tab titles. Now it's randomly updating it, and you can't tell which conversation is which anymore as they are changing, but its picking a random message, which makes it hard to pick the right conversation again, especially since lately when I reload, some of my tabs (I usually have 2-5 open panes each with multiple tabs) won't load likely becuase it is trying to load too many conversations at once on reload/refresh.
interconnectedMe commentedon Mar 16, 2026
Session title corruption — root cause analysis and workaround
This issue is part of a family of bugs that all stem from the same root cause. Collecting them here for visibility:
Title lost/overwritten:
Wrong title displayed / cross-session contamination:
Sessions invisible / indexing failures:
Feature requests (workarounds for the same root cause):
Root cause
The VS Code extension's
listSessionsreads titles by doing a raw string search for"customTitle"in the last 64KB of each.jsonlfile. This has three failure modes:64KB eviction: On long sessions (common with agentic workflows), the
custom-titleentry gets pushed outside the 64KB tail window. Title is lost.Cross-session contamination: The scanner doesn't distinguish between real
custom-titleJSONL entries and the string"customTitle"appearing inside tool results or conversation content. If a tool result contains"customTitle": "some other title"as text, the extension picks that up as the session's title.Overwrite on resume: When a session is resumed and new content is appended, any
custom-titleentry from/renamegets buried deeper in the file. The extension falls back tolastPromptor picks up a stale match from tool output.Proposed fix
Store titles in a separate lightweight index rather than scanning the tail of large JSONL files. A
title-registry.json(or similar) that mapssession_id → titlewould:Workaround
See #32150 for a working implementation (UserPromptSubmit hook + systemd timer + persistent title registry).
interconnectedMe commentedon Mar 16, 2026
@hackyon-anthropic — you worked on the session title fix for #9668 (Warmup titles) and the v2.1.47/v2.1.71 patches. The root cause analysis above identifies why those fixes didn't fully resolve the problem: the 64KB tail scanner picks up
"customTitle"strings from inside tool result content, not just from real JSONL entries. This causes cross-session title contamination that no amount of repositioning thecustom-titleentry can fix.A separate title index file (rather than scanning conversation content) would eliminate all three failure modes in one shot. Happy to discuss the implementation details — we've been running a working workaround (persistent registry + hook) for weeks.
ElliotDrel commentedon Mar 19, 2026
+1 on this. My use case is from the CLI side rather than VS Code:
I'd love to create a custom slash command (e.g.,
/suggest-rename) where Claude analyzes the conversation, suggests a few title options, and then applies the chosen one — all without me having to manually copy-paste into/rename. Right now the workflow is:/rename <title>It's a small friction, but it adds up across dozens of sessions. If Claude had access to a rename tool/API, this could be a single-step interaction.
A programmatic rename capability would benefit both IDE and CLI users — anywhere Claude can suggest context-aware names but can't act on them.
ElliotDrel commentedon Mar 24, 2026
I built a workaround for this: a
/better-titleskill that has Claude analyze the conversation, suggest 3 descriptive titles, and apply the chosen one by appending directly to the session JSONL file.Repo: https://github.com/ElliotDrel/elliots-skills/tree/main/better-title
It works, but it's a hack — writing directly to the JSONL is fragile (see the 64KB tail-scan issue discussed upthread), and there's no way to update the live UI border until the next
/resume. A proper rename API or tool would make this clean and reliable.My use case: at the end of every session I want Claude to give it a descriptive name so I can find it later in the
/resumemenu. Right now the skill handles it, but a first-class API would benefit both CLI and IDE users.ElliotDrel commentedon Mar 24, 2026
I'm personally affected by this — session titles I set via
/rename(or my/better-titleskill) regularly disappear from the/resumemenu on longer sessions. It's disruptive when you're trying to find a specific session among dozens.My
/better-titleskill (repo) partially mitigates this since you can re-run it at the end of a long session to re-append the title within the 64KB window. But that's a band-aid — you shouldn't have to re-title a session just because the conversation got long.+1 for @interconnectedMe's proposal of a separate title registry/index. Scanning the tail of a growing JSONL file for metadata is fundamentally the wrong approach.
interconnectedMe commentedon Mar 24, 2026
Same with mine - it works, but it's hacky, takes a couple of minutes for titles to show up, and sometimes even requires a dev reload....and will likely break on an upcoming extension version....
But - anything to have Claude Code chat sessions actually match to my task card titles ;-)
fthomas-team commentedon Jul 28, 2026
+1 - I start chats all the time that either lead to or link to some external ticket reference. At that point I want Claude to immediately insert that ref into the session title. Why is that not possible? Cmon...
BasedGPT commentedon Jul 31, 2026
That long-session title loss is a cache problem rather than the session JSONL losing its content. The
custom-titlerecord is still in the file; the VS Code extension's 64 KB tail scan simply stops seeing it once later turns push it out.I built
BasedGPT/claude-code-session-recoveryfor the related VS Code cache case. Runpython tools/diagnose.pyfirst; it checks the complete transcript files against the workspace cache and prints the exact recovery command for your diagnosis. If it reports dropped entries, the dry-run command ispython tools/sessions/recover_vscode_sessions.py. That reads the complete JSONL rather than the tail and rebuilds the cache without touching the transcript. Keep VS Code closed before applying a cache repair.That won't provide a live rename command, but it should separate the title/API request from the existing recovery problem: the stored session is still there, while the list can no longer derive its title.
Hope this helps, if my tools are able to help you, would appreciate a ⭐ :)
NubeBuster commentedon Sep 14, 2026
Workaround: rename a live session programmatically via its messaging inbox socket (CLI)
Verified on Claude Code 2.1.270, Linux.
@dokipen Does this work for VS Code as well? It's basically the same as slash rename. But then via a script.
This is the bare minimum test for it. Run
Inside Claude Code. Does that update the VSCode tab?
Or from another terminal:
where the sock is the path that is shown in
/statusThe frame runs the same internal function as a typed
/rename(source"peer"instead of"user"), ~50 ms. This is basically the message that a remote control session would send for emitting a rename command.What it updates (all verified)
.jsonl(custom-title+agent-namerecords)…/<session-id>/custom-title.json~/.claude/sessions/<pid>.jsonregistry (name,nameSource:"peer",nameSince,formerNames)/list-agentsin other sessions,--resumelaterRequirements — what is and isn't needed
--bare;/statusPeer address notunavailable{"type":"auth","token":…}(Linux/macOS)session_idin the framecrossSessionInbound= acceptsandbox.network.allowUnixSocketsclaude --remote <id>/--teleport, the session itself runs in the cloud)Name handling (verified)
name<name>-<word>-<word>is behind server flagtengu_session_name_uniqueness(off for my account), identical for typed and socketLocating the socket
ENVIRONMENT.
CLAUDE_CODE_MESSAGING_SOCKETis available for hooks and in Bash commands run by Claude. docsFallback, for a sender that is not a child of the session (another terminal, one session renaming another, external scripts):
~/.claude/sessions/*.json→ matchsessionId→messagingSocketPath.Hook example / Script
{ "hooks": { "UserPromptSubmit": [ { "hooks": [ { "type": "command", "command": "python3 ~/.claude/hooks/claude-rename-session.py" } ] } ] } }dkushnikov commentedon Oct 20, 2026
Data point from the terminal CLI, Claude Code 2.1.296 on macOS: the inbox-socket control frame from the comment above (
{"type":"control","action":"rename","name":…}+ optionalsession_id) renames a live session end to end — TUI label, transcriptcustom-titlerecord,custom-title.jsonsidecar, pid-file registry (nameSource: "peer",formerNames) and the Remote Control / phone list. Thesession_idguard works as described (mismatching id → frame dropped). We now call it from a wrap-up script so the agent names its own session without a manual/rename.Request: an official door for the same —
claude session rename <id> <name>or a hook/SDK-visible call — the socket frame is undocumented and may change between releases.jacobyoby commentedon Nov 1, 2026
Workaround: https://github.com/jacobrakaiFoundation/claude-mods/tree/main/mods/session-namer
Gives Claude a
rename_sessiontool (same as/rename), and names an unnamed session after its first answer with a short title from a small model. A name you set is never replaced unless your prompt asks for a new one. Interactive sessions only (it stays silent underclaude -p). Install:/plugin install session-namer --marketplace jacobrakaiFoundation/claude-mods.