Feature Request: Add session name to statusline JSON input
Resolved 💬 3 comments Opened Jan 13, 2026 by tomerbr1 Closed Mar 1, 2026
Summary
Add the current session name/summary to the JSON data passed to custom statusline scripts, enabling statuslines to display the accurate session name without parsing transcript files.
Problem
Currently, the statusline receives JSON input with session_id, model, context_window, cost, etc., but not the session name. Custom statuslines that want to display the session name must:
- Parse the transcript JSONL file (
~/.claude/projects/{encoded-cwd}/{session-id}.jsonl) - Search for
{"type":"summary","summary":"..."}entries - Extract the last valid summary
This creates a timing/staleness issue where:
- Claude Code's internal state updates the session name immediately (e.g., when using
/renameor when Claude suggests a name via hooks) - The transcript JSONL is only updated at specific lifecycle events (session end, hooks, etc.)
- The statusline script runs and reads from the stale transcript
- Result: The iTerm2 tab title (set by Claude Code internally) shows the correct name, while the statusline shows stale/old data
Proposed Solution
Include session_name (or session_summary) in the JSON passed to the statusline command:
{
"session_id": "abc123-...",
"session_name": "My Feature Implementation",
"model": {...},
"context_window": {...},
"cost": {...}
}
Benefits
- Statuslines can display the accurate, current session name immediately
- No need for workarounds like cache files or transcript parsing
- Consistent with how Claude Code already tracks session names internally for setting terminal/tab titles
- Enables richer statusline customization
Current Workaround
I've implemented a workaround using:
- A
UserPromptSubmithook that asks Claude to emit<!-- SESSION_NAME: ... -->comments - A
Stophook that parses these comments and writes to both the transcript AND a cache file - The statusline reads from the cache file first, falling back to transcript
This works but adds complexity and is still subject to timing issues between hook execution and statusline calls.
Environment
- Claude Code version: 2.1.6
- Platform: macOS
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗