Statusline doesn't refresh after /compact, showing stale context usage

Resolved 💬 3 comments Opened Apr 9, 2026 by mpiroc Closed Apr 13, 2026

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

  1. Work in a conversation until context usage is moderately high (e.g., ctx:40% remaining)
  2. Run /compact
  3. Observe that the statusline still shows ctx:40% (or whatever the pre-compaction value was)
  4. Send any new prompt — the statusline now updates to reflect the actual post-compaction percentage (e.g., ctx:85%)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗