SLOPSHOPPER

cache-meter

Prompt-cache hit rate in one row above the prompt, with how long the cache stays warm and a Keep warm switch that refreshes it while you are away.

bandtoastmodeltimer
★ 3v0.4.3MITupdated 2026-10-24T-AI-Labs/claude-code-mods/cache-meter
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · cache-meter
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM Cache ▮▮▮▮▮ ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
Cache ▮▮▮▮▮ ⟨Claude Code's own drawing⟩
README

<h1 align="center">Claude Code Mods</h1>

<a href="https://github.com/T-AI-Labs/claude-code-mods/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/T-AI-Labs/claude-code-mods/ci.yml?branch=main&style=flat-square&label=ci" alt="CI"></a> <a href="https://github.com/T-AI-Labs/claude-code-mods/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FT-AI-Labs%2Fclaude-code-mods%2Fmain%2Fcontext-usage%2F.claude-plugin%2Fplugin.json&query=%24.version&prefix=v&label=context-usage&style=flat-square" alt="context-usage version"></a> <a href="https://github.com/T-AI-Labs/claude-code-mods/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FT-AI-Labs%2Fclaude-code-mods%2Fmain%2Fcache-meter%2F.claude-plugin%2Fplugin.json&query=%24.version&prefix=v&label=cache-meter&style=flat-square" alt="cache-meter version"></a> <a href="https://github.com/T-AI-Labs/claude-code-mods/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FT-AI-Labs%2Fclaude-code-mods%2Fmain%2Fcatalog-pane%2F.claude-plugin%2Fplugin.json&query=%24.version&prefix=v&label=catalog-pane&style=flat-square" alt="catalog-pane version"></a> <a href="https://github.com/T-AI-Labs/claude-code-mods/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FT-AI-Labs%2Fclaude-code-mods%2Fmain%2Fcontext-meter%2F.claude-plugin%2Fplugin.json&query=%24.version&prefix=v&label=context-meter&style=flat-square" alt="context-meter version"></a> <a href="https://github.com/T-AI-Labs/claude-code-mods/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FT-AI-Labs%2Fclaude-code-mods%2Fmain%2Fusage-limits%2F.claude-plugin%2Fplugin.json&query=%24.version&prefix=v&label=usage-limits&style=flat-square" alt="usage-limits version"></a> <a href="LICENSE"><img src="https://img.shields.io/github/license/T-AI-Labs/claude-code-mods?style=flat-square" alt="License"></a>

Installation

Add the marketplace once, then install the mods you want with the first command in their row of the Mods table. To update, run the second lines: the marketplace first, then each mod. The commands work in any shell, or inside Claude Code with /plugin in place of claude plugin. New sessions load the changes.

claude plugin marketplace add T-AI-Labs/claude-code-mods
claude plugin marketplace update T-AI-Labs

The mods use Claude Code's function-hook plugin API, which is in early access and may change between releases. They are built and tested against Claude Code 2.1.295, the engine in the Claude desktop app 2.31226.1.

Mods

context-usage already contains context-meter and usage-limits: install either it or those two, not both.

<table> <tr><th>Mod</th><th>Description</th><th width="35%">Preview</th></tr> <tr><td><a href="#context-usage">context&#8209;usage</a></td><td>

Start here. The context fill with the auto-compact threshold, Compact and Clear, and the 5-hour and weekly limits beneath it.

claude plugin install context-usage@T-AI-Labs
claude plugin update context-usage@T-AI-Labs

</td><td><img src=".docs/context-usage.svg" alt="The context-usage rows" width="320"></td></tr> <tr><td><a href="#context-meter">context&#8209;meter</a></td><td>

The context row of context-usage on its own.

claude plugin install context-meter@T-AI-Labs
claude plugin update context-meter@T-AI-Labs

</td><td><img src=".docs/context-meter.svg" alt="The context-meter row" width="320"></td></tr> <tr><td><a href="#usage-limits">usage&#8209;limits</a></td><td>

The usage row of context-usage on its own.

claude plugin install usage-limits@T-AI-Labs
claude plugin update usage-limits@T-AI-Labs

</td><td><img src=".docs/usage-limits.svg" alt="The usage-limits row" width="320"></td></tr> <tr><td><a href="#cache-meter">cache&#8209;meter</a></td><td>

How much of each turn the prompt cache served and how long it stays warm, with a switch that keeps it warm while you are away.

claude plugin install cache-meter@T-AI-Labs
claude plugin update cache-meter@T-AI-Labs

</td><td><img src=".docs/cache-meter.svg" alt="The cache-meter row" width="320"></td></tr> <tr><td><a href="#catalog-pane">catalog&#8209;pane</a></td><td>

A pane listing every skill, command, agent, mod, plugin, settings hook, MCP server and tool, with usage, token cost and buttons to use or manage each one.

claude plugin install catalog-pane@T-AI-Labs
claude plugin update catalog-pane@T-AI-Labs

</td><td><img src=".docs/catalog-pane.svg" alt="The catalog pane" width="320"></td></tr> </table>

context-usage

context-meter and usage-limits in one mod: the context row and the usage row beneath it. Both work as described under context-meter and usage-limits. To switch from the two separate mods, install context-usage, uninstall context-meter and usage-limits, and pick the threshold again.

Usage

The rows sit in the band above the prompt and cost no tokens: they only read figures Claude Code already has. In the terminal, ctrl+x tab moves into the band: Tab walks the controls, Enter presses a button, the arrow keys pick a threshold. ctrl+x ctrl+a or the band's [-] mark collapses it.

Options

OptionValuesDefaultEffect
displaygauge, textgaugegauge draws a five-segment gauge before each percentage; text leaves it out.
detailstrue, falsetrueShows the figures in parentheses.
usagePositionbelow, abovebelowPuts the usage row under or on top of the context row.
'{"display":"text","usagePosition":"above"}' | claude plugin configure context-usage@T-AI-Labs --values-stdin

That is PowerShell; in cmd, use echo {"display":"text"} | …. Options you leave out keep their value, the command without --values-stdin shows what is set, and a new session picks up the change. --config display=text sets an option while installing, and in a terminal session the options are rows of the /config menu.

context-meter

ElementWhat it shows
ContextFill of the context window, with tokens used and window size. Yellow within 15 points of the threshold, red at it; with Auto off, the same against 100 %.
AutoThe fill at which the mod compacts on its own: Off, 97, 90, 70, 60 or 50 %. Off leaves it to you and to Claude Code's built-in auto-compaction. Kept across sessions.
CompactRuns /compact now.
ClearRuns /clear.

Usage

The row sits in the band above the prompt and costs no tokens: it only reads figures Claude Code already has. In the desktop app it is two lines high so the app's taller buttons fit. In the terminal, ctrl+x tab moves into the band: Tab walks the controls, Enter presses a button, the arrow keys pick a threshold. ctrl+x ctrl+a or the band's [-] mark collapses it.

Until the first response of a session, and again after a clear, the fill reads 0%: the engine counts the system prompt and tools only once a response arrives.

Options

OptionValuesDefaultEffect
displaygauge, textgaugegauge draws a five-segment gauge before the percentage; text leaves it out.
detailstrue, falsetrueShows the figures in parentheses.
'{"display":"text","details":"false"}' | claude plugin configure context-meter@T-AI-Labs --values-stdin

Set them as for context-usage. The row needs about 62 columns with the defaults; on a narrower window the buttons wrap to a second line. details off saves about 11 columns, display set to text about 6:

How auto-compact works

After each turn the mod compares the fill with the threshold and runs /compact once it is reached. It fires again only after the fill has dropped below the threshold, so a compaction that lands above it does not loop. Claude Code's built-in auto-compaction still runs at its own limit, so a threshold above that limit never fires.

Every compaction costs tokens, whether you press Compact or the threshold triggers it: /compact is a model request that summarizes the conversation, and the next turn starts on a cold cache. To keep usage down, leave the threshold high and compact by hand when it suits you.

usage-limits

A gauge for each rate-limit window, with the percentage used and the time until it resets: 5h for the 5-hour limit, Week for the weekly one. Yellow from 75 %, red from 90 %.

Usage

The row sits in the band above the prompt and costs no tokens. ctrl+x ctrl+a or the band's [-] mark collapses it in the terminal.

Claude Code reports the limits only on a subscription plan, with each response. Until the first one, and right after a /clear, the row shows the last reading, with a window that has reset since at 0 %. A window that never had a reading shows –.

Sessions running side by side share their readings through a file on your machine, once a minute and at no token cost, so an idle session still shows what the others used. context-usage and usage-limits keep separate stores and do not share with each other.

Options

OptionValuesDefaultEffect
displaygauge, textgaugegauge draws a five-segment gauge before each percentage; text leaves it out.
detailstrue, falsetrueShows the reset times in parentheses.
'{"display":"text"}' | claude plugin configure usage-limits@T-AI-Labs --values-stdin

Set them as for context-usage. Give the row mods the same display and details to keep their columns aligned.

cache-meter

ElementWhat it shows
CacheShare of the last turn's input tokens served from the prompt cache, with tokens read and total input. Yellow below 40 %; – until the first response and after a clear.
warm / coldHow long the cache stays valid: five minutes after the last request starts, or an hour once the session has used the hour-long cache. cold means the next turn writes the whole context again at full price, the cheapest moment to compact or clear.
Keep warmOff by default. Refreshes the cache shortly before it lapses, for up to keepWarmMinutes after the last turn, and counts the refreshes. Stops when a refresh finds the cache already gone.

Usage

The row sits in the band above the prompt and costs no tokens; only Keep warm's refreshes are model requests. Keep warm is a text link in the desktop app and a button elsewhere. In the terminal, ctrl+x tab moves into the band, Tab walks the controls and Enter presses one. ctrl+x ctrl+a or the band's [-] mark collapses it.

Before 0.4.0 cache-meter also showed the context fill, threshold, Compact and Clear. They moved to context-meter, which an update does not install: install it and pick the threshold again.

Options

OptionValuesDefaultEffect
displaygauge, textgaugegauge draws a five-segment gauge before the percentage; text leaves it out.
detailstrue, falsetrueShows the figures in parentheses.
keepWarmMinutes15, 30, 60, 12060How long after the last turn Keep warm goes on refreshing.
'{"keepWarmMinutes":"120"}' | claude plugin configure cache-meter@T-AI-Labs --values-stdin

Set them as for context-usage.

Why the hit rate matters

Every turn sends the whole conversation again. Cached tokens cost about a tenth of the input price, a twentieth on Claude Opus 5.5; writing them to the cache costs 1.25 times the input price. The cache lapses after a pause, on a model switch, and when something early in the context changes, such as CLAUDE.md or the tools.

What Keep warm costs

Each refresh reads the cached context once at the cache price, plus a one-word reply. With 200k tokens on Claude Opus 5.5 that is about $0.04, against about $1.00 for writing the context again after it went cold. At one refresh every four and a half minutes, an hour costs about half a rewrite: worth it if you come back, lost if you don't. On a subscription the refreshes count against the usage limits.

catalog-pane

A pane with one tab per category: Skills, Commands, Agents, Mods, Plugins, Hooks (from the settings files), MCP servers and built-in Tools.

Usage

/catalog opens the pane, in the desktop app and in the terminal; /catalog mods opens a category, /catalog <text> a search. Each row shows the entry's origin, how often it was used in total and in the last 30 days, and for plugin parts the tokens it adds to every session. Usage is counted from the install of the mod on. On the desktop you can filter by text and origin and sort:

SortOrder
Most used, Recently used, NameBy usage, or alphabetically.
Clean-upCostly and unused entries first.
GitHub stars, Trending, GitHub forks, Latest GitHub pushBy the plugin's repository; Trending is stars gained per month.
Installs, Newest installedBy the official directory's install count, or by install date.

Pressing an entry opens its detail: usage over 7 and 30 days, token cost, version and install dates, what a mod hooks and calls, the repository and the full description. Explain with Haiku sums up in three sentences what the entry is for. The buttons depend on the kind: insert or run a skill or command, insert an agent, MCP server or tool into the prompt, update, disable or uninstall a plugin or mod, remove a local MCP server. Uninstalling and removing ask first.

Options

OptionValuesDefaultEffect
languageany language nameEnglishThe language Explain with Haiku answers in.
githubStatstrue, falsetrueFetches the GitHub stats of each plugin's repository once a day.
'{"language":"German"}' | claude plugin configure catalog-pane@T-AI-Labs --values-stdin

Set them as for context-usage.

Network and model requests

  • GitHub: once a day, the public API for each plugin repository's stars, forks, open issues and last push. Off with githubStats.
  • Haiku: one request of at most 400 output tokens per Explain with Haiku. The answer is kept, so each entry is explained once.
  • Claude Code CLI: claude plugin details once per plugin version for its token cost, claude plugin validate once per mod version, and update, disable, enable or uninstall when you press those buttons.

Everything else comes from Claude Code and the configuration files, and is kept in the mod's own store.

License

MIT

Source 2 files
hooks/register.tsx 332 lines
1import { atom, read, update } from 'claude-code'
2import type {
3  Color,
4  Elements,
5  EngineInterface,
6  ModelUsage,
7  Register,
8} from 'claude-code'
9
10import type { CacheHit } from '../types'
11
12const MINUTE = 60_000
13const SHORT_TTL_MS = 5 * MINUTE
14const LONG_TTL_MS = 60 * MINUTE
15const TTL_KEY = 'ttlMs'
16const TICK_MS = 1000
17// A refresh starts this long before the entry would lapse; the TTL counts from the start of a request.
18const LEAD_MS = 40_000
19const GRACE_MS = 30_000
20const LAPSED_SHARE = 0.5
21const REFRESH_PROMPT = 'Reply with the single word OK.'
22
23// Shared with cache-meter, context-meter and usage-limits so the gauges of all rows line up.
24const LABEL_WIDTH = 7
25const SEGMENTS = 5
26const PERCENT_WIDTH = 4
27const DETAIL_WIDTH = 10
28
29type Tags = Pick<Elements['terminal'], 'Box' | 'Text'>
30type Layout = { hasGauge: boolean; hasDetails: boolean }
31
32const KEEP_WARM_URL = 'https://cache-meter.invalid/keep-warm'
33
34const cache = atom({ plugin: 'cache-meter', key: 'cache' } as const, null)
35const warmth = atom({ plugin: 'cache-meter', key: 'warmth' } as const, {
36  sentAt: null,
37  ttlMs: SHORT_TTL_MS,
38})
39const keepWarm = atom({ plugin: 'cache-meter', key: 'keepWarm' } as const, {
40  isOn: false,
41  until: null,
42  refreshes: 0,
43})
44const now = atom({ plugin: 'cache-meter', key: 'now' } as const, 0)
45
46const tokens = (count: number) => {
47  const thousands = Math.round(count / 1000)
48
49  if (count < 1000) {
50    return String(count)
51  }
52
53  return thousands < 1000
54    ? `${thousands}k`
55    : `${Number((count / 1_000_000).toFixed(1))}M`
56}
57
58const clockText = (duration: number) => {
59  const seconds = Math.max(0, Math.ceil(duration / 1000))
60
61  return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`
62}
63
64const hitOf = (usage: ModelUsage): CacheHit | null => {
65  const read = usage.cache_read_input_tokens
66  const total = usage.input_tokens + read + usage.cache_creation_input_tokens
67
68  return total > 0 ? { read, total } : null
69}
70
71const cacheTone = (percent: number): Color | undefined =>
72  percent < 40 ? 'warning' : undefined
73
74const meter = (
75  { Box, Text }: Tags,
76  layout: Layout,
77  hit: CacheHit | null,
78) => {
79  const percent = hit === null ? null : (hit.read / hit.total) * 100
80  const tone = cacheTone(percent ?? 100)
81  const filled =
82    percent === null
83      ? 0
84      : Math.max(0, Math.min(SEGMENTS, Math.round((percent / 100) * SEGMENTS)))
85
86  return (
87    <Box flexDirection="row" flexShrink={0}>
88      <Box minWidth={LABEL_WIDTH} marginRight={1} flexShrink={0}>
89        <Text dimColor>Cache</Text>
90      </Box>
91      {layout.hasGauge && (
92        <Box minWidth={SEGMENTS} marginRight={1} flexShrink={0}>
93          <Text color={tone}>{'▮'.repeat(filled)}</Text>
94          <Text dimColor>{'▯'.repeat(SEGMENTS - filled)}</Text>
95        </Box>
96      )}
97      <Box
98        minWidth={PERCENT_WIDTH}
99        marginRight={1}
100        flexShrink={0}
101        justifyContent="flex-end"
102      >
103        <Text color={percent === null ? 'inactive' : tone}>
104          {percent === null ? '–' : `${Math.round(percent)}%`}
105        </Text>
106      </Box>
107      {layout.hasDetails && (
108        <Box minWidth={DETAIL_WIDTH} marginRight={1} flexShrink={0}>
109          <Text dimColor>
110            {hit === null ? '' : `(${tokens(hit.read)}/${tokens(hit.total)})`}
111          </Text>
112        </Box>
113      )}
114    </Box>
115  )
116}
117
118let limitMs = 60 * MINUTE
119let isWorking = false
120let isRefreshing = false
121let hasRefreshedSinceTurn = false
122
123function stopKeeping($: EngineInterface, why: string) {
124  $.ui.toast(`cache-meter: Keep warm stopped, ${why}.`)
125  void update($, keepWarm, held => ({ ...held, isOn: false, until: null }))
126}
127
128async function refresh($: EngineInterface) {
129  isRefreshing = true
130
131  try {
132    const at = await $.clock.now()
133    const result = await $.model.fork({ prompt: REFRESH_PROMPT })
134
135    if (!result.isAnswered) {
136      if (result.reason !== 'nothing-to-fork') {
137        stopKeeping($, `the refresh failed (${result.reason})`)
138      }
139
140      return
141    }
142
143    const { usage } = result
144    const total = usage.input_tokens + usage.cache_read_input_tokens + usage.cache_creation_input_tokens
145
146    if (total > 0 && usage.cache_read_input_tokens / total < LAPSED_SHARE) {
147      stopKeeping($, 'the cache had already lapsed')
148
149      return
150    }
151
152    hasRefreshedSinceTurn = true
153    await update($, warmth, held => ({ ...held, sentAt: at }))
154    await update($, keepWarm, held => ({ ...held, refreshes: held.refreshes + 1 }))
155  } finally {
156    isRefreshing = false
157  }
158}
159
160async function tick($: EngineInterface) {
161  const at = await $.clock.now()
162  const held = await read($, warmth)
163
164  if (held.sentAt === null || at - held.sentAt > held.ttlMs + TICK_MS * 2) {
165    return
166  }
167
168  await update($, now, () => at)
169  const keep = await read($, keepWarm)
170  const isDue = at >= held.sentAt + held.ttlMs - LEAD_MS && at < held.sentAt + held.ttlMs
171
172  if (keep.isOn && keep.until !== null && at < keep.until && isDue && !isWorking && !isRefreshing) {
173    await refresh($)
174  }
175}
176
177async function toggle($: EngineInterface) {
178  const at = await $.clock.now()
179  const held = await read($, warmth)
180  const isWarm = held.sentAt !== null && at - held.sentAt < held.ttlMs
181
182  await update($, keepWarm, keep =>
183    keep.isOn
184      ? { ...keep, isOn: false, until: null }
185      : { isOn: true, until: isWarm ? at + limitMs : null, refreshes: 0 },
186  )
187}
188
189export const register: Register = (on, options) => {
190  const layout: Layout = {
191    hasGauge: options.display !== 'text',
192    hasDetails: options.details !== false,
193  }
194  limitMs = Number(options.keepWarmMinutes ?? 60) * MINUTE || 60 * MINUTE
195
196  on('session.start', async ($, e, next) => {
197    const learned = await $.store.get(TTL_KEY)
198    const at = await $.clock.now()
199    if (learned === LONG_TTL_MS) {
200      await update($, warmth, held => ({ ...held, ttlMs: LONG_TTL_MS }))
201    }
202
203    await update($, now, () => at)
204    $.clock.every(TICK_MS, () => void tick($))
205
206    return next(e)
207  })
208
209  on('session.end', async ($, e, next) => {
210    if (e.reason === 'clear') {
211      await update($, cache, () => null)
212      await update($, warmth, held => ({ ...held, sentAt: null }))
213      await update($, keepWarm, held => ({ ...held, until: null }))
214    }
215
216    return next(e)
217  })
218
219  on('turn.step', async function* ($, e, next) {
220    if (e.agentId !== undefined || isRefreshing) {
221      return yield* next(e)
222    }
223
224    const at = await $.clock.now()
225    const held = await read($, warmth)
226    const gap = held.sentAt === null ? null : at - held.sentAt
227    const wasRefreshed = hasRefreshedSinceTurn
228    isWorking = true
229    hasRefreshedSinceTurn = false
230    await update($, warmth, before => ({ ...before, sentAt: at }))
231
232    const result = yield* next(e)
233    const usage = result.usage
234    const total =
235      usage === null
236        ? 0
237        : usage.input_tokens + usage.cache_read_input_tokens + usage.cache_creation_input_tokens
238    // A hit after a gap past the short TTL, with no refresh between, shows the session caches for an hour.
239    const isLongTtl =
240      e.index === 0 &&
241      !wasRefreshed &&
242      held.ttlMs === SHORT_TTL_MS &&
243      gap !== null &&
244      gap > SHORT_TTL_MS + GRACE_MS &&
245      usage !== null &&
246      total > 0 &&
247      usage.cache_read_input_tokens / total >= LAPSED_SHARE
248
249    if (isLongTtl) {
250      await update($, warmth, before => ({ ...before, ttlMs: LONG_TTL_MS }))
251      await $.store.set(TTL_KEY, LONG_TTL_MS)
252    }
253
254    return result
255  })
256
257  on('turn.complete', async ($, e, next) => {
258    if (e.agentId === undefined) {
259      isWorking = false
260      const at = await $.clock.now()
261      await update($, keepWarm, keep => (keep.isOn ? { ...keep, until: at + limitMs } : keep))
262
263      const hit = e.usage === undefined ? null : hitOf(e.usage)
264
265      if (hit !== null) {
266        await update($, cache, () => hit)
267      }
268    }
269
270    return next(e)
271  })
272
273  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
274    const below = await next(e)
275
276    if (e.props.hasSurvey) {
277      return below
278    }
279
280    const { Box, Button, Markdown, Text } = $.ui.resolve(e)
281    const hit = await read($, cache)
282    const held = await read($, warmth)
283    const keep = await read($, keepWarm)
284    const at = await read($, now)
285    const left = held.sentAt === null ? null : held.sentAt + held.ttlMs - at
286    const keepLeft = keep.until === null ? null : keep.until - at
287    const keepLabel = !keep.isOn
288      ? 'Keep warm'
289      : keepLeft === null
290        ? 'Keep warm: after next turn'
291        : keepLeft > 0
292          ? `Keeping warm ${Math.ceil(keepLeft / MINUTE)}m · ${keep.refreshes}×`
293          : `Kept warm · ${keep.refreshes}×`
294
295    return (
296      <Box flexDirection="column">
297        <Box flexDirection="row" flexWrap="wrap">
298          {meter({ Box, Text }, layout, hit)}
299          {left !== null && (
300            <Box minWidth={10} marginRight={1} flexShrink={0}>
301              {left > 0 ? (
302                <Text dimColor>warm {clockText(left)}</Text>
303              ) : (
304                <Text color="warning">cold</Text>
305              )}
306            </Box>
307          )}
308          <Box flexDirection="row" flexShrink={0}>
309            {e.surface === 'desktop' ? (
310              // The desktop draws every Button as a full-height control; a Markdown link is drawn at text size.
311              <Markdown
312                key="keep-warm"
313                text={`[${keepLabel}](${KEEP_WARM_URL})`}
314                pressableLinks={[KEEP_WARM_URL]}
315                onLinkPress={() => void toggle($)}
316              />
317            ) : (
318              <Button
319                key="keep-warm"
320                label={keepLabel}
321                variant={keep.isOn ? 'primary' : 'secondary'}
322                onPress={() => void toggle($)}
323              />
324            )}
325          </Box>
326        </Box>
327        {below}
328      </Box>
329    )
330  })
331}
332
types/index.d.ts 17 lines
1export type CacheHit = { read: number; total: number }
2
3export type Warmth = { sentAt: number | null; ttlMs: number }
4
5export type KeepWarm = { isOn: boolean; until: number | null; refreshes: number }
6
7declare module 'claude-code' {
8  interface PluginState {
9    'cache-meter': {
10      cache: CacheHit | null
11      warmth: Warmth
12      keepWarm: KeepWarm
13      now: number
14    }
15  }
16}
17