Skip to content

Rename stopped sessions with the agent-name record too, so resume draws it - #56

Merged
flipbit03 merged 2 commits into
mainfrom
feat/bug-rename-sessh
Aug 25, 2026
Merged

Rename stopped sessions with the agent-name record too, so resume draws it#56
flipbit03 merged 2 commits into
mainfrom
feat/bug-rename-sessh

Conversation

@flipbit03

Copy link
Copy Markdown
Owner

The bug

Rename a stopped Claude session in forestui, resume it: the tmux tab carries the new name, but the Claude prompt-box badge keeps the old one — and no amount of chatting realigns them. Only renaming the tab a second time fixed it.

Root cause

Claude Code keeps a session's name in two transcript records, written as a pair by every runtime rename (/rename, or the sync plugin's sessionTitle push):

  • custom-title — the session title: the resume picker, hook-input session_title
  • agent-name — what the badge in the prompt box draws

forestui's stopped-session rename appended only custom-title. On resume the title was right everywhere except the visible badge — and the sync plugin could not heal it, because the title it compares against the window name was already the new name, so all three strings it can see agreed and it never pushed the runtime rename that rewrites the agent name. A second tab rename broke the tie (window != @claude_synced_name), which is why that worked.

Diagnosed from a real repro transcript: forestui's appended record is identifiable by serde_json's alphabetical key order, and the working second rename is the only one followed by an agent-name record.

The fix

  • rename_transcript now appends the same custom-title + agent-name pair Claude writes, so a resumed session draws the new name from its first frame.
  • Hardening from adversarial review: if the transcript's last line is torn (no trailing newline), lead with one — appending blindly would fuse the first record onto the torn line and half-apply the pair, recreating the exact disagreement this fixes.

Testing

  • Unit tests assert both records land as valid standalone JSON lines stamped with the session id, plus the torn-tail case; make check and make check-shipped green.
  • Live tu-driven repro (isolated tmux + real Claude): fresh session claude:demo → stop → rename in forestui to claude:demoRENAMED → resume: badge and tab both show the new name immediately, stable across turns; a subsequent tab rename still syncs to the session on the next turn, so the normal two-way path is unregressed.

Sessions renamed-while-stopped before this fix heal on their next tab rename, as before; nothing to migrate.

…ws it

Claude keeps a session's name in two transcript records and a runtime
rename writes them as a pair: custom-title is the session title (the
resume picker, hook-input session_title), agent-name is what the badge
in the prompt box draws. Renaming a stopped session appended only
custom-title, so a resumed session showed its old name — and the sync
plugin could not heal it, because the title it compares against the
window was already the new name, so it never pushed the runtime rename
that rewrites the agent name. Only renaming the tab a second time broke
the tie.

Append the same pair Claude writes and the resumed badge is right from
the first frame, verified live under tu.
Appending straight onto an unterminated last line would fuse the
custom-title record into it — both stop parsing — while the agent-name
record still lands, recreating the title/badge disagreement the pair
exists to prevent. Lead with a newline when the file does not end in
one.
@flipbit03
flipbit03 merged commit 82cb640 into main Aug 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant