[BUG] Status line CONTEXT % not updated after /clear — stale context_window data displayed
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 the PAI status line's CONTEXT bar shows stale percentages after /clear — e.g., the user sees a cleared conversation but the context bar still shows 44%.
Steps to Reproduce
- Start a Claude Code session (PAI status line active via
statusline-command.sh) - 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 CONTEXT bar should reset to reflect the new empty session state (near 0%).
Actual Behavior
The CONTEXT bar retains stale token counts from the previous session until the next API call triggers a fresh status line update.
Root Cause
Claude Code pipes JSON with context_window.current_usage to the status line command on each update. /clear resets the session internally but does not push a fresh JSON payload to the status line — so statusline-command.sh keeps displaying the last values it received.
Environment
- Claude Code: v2.1.50
- Platform: macOS (Darwin 25.4.0)
- PAI: v3.0, Algorithm v1.8.0
Suggested Solutions
Option 1: PAI-side fix — detect /clear via hook and reset display
Add a hook that fires on /clear and forces the status line to display zeroed context values. This is fully within PAI's control and doesn't depend on upstream changes.
Option 2: Upstream fix — request Claude Code emit status line update on /clear
File an issue on anthropics/claude-code requesting that /clear push a zeroed context_window.current_usage payload to the status line command. This is the cleanest fix but depends on the CC team.
Option 3: Hybrid — PAI-side workaround + upstream feature request
Implement Option 1 now as a workaround, and file Option 2 upstream for a proper long-term fix.
Option 3 (hybrid) is recommended.
Fixed in v4.0.1 — the broken context percentage fallback that persisted stale data after /clear has been removed. The statusline now only reports what Claude Code provides directly.