[BUG] Status line JSON not updated after /clear — context_window data remains stale
Description
After running /clear, the status line command continues to receive the previous session's context_window.current_usage token counts. The status line is not updated with fresh (zeroed) data until the first API round-trip in the new session completes.
This means any custom status line displaying context usage (a common use case) shows stale percentages after /clear, which is confusing — the user sees a cleared conversation but the context bar still shows, e.g., 44%.
Steps to Reproduce
- Start a Claude Code session with a custom
statusLinecommand that displayscontext_window.current_usagedata - Have a conversation long enough to reach meaningful context usage (e.g., 40%+)
- Run
/clear - Observe that the status line still displays the pre-clear context percentage
- Send a new message — the status line now correctly resets to a low percentage
Expected Behavior
After /clear, the status line should receive an updated JSON payload with zeroed/reset context_window.current_usage values, reflecting the new empty session state.
Actual Behavior
The status line retains stale token counts from the previous session until the next API call triggers a fresh status line update.
Environment
- Claude Code: v2.1.50
- Platform: macOS (Darwin 25.4.0)
- Model: Opus 4.6
Suggested Solutions
- Emit a status line update on
/clear— When/clearresets the session, push a JSON payload to the status line command with zeroedcurrent_usagefields. This is the most natural fix since/clearis a session-boundary event.
- Add a
session_idfield to status line JSON — Include a session identifier so custom status lines can detect session changes and reset their displayed state independently.
- Fire a
SessionClearhook event — Emit a hook event (e.g.,PostCommandwith command/clear) so hook authors can react to session resets. This would also benefit other hook use cases beyond status lines.
Option 1 is the simplest and most direct fix.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗