/clear drops session_name from statusline JSON input (preserved internally)
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):
- 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"
chmod +x /tmp/repro-statusline.sh`.
Then
- Add to
~/.claude/settings.json:
``json``
{
"statusLine": {
"type": "command",
"command": "bash /tmp/repro-statusline.sh"
}
}
- Start a new Claude Code session. Statusline shows
session_name=<empty>(expected — no name yet).
- Run
/rename work. Statusline now showssession_name=work. ✓
- Run
/clear. Statusline now showssession_name=<empty>. ✗
- Run
/rename workagain. Statusline showssession_name=workagain — confirming the underlying state still accepts and tracks the name; only the post-/clearJSON 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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗