Skip to content

[low] fix(cache-timer): stop reporting HOT after interrupts and local slash commands - #628

Merged
sirmalloc merged 1 commit into
sirmalloc:mainfrom
elhoim:fix/cache-timer-idle-after-meta-rows
Oct 9, 2026
Merged

sirmalloc merged 1 commit into
sirmalloc:mainfrom
elhoim:fix/cache-timer-idle-after-meta-rows

Conversation

@elhoim

@elhoim elhoim commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

BLUF

  • Priority: low.
  • The Cache Timer widget showed HOT (request in flight) indefinitely after an Esc interrupt or a local slash command (/cost, /model, ...), even once the prompt cache had gone cold.
  • Cause: any trailing main-chain user row counted as in flight, but Claude Code writes several user rows that never reach the API.
  • Fix: interrupt markers and local-command rows now end the turn, the same way an assistant row does. The countdown then resumes from the last assistant row with cache activity. Regression tests included.

Details

Failure scenario. scanTailForState walks the transcript tail newest-first and returns { isWorking: true } for the first type: "user" row it meets before any assistant row. It never looks at what that row is. Claude Code also appends user rows that do not start or continue an API request:

  • the interrupt marker: a user row whose content is a single text block [Request interrupted by user] (or ... for tool use]), written after Esc;
  • local slash-command bookkeeping: an isMeta <local-command-caveat> row, a <command-name>/cost</command-name>... row, and usually a <local-command-stdout> row. Some commands record a system row instead of the stdout row.

If a session ends on one of these, the tail finishes with a user row that has no assistant row after it. The widget then shows HOT until the next real prompt, including after the 5-minute TTL has passed, which is the moment the widget is meant to warn about.

Fix. A small endsTurnWithoutResponse helper recognizes those rows by content prefix ([Request interrupted by user, <command-name>, <local-command-stdout>, <local-command-stderr>, <local-command-caveat>). In the scan they set turnFinished and continue, the same handling as an assistant row that refreshed no cache. They never anchor the countdown. Rows whose content is missing or unrecognized still count as in flight, so the existing behaviour and fixtures are unchanged.

Deliberately not skipped:

  • isMeta rows in general. Prompt-based slash commands (<command-message> first) and hook or skill context are written as isMeta user rows, and they are sent to the model. A guard test pins this: a prompt command still shows HOT.
  • isCompactSummary rows. A manual /compact already ends in local-command rows, which this change handles. An auto-compact mid-turn continues with a real request.

Checks

  • bun run lint (tsc + eslint --max-warnings=0): clean.
  • bun test src/widgets/__tests__/CacheTimer.test.ts:
    • Before the fix: 30 pass, 2 fail. The new interrupt and local-command tests received 🔥 HOT.
    • After the fix: 32 pass, 0 fail.
  • Full bun test: CacheTimer and CacheWidgets suites all pass. Remaining failures are time-limit-sensitive suites that already fail on unmodified main on the same heavily loaded machine: fetchUsageData error handling hits its 5 s timeout, and there are custom-command capture and TUI menu tests. None of them touch the cache timer.
    • With this branch: 2309 pass, 52 fail. On unmodified main (same machine): 2306 pass, 52 fail, in the same 12 suites. The pass count differs by exactly the 3 new tests.
    • Per-suite counts differ by one between runs, which points to load-induced flakes.
  • bun run build: succeeds, and dist/ccstatusline.js is present.

🤖 Generated with Claude Code

scanTailForState treated any trailing main-chain user row as an in-flight
request. Claude Code also writes user-role rows that never reach the API:
the "[Request interrupted by user]" marker left by Esc, and the
bookkeeping rows of local slash commands such as /cost or /model
(<local-command-caveat>, <command-name>, <local-command-stdout>). A
session ending on one of those showed HOT indefinitely, even after the
prompt cache had gone cold, which is the state the widget exists to warn
about.

Treat those rows like an assistant row that refreshed nothing: they end
the turn, and the countdown keeps anchoring on the newest assistant row
with cache activity. Rows with any other content (including isMeta
prompt-command expansions and hook context, which are sent to the model)
still count as in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants