modscode / Gallery / cache-panel
cache-panel
Passive 50-minute prompt-cache reminder with a keyboard/mouse panel: keep warm, ping once, or compact, with live cost estimates.
What it does
- Draws a band above the prompt, a pane, toasts
- Hooks classic.SessionStart, session.compact, session.measure, session.start and 1 more
- Starts processes
Good points
- No network calls
- Written in TypeScript
- Has a desktop-specific branch
- Handles errors
Code to start from
Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like cache-panel by Dustin Yuchen Teng (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/danyuchn-cache-panel/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Button } = $.ui.resolve(e)
const label = '…'
return (
<Box flexDirection="column">
<Button label={`${label}`} />
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Cache" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Input, Button } = $.ui.resolve(e)
const id = '…'
const fmtK = '…'
const cacheText = '…'
const quota = '…'
const guess = '…'
const DEFAULT_HOURS = '…'
const typed = '…'
const line = '…'
const line2 = '…'
const line3 = '…'
const lastNote = '…'
const advice = '…'
const fmtDur = '…'
const pings = '…'
const fmtHours = '…'
return (
<Box flexDirection="column">
<Box flexDirection="column">
<Text bold>
{`${id} · ctx ${fmtK}`}
</Text>
<Text>
{`cache ${cacheText}${quota}${guess}`}
</Text>
</Box>
<Input label="Away (hours)" placeholder={`${DEFAULT_HOURS}`} value={`${typed}`} submitLabel="warm" />
<Text>
{line}
</Text>
<Text>
{line2}
</Text>
<Text>
{line3}
</Text>
<Text dimColor>
{lastNote}
</Text>
<Text>
{advice}
</Text>
<Button label={`Stop warm (${fmtDur} left, ${pings} ping)`} autoFocus />
<Button label={`Keep warm ${fmtHours}`} autoFocus />
<Button label="Ping once (+1h)" />
<Button label="Compact now" />
<Button label="Dismiss" autoFocus />
</Box>
)
})
on('session.start', async ($, e, next) => {
await $.ui.toast(`Keep-warm ended`)
await $.ui.toast(`Keep-warm stopped`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
cache-panel/hooks/register.tsx lines 355–382 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const w = await read($, warm)
const now = await read($, nowAt)
const last = await read($, lastRequestAt)
const reminding = await read($, isReminding)
const showReminder = w === null && reminding && last > 0 && now - last < TTL_MS
if (e.props.hasSurvey || (w === null && !showReminder)) return next(e)
const below = await next(e)
const { Box, Button } = $.ui.resolve(e)
const short = e.props.bodyColumns < 40
const label =
w !== null
? `warm ${fmtDur(w.deadline - now)}`
: short
? `cache ${fmtDur(last + TTL_MS - now)}`
: `cache cools in ${fmtDur(last + TTL_MS - now)}`
const mine = <Button key="open" label={label} onPress={() => void openPanel($)} />
return below ? (
<Box flexDirection="column">
{mine}
{below}
</Box>
) : (
mine
)
})cache-panel/hooks/register.tsx lines 384–471 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
// Text fields exist in the terminal and the Desktop app only.
if (e.surface !== 'terminal' && e.surface !== 'desktop') return next(e)
const { Box, Text, Button, Input } = $.ui.resolve(e)
const s = await read($, snap)
const now = await read($, nowAt)
const last = await read($, lastRequestAt)
const w = await read($, warm)
const typed = await read($, hoursText)
const lastNote = await read($, note)
const price = priceOf(s.model)
const basis = s.hasLimits ? 'subscription' : 'api'
const parsed = parseHours(typed)
const hours = parsed ?? DEFAULT_HOURS
const isCold = last > 0 && now - last >= TTL_MS
const plan = makePlan({ ctx: s.ctx, price, basis, hours, lastReq: last, now, isWarm: !isCold })
// Short enough to fit above the prompt, so the arrow keys move focus and do not scroll.
const narrow = e.props.bodyColumns < 44
const cacheText = isCold
? `cold ${fmtDur(now - last - TTL_MS)}`
: last > 0
? `${fmtDur(last + TTL_MS - now)} left`
: 'no request'
const quota = s.fiveHour !== null ? ` · 5h ${s.fiveHour}%` : ''
const guess = price.isGuess ? ' · guessed' : ''
let advice: string
if (parsed === null) advice = `Hours: 0 to ${MAX_HOURS}`
else if (isCold) advice = 'Cache is cold: just send.'
else if (s.ctx < thresholdTokens(price)) advice = 'Small context: do nothing.'
else advice = narrow ? `Best: ${pickLabel(plan.recommended)}` : `Best: ${pickLabel(plan.recommended)} (warm wins to ~${plan.breakEvenHours.toFixed(1)}h)`
const legend = basis === 'subscription' ? '~ token-equiv (plan) · $ API price' : '~ token-equiv · $ API price'
return (
<Box flexDirection="column">
{narrow ? (
<Box flexDirection="column">
<Text bold>{`${price.id} · ctx ${fmtK(s.ctx)}`}</Text>
<Text>{`cache ${cacheText}${quota}${guess}`}</Text>
</Box>
) : (
<Text bold>{`${price.id} · ctx ${fmtK(s.ctx)} · cache ${cacheText}${quota}${guess}`}</Text>
)}
<Input
key="hours"
label="Away (hours)"
placeholder={String(DEFAULT_HOURS)}
value={typed}
submitLabel="warm"
onInput={(v: string) => void update($, hoursText, () => v)}
onSubmit={(v: string) => {
const h = parseHours(v)
if (h === null) $.ui.toast(`Enter hours between 0 and ${MAX_HOURS}`, { timeoutMs: TOAST_MS })
else void startWarm($, h)
}}
/>
{optionRows(plan, !isCold, narrow).map(line => (
<Text>{line}</Text>
))}
{!narrow && <Text dimColor>{lastNote !== '' ? lastNote : legend}</Text>}
<Text>{advice}</Text>
{w !== null && (
<Button
key="stop"
label={`Stop warm (${fmtDur(w.deadline - now)} left, ${w.pings} ping${w.pings === 1 ? '' : 's'})`}
autoFocus
onPress={() => void endWarm($, 'stopped')}
/>
)}
{w === null && !isCold && (
<Button
key="warm"
label={`Keep warm ${fmtHours(hours)}`}
autoFocus
onPress={() => {
if (parsed === null) $.ui.toast(`Enter hours between 0 and ${MAX_HOURS}`, { timeoutMs: TOAST_MS })
else void startWarm($, parsed)
}}
/>
)}
{!isCold && <Button key="once" label="Ping once (+1h)" onPress={() => void doPing($, 'once')} />}
<Button key="compact" label="Compact now" onPress={() => void $.clock.after(50, () => void compactNow($))} />
{isCold && <Button key="close" label="Dismiss" autoFocus onPress={() => void $.ui.close({ id: PANE })} />}
</Box>
)
})Licence text (MIT)
MIT License Copyright (c) 2026 Dustin Yuchen Teng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
What its code calls
runs programsenv varsdrives Claude
The design, read from code
Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.
What its code shows
Read from the source at commit 9e7d228f7953 on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.cache-panel/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.2 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.cache-panel/hooks/register.tsx:74 a program named at run time |
| Reads and sends | Whether it both reads files or environment variables and reaches the network.reaches no network |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add danyuchn/claude-mods/plugin install cache-panel@dustin-modsThis installs the marketplace's latest commit, which may not be the one read here (9e7d228f7953). Compare them before you install.
Ask Claude about it
With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:
Read the modscode design "danyuchn-cache-panel" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
slop Edit1 of 3accepteditrejectAsk Claude…
-
Ask Claude…Skins0 Your promptadd rate limiting to the hub api0 Tool rows: finished, running, failedYour prompt Spinner0 Folded group of reads and searches●main · note 3 · note 3 · note 30 Edit diff cardDesktop only; the terminal keeps Claude Code's diff.0 Shell output cardDesktop only.0 Code block cardDesktop only; the terminal keeps Claude Code's markdown.0 TableAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopy0 SpinnerAccent SpinnerSpinnerSpinner… 2h 10m0 Band above the prompt: normal, then nudging to compact█████░░░ 42% build█████░░░ 42% build█████░░░ 42% buildContext is 42% full0 Compact now0 Band above a questionTable BashBashBash0 Turn footer (terminal)3 build in 2h 10m · Grep · +3 −3
-
Ask Claude…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
Ask Claude…Fanyi settingsOnAPI · OpusenOn this MacAPIHost src/ SaveKey K · paste a new one, Enter SaveOpus↻ RefreshCustom model model id, for an API that lists none UseFanyi settingsHostClose
-
Ask Claude…Glossary BrowserGlossary openContextsContextsContexts▲ prevWrite1/Glossary▼ nextContexts