[FEATURE] add session_name into hooks common fields

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Mar 26, 2026 · closed Mar 31, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

I often need to work with multiple projects and may leave claude to do some work, notifying me via a hook (and a system toast) when it requires some input.

The issue I have is if I have 10 of these knowing which one sent the input is non obvious.

Various workarounds exist such as obtaining the current working directory (but that is not obvious in a terminal title).

The hook injects the SessionID but there is no (supported) way to get the name of the current session from that.

NB on windows using windows terminal it is not possible to obtain the title of the tab that claude is running in.

Proposed Solution

the Hook json is extended to include session_name

Alternative Solutions

you can parse the json log for the session but this can be rather large and is not so performant.

extending claude to have a flag that prints all sessions IDs and names (/resume will not list in progress sessions just saved ones).

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

I have 10 claude sessions on the go, probably 3 windows with 3 or 4 tabs in each. Possibly some of these windows are on different desktops.

Setup a hook such that whenever claude needs some input (or it is waiting) it sends you a notification.

Your ability to react on that information requires you to know which claude session it came from.

The best thing to use is the session name, this is often added to the name of the tab in the window.

In the case where the session is not named, fallback to the inferred session name (which is set by claude in the title)

Additional Context

currently the toast appears like: which is using the working directory

<img width="584" height="284" alt="Image" src="https://github.com/user-attachments/assets/eee266ca-7654-4ae1-bf94-3f09eed64586" />

that does not make it so obvious when your tab titles are like

<img width="855" height="95" alt="Image" src="https://github.com/user-attachments/assets/47be11e8-6eae-4d82-b57d-48172439b8d6" />

(well probably obvious in this use dummy example, but would be nicer if it could show "check current time").

View original on GitHub ↗

6 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/36058
  2. https://github.com/anthropics/claude-code/issues/36623
  3. https://github.com/anthropics/claude-code/issues/21103

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

evdibbs-manticore · 5 months ago

+1, exact same use case here — Windows toast notifications with taskbar flashing across multiple sessions. As noted in the auto-close bot's comment, #36058 is the canonical issue. I've added a detailed comment there covering why auto-generated titles (not just /rename'd ones) should be included, and why there's no viable client-side workaround on Windows.

yurukusa · 5 months ago

Until session name is added to the hook input, you can track it yourself:

SESSION_ID=$(cat | jq -r '.session_id // empty' 2>/dev/null)
BRANCH=$(git branch --show-current 2>/dev/null || echo "detached")
DIR=$(basename "$PWD")
NAME="$DIR/$BRANCH"
echo "$NAME" > /tmp/cc-session-name
echo "$SESSION_ID" > /tmp/cc-session-id
echo "Session: $NAME ($SESSION_ID)" >&2
exit 0

Then any other hook can read the session name:

SESSION_NAME=$(cat /tmp/cc-session-name 2>/dev/null || echo "unknown")
echo "[$SESSION_NAME] Your hook output here" >&2
exit 0

For a more structured approach with multiple sessions:

INPUT=$(cat)
EVENT=$(echo "$INPUT" | jq -r '.event // empty')
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty')
REGISTRY="/tmp/cc-sessions.json"
if [ "$EVENT" = "start" ]; then
    NAME="$(basename $PWD)/$(git branch --show-current 2>/dev/null)"
    jq --arg id "$SESSION_ID" --arg name "$NAME" '.[$id] = $name' "$REGISTRY" 2>/dev/null > "${REGISTRY}.tmp" || echo "{}" | jq --arg id "$SESSION_ID" --arg name "$NAME" '.[$id] = $name' > "${REGISTRY}.tmp"
    mv "${REGISTRY}.tmp" "$REGISTRY"
elif [ "$EVENT" = "stop" ]; then
    jq --arg id "$SESSION_ID" 'del(.[$id])' "$REGISTRY" > "${REGISTRY}.tmp" && mv "${REGISTRY}.tmp" "$REGISTRY"
fi
exit 0
jtnord · 5 months ago
Until session name is added to the hook input, you can track it yourself:

Session names are not based on git branches. In some use cases they may be, but you should never assume that.

jtnord · 5 months ago

dupe of #36058

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.