/clear drops session_name from statusline JSON input (preserved internally)

Resolved 💬 1 comment Opened Apr 8, 2026 by PearGod Closed Apr 15, 2026

Summary: After running /clear, the session_name field is missing from the JSON input piped to the statusline command, even though the session was named via /rename (or --name / --remote-control "<name>") and the name is still preserved in the session state. Re-running /rename repopulates it.

Repro (self-contained — works on a fresh setup):

  1. Create a minimal statusline script at /tmp/repro-statusline.sh:

``bash
#!/usr/bin/env bash
input=$(cat)
name=$(echo "$input" | jq -r '.session_name // "<empty>"')
echo "session_name=$name"
`
Then
chmod +x /tmp/repro-statusline.sh`.

  1. Add to ~/.claude/settings.json:

``json
{
"statusLine": {
"type": "command",
"command": "bash /tmp/repro-statusline.sh"
}
}
``

  1. Start a new Claude Code session. Statusline shows session_name=<empty> (expected — no name yet).
  1. Run /rename work. Statusline now shows session_name=work. ✓
  1. Run /clear. Statusline now shows session_name=<empty>. ✗
  1. Run /rename work again. Statusline shows session_name=work again — confirming the underlying state still accepts and tracks the name; only the post-/clear JSON payload to the statusline omits it.

Expected: after step 5, session_name should still be work. The user did not ask to drop their session identity by clearing history.

Why it matters: statuslines, custom tooling, and any consumer of the input JSON lose visual/structural session identity for the rest of the session unless the user manually re-renames after every /clear. There is no workaround via hooks — SessionStart (matcher: clear) fires correctly, but no documented hook output field can set or restore the session name.

Environment: Claude Code (Mac terminal), Opus 4.6, statusline configured under statusLine in ~/.claude/settings.json. SessionStart clear matcher confirmed firing via existing hook plumbing.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗