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:

  1. Parse the transcript JSONL file (~/.claude/projects/{encoded-cwd}/{session-id}.jsonl)
  2. Search for {"type":"summary","summary":"..."} entries
  3. 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 /rename or 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:

  1. A UserPromptSubmit hook that asks Claude to emit <!-- SESSION_NAME: ... --> comments
  2. A Stop hook that parses these comments and writes to both the transcript AND a cache file
  3. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗