[BUG] VS Code extension: renamed sessions revert to the last prompt once the custom-title record drifts past the 64 KB tail window

Status Open
Reported on v2.1.265
Maintainer reply None cached
Activity 0 comments · opened Sep 9, 2026

Summary

A manually renamed session reverts to showing the text of the last message sent. The rename is not lost on disk; it becomes unreadable because both the session list and the auto-titler read only a fixed window of the transcript.

Related, all closed without a fix: #26240, #46587, #72554, #65361. This report adds the write-side half of the bug, which those do not cover.

Environment

  • Extension: anthropic.claude-code 2.1.265 (linux-x64)
  • CLI: 2.1.258

Mechanism

A manual rename appends a record to the end of the session transcript:

{"type":"custom-title","sessionId":"...","customTitle":"..."}

Both the session list and the rename guard read the transcript through a helper that reads only 65536 bytes from the start and 65536 bytes from the end (D2 = 65536), returning {head, tail}.

Read path. The listing resolves a display name by falling through:

let q = D9(U,"customTitle") ?? D9(K,"customTitle") ?? D9(U,"aiTitle") ?? D9(K,"aiTitle"),
N = q || D9(U,"lastPrompt") || D9(U,"summary") || AT$(K);

with U the tail and K the head. Once the transcript grows so the custom-title record sits outside both windows, q is undefined and the name falls through to lastPrompt, which is the user's most recent message. The listing also returns customTitle: undefined, so the session is treated as never renamed and the restore path that would reinstate the title never runs.

Write path. The auto-titler calls rename with onlyIfNoCustomTitle set, and that guard consults the same window:

if (J && W) {
if (D9(W.tail,"customTitle") || D9(W.head,"customTitle")) return true; // skip
appendFile(z, JSON.stringify({type:"ai-title", sessionId:$, aiTitle:Q}) + "\n")
}

So the guard concludes there is no custom title and appends an ai-title over a rename that is still present in the file. This is the part not covered in the earlier reports.

The full parser (ensureSessionLoaded) reads the whole file in order and does prefer custom-title correctly, so behaviour differs between the windowed fast path and the full load.

Reproduction

  1. Rename a session in the sidebar.
  2. Continue working until more than 64 KB of transcript is appended (a few tool calls in an agentic session).
  3. The sidebar now shows the last prompt instead of the chosen name.

Evidence

Across 75 renamed sessions in one project directory, 7 had the custom-title record stranded outside both windows. For those, the resolver lands on lastPrompt and displays text such as "continue" or a raw slash command, while the chosen name is still present mid-file. In one case an ai-title had been appended after the stranded custom-title, confirming the guard misfiring.

Sessions of 1 MB to 11 MB are normal for long agentic runs, and the stranded records sat around byte 100 KB to 300 KB, just past the head window.

Impact

Renaming is unreliable on exactly the long sessions where it is most useful. The recorded name is silently shadowed rather than deleted, so it looks like data loss.

Suggested fix

Any of:

  1. Resolve the title from a sidecar file per session, removing the dependency on byte offsets.
  2. Scan the whole file for custom-title when the windowed read finds none, before falling back to lastPrompt.
  3. Rewrite or move the custom-title record to the tail on each append, keeping it inside the window.

At minimum, the write-side guard should not append an ai-title on the basis of a partial read.

Workaround

Rename immediately before finishing with a session. The record then sits inside the tail window and survives, until roughly 64 KB more is written.

View original on GitHub ↗