Statusline doesn't refresh after /compact, showing stale context usage
Problem
After running /compact, the statusline continues to display the pre-compaction context usage percentage. Since compaction significantly reduces context usage, seeing a high ctx:XX% value immediately after compacting is confusing and misleading.
The statusline only refreshes on the next conversation turn (when Claude makes an API call), so the stale value persists until the user sends another prompt.
Statusline script context
My statusline script extracts and displays context usage from the JSON input that Claude Code provides:
# Extract remaining context percentage from input JSON
remaining=$(echo "$input" | jq -r '.context_window.remaining_percentage // empty')
# Display as ctx:XX% in the statusline
if [ -n "$remaining" ]; then
printf " \033[0;33mctx:%s%%\033[0m" "$(printf '%.0f' "$remaining")"
fi
The script relies entirely on .context_window.remaining_percentage from the input — it has no way to know that a compaction just occurred and the value is stale.
Expected behavior
The statusline should refresh after /compact completes, so the updated context percentage is immediately visible. This would also apply to any other built-in command that materially changes context window state.
Steps to reproduce
- Work in a conversation until context usage is moderately high (e.g.,
ctx:40%remaining) - Run
/compact - Observe that the statusline still shows
ctx:40%(or whatever the pre-compaction value was) - Send any new prompt — the statusline now updates to reflect the actual post-compaction percentage (e.g.,
ctx:85%)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗