feat: add CacheTimer widget for prompt cache TTL countdown#307
Open
tuansondinh wants to merge 3 commits intosirmalloc:mainfrom
Open
feat: add CacheTimer widget for prompt cache TTL countdown#307tuansondinh wants to merge 3 commits intosirmalloc:mainfrom
tuansondinh wants to merge 3 commits intosirmalloc:mainfrom
Conversation
Reads ~/.claude/state/cache-timer-{session_id}.json written by the
claude-cache-countdown hooks and displays live cache state:
🔥 HOT — agent active, cache being refreshed
🟢 4:52 — countdown with green/yellow/red urgency colors
❄️ COLD — cache expired
Widget type: 'cache-timer', category: Session
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of reading ~/.claude/state/cache-timer-{session_id}.json
(which required the claude-cache-countdown hooks to be installed),
the widget now reads the last assistant message timestamp directly
from the transcript_path provided by Claude Code.
No hooks, no external scripts — works out of the box with ccstatusline alone.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When Claude is processing a request, the transcript's last entry is a user message (the assistant response hasn't been written yet). The previous code only searched for assistant timestamps, so it would use the prior turn's timestamp — never showing HOT during active work. Now detects the pending user message and displays 🔥 HOT immediately. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
cache-timerwidget that displays the remaining time on Anthropic's 5-minute prompt cache TTL directly in the status line.No external dependencies. The widget reads the last assistant message timestamp directly from the
transcript_paththat Claude Code already passes to ccstatusline — no hooks, no additional tools required.How it works
On each status line refresh, the widget:
type: "assistant"entryremaining = 300s − elapsedfrom that timestampDisplay states:
Usage
Add
cache-timerto your layout via the TUI or directly in~/.config/ccstatusline/settings.json:{ "type": "cache-timer" }Pair with
refreshInterval: 1in your Claude CodestatusLineconfig so the countdown ticks in real time when the agent is idle:Files changed
src/widgets/CacheTimer.ts— new widgetsrc/widgets/index.ts— exportsrc/utils/widget-manifest.ts— registration