feat: show session name from /rename in notification title#1
Open
PhilipeeX wants to merge 2 commits into
Open
Conversation
Reads the session_id from the hook JSON payload and looks up the corresponding session file in ~/.claude/sessions/ to extract the name set by Claude Code's /rename command. When a session has been renamed, notifications display: "Claude Code [session-name] — Done" "Claude Code [session-name] — Needs Input" Sessions without a custom name keep the original format unchanged.
The session_id in the hook JSON payload differs from the sessionId stored in ~/.claude/sessions/ files. Instead, walk up the process tree to find the Claude Code PID that matches a session file. Also moves the session name from the notification title to the subtitle for better readability (title was being truncated). Result: "core · Analytics database" in subtitle instead of "Claude Code [Analytics database] — D..." in truncated title.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When users rename their Claude Code sessions with
/rename, the custom name now appears in the notification subtitle alongside the project name:corecore · my-sessionThis makes it easy to identify which session triggered a notification when running multiple Claude Code instances.
How it works
~/.claude/sessions/{PID}.jsonfor the matching session filenamefield (set by/rename)Sessions without a custom name keep the original format unchanged — fully backward compatible.
Why PID ancestry instead of session_id?
The
session_idin the hook JSON payload is a conversation/transcript ID, which differs from thesessionIdstored in~/.claude/sessions/*.json. However, the session files are named by the Claude Code process PID, so walking up the process tree reliably finds the correct file.Test plan
core · Analytics databasecore(unchanged)/renamemid-session — next notification picks up the new name immediatelyexample:
