modscode / Gallery / long-live-the-claude
long-live-the-claude
Keeps long-running Claude Code sessions alive: a usage band above the prompt, prompt-cache keep-alive across idle gaps, and a graceful pause at 95% of the 5-hour limit that wakes the session when it resets.
What it does
- Draws a band above the prompt, toasts
- Adds /long-run
- Watches tool calls
- Hooks classic.PostCompact, classic.PostModelSwitch, prompt.submit, session.end and 6 more
- Keeps its own state between turns
Good points
- No network calls
- Starts no processes
- Written in TypeScript
- Writes no files
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 long-live-the-claude by Lapis0x0 (band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/lapis0x0-long-live-the-claude/
// 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, Text, Client, Button } = $.ui.resolve(e)
const rest = '…'
const d = '…'
const d2 = '…'
const d3 = '…'
const d4 = '…'
const d5 = '…'
const d6 = '…'
const k = '…'
const d7 = '…'
const d8 = '…'
const d9 = '…'
const d10 = '…'
const d11 = '…'
const d12 = '…'
const pauseBadge = '…'
const d13 = '…'
const d14 = '…'
const d15 = '…'
return (
<Box flexDirection="column">
<Box alignItems="flex-start">
<Box position="relative" flexGrow={1} flexShrink={1} minWidth={0} paddingRight={3} columnGap={3} alignItems="flex-start">
<Box gap={1} alignItems="flex-start" flexShrink={0}>
<Box>
<Text dimColor>
5h
</Text>
</Box>
<Box flexDirection="column" flexShrink={1} minWidth={0}>
<Box gap={1} alignItems="center">
<Text color="error">
▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱
</Text>
<Text>
{`${rest}%`}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{d}
</Text>
<Text dimColor wrap="truncate-end">
{d2}
</Text>
<Text dimColor wrap="truncate-end">
{d3}
</Text>
</Box>
</Box>
<Box gap={1} alignItems="flex-start" flexShrink={0}>
<Box>
<Text dimColor>
7d
</Text>
</Box>
<Box flexDirection="column" flexShrink={1} minWidth={0}>
<Box gap={1} alignItems="center">
<Text color="error">
▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱
</Text>
<Text>
{`${rest}%`}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{d4}
</Text>
<Text dimColor wrap="truncate-end">
{d5}
</Text>
<Text dimColor wrap="truncate-end">
{d6}
</Text>
</Box>
</Box>
<Box gap={1} alignItems="flex-start" flexShrink={0}>
<Box flexDirection="column" flexShrink={1} minWidth={0}>
<Box gap={1} alignItems="center">
<Text dimColor>
ctx
</Text>
<Text>
{`${k} / ${k}`}
</Text>
</Box>
<Text dimColor wrap="truncate-end">
{d7}
</Text>
<Text dimColor wrap="truncate-end">
{d8}
</Text>
<Text dimColor wrap="truncate-end">
{d9}
</Text>
</Box>
</Box>
<Box gap={1} alignItems="flex-start" flexShrink={0}>
<Box flexDirection="column" flexShrink={1} minWidth={0}>
<Text dimColor wrap="truncate-end">
{d10}
</Text>
<Text dimColor wrap="truncate-end">
{d11}
</Text>
<Text dimColor wrap="truncate-end">
{d12}
</Text>
</Box>
</Box>
<Box position="absolute" top={0} left={0} right={0} bottom={0}>
<Client module="./click-probe.tsx" width="100%" height="100%" />
</Box>
</Box>
<Box gap={1} alignItems="center" flexShrink={0}>
<Box flexShrink={1} minWidth={0}>
<Text color="warning" wrap="truncate-end">
{pauseBadge}
</Text>
</Box>
<Box flexShrink={1} minWidth={0}>
<Text color="warning" wrap="truncate-end">
Retrying
</Text>
</Box>
<Box flexShrink={0}>
<Text dimColor>
Refreshing…
</Text>
</Box>
<Button label="Long run ✓" />
</Box>
</Box>
<Box columnGap={3} flexWrap="wrap" display="none">
<Text dimColor>
{d13}
</Text>
<Text dimColor>
{d14}
</Text>
<Text dimColor>
{d15}
</Text>
</Box>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const hhmm = '…'
const drop = '…'
await $.ui.toast(`Long run: paused, resumes at ${hhmm}`)
await $.ui.toast(`Long run: wake-up not delivered (${drop}); retrying in 1 minute`)
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.
hooks/register.tsx lines 920–924 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey) return next(e)
return drawBand($, e)
})hooks/register.tsx lines 429–588 · Band
async function drawBand($: Engine, e: ResolveInput) {
const els = $.ui.resolve(e)
const { Box, Button, Text } = els
const Svg = 'Svg' in els ? els.Svg : undefined
const t = (await read($, now)) || Date.now()
const list = await read($, limits)
const hit = await read($, lastHitAt)
const w = await read($, warm)
const lr = await read($, longRun)
const ctx = await read($, context)
const isIdleTooLong = w.lastTurnAt !== null && t - w.lastTurnAt > IDLE_CAP_MS
// Keep-alive is actually working: long-run mode on, not stopped, not idle too long
const isWarming = lr.isOn && !w.isBroken && !isIdleTooLong
const five = list.find(x => x.kind === 'five_hour')
const week = list.find(x => x.kind === 'seven_day')
const left = hit === null ? null : hit + TTL_MS - t
// The ring's color: first whether the cache is near expiry or expired, then whether keep-alive
// is failing; otherwise the keep-alive color while it is on
const cacheTone =
left === null
? MUTED
: left <= 0
? DANGER
: left <= LEAD_MS
? WARN
: isWarming && w.isFailing
? WARN
: isWarming
? WARM
: OK
const dot = isWarming ? (w.isFailing ? WARN : WARM) : null
// SVG on the desktop, characters in the terminal
const meter = (pct: number, label: string, mark?: number) =>
Svg ? (
<Svg source={barSvg(pct, mark)} alt={label} width={BAR_W} height={BAR_H} />
) : (
<Text color={pct <= 20 ? 'error' : undefined} dimColor={pct > 20}>
{barText(pct)}
</Text>
)
const k = (n: number) => (n >= 1e6 ? `${Math.round(n / 1e5) / 10}M` : `${Math.round(n / 1000)}k`)
// ---- Main row: the standing readings and the buttons; its width does not change when expanded ----
const usage = (name: string, win: RateWindow) => {
// Shows what is left; percentUsed has at most one decimal and exceeds 100 past the limit
const rest = Math.max(0, Math.round((100 - win.percentUsed) * 10) / 10)
const resetIn = win.resetsAt === undefined ? null : Date.parse(win.resetsAt) - t
const p = resetIn === null ? null : project(win.kind, win.percentUsed, resetIn)
return (
<Box gap={1} alignItems="center">
{meter(rest, `${name} ${rest}% left`, p === null ? undefined : Math.max(0, p.restAtReset))}
<Text bold={rest <= 20}>{`${rest}%`}</Text>
</Box>
)
}
// Context against the compaction window (the same basis as /context's percentage), with no bar:
// it answers "how far from auto-compaction", not "how much is left"
const contextText = (c: ContextState & { tokens: number }) => {
const used = c.tokens / c.limit
const tone = used >= CONTEXT_DANGER ? 'error' : used >= CONTEXT_WARN ? 'warning' : undefined
return (
<Box gap={1} alignItems="center">
<Text dimColor>ctx</Text>
<Text color={tone} bold={tone === 'error'}>{`${k(c.tokens)} / ${k(c.limit)}`}</Text>
</Box>
)
}
const cacheText = left === null ? '—' : left > 0 ? countdown(left) : 'expired'
// ---- Details: click the band to expand. Where the surface has Client each detail sits right below
// its reading; elsewhere they fall back to a row of their own ----
const resetLines = (win: RateWindow) => {
if (win.resetsAt === undefined) return []
const resetIn = Date.parse(win.resetsAt) - t
const p = project(win.kind, win.percentUsed, resetIn)
// The bar's translucent part already shows what is projected to be left; here we only warn when it runs out early
return [`resets in ${roughly(resetIn)}`, p?.runsOutIn != null ? `runs out in ~${roughly(p.runsOutIn)}` : null]
}
// Long-run pause: a short badge in the main row
const wakeAt = lr.resetsAt === null ? null : lr.resetsAt + WAKE_DELAY_MS
const pauseBadge =
!lr.isOn || wakeAt === null
? null
: lr.phase === 'winding'
? 'Winding down'
: lr.phase === 'paused'
? `Paused · resumes ${hhmm(wakeAt)}${lr.held.length > 0 ? ` · ${lr.held.length} held` : ''}`
: null
// The details below the cache column: two lines at most, each truncated rather than wrapped, so
// they never push the buttons out
const held = lr.held.length
const keeperLines: (string | null)[] = !lr.isOn
? [w.note]
: lr.phase === 'winding' && wakeAt !== null
? [`Winding down · ${lr.isReminded ? 'model asked to wrap up' : 'asks at the next tool call'} · resumes ${hhmm(wakeAt)}`]
: lr.phase === 'paused' && wakeAt !== null
? [`Paused · resumes in ${roughly(wakeAt - t)} (${hhmm(wakeAt)})`, `${held} notification${held === 1 ? '' : 's'} held`]
: w.isBroken || w.isFailing
? [w.note]
: isIdleTooLong
? [`Idle over ${IDLE_CAP_MS / 3600_000}h, stopped`, 'resumes at the next request']
: hit === null
? ['Waiting for the next request']
: [`${lr.isIdle ? '[idle] · keep-alive only' : 'no [idle] · check-ins'} · kept warm ${w.count}×`, w.note]
const compactLine = ctx?.tokens !== undefined ? `${k(Math.max(0, ctx.compactAt - ctx.tokens))} to auto-compact` : null
const isText = (x: unknown): x is string => typeof x === 'string' && x !== ''
// Where the surface has Client, a transparent click probe covers the area left of the buttons:
// a click anywhere toggles the details. Without Client there are no clicks, so we fall back to
// the host's hover: hovering the band shows the details row.
// The probe must not cover the buttons: a probe layered above eats the button's click, and no
// positioning order wins over it
const Client = 'Client' in els ? els.Client : undefined
const isExpanded = await read($, expanded)
const probe = (key: string) =>
Client ? (
<Box position="absolute" top={0} left={0} right={0} bottom={0}>
<Client key={key} module="./click-probe.tsx" props={{ zone: 'band' }} width="100%" height="100%" />
</Box>
) : null
// One column: the standing reading on top and, when expanded, its details below.
// 5h and 7d pass a label: it stands on its own at the left (top-aligned, on the reading's line)
// and the details line up with the bar; ctx and cache pass none: the label is part of the
// reading and the details start at the column's left edge.
// The first three columns' details are no wider than their readings, so expanding does not shift
// the main row; the last column (cache and long run) may shrink and truncate instead of pushing the buttons
type El = ReturnType<typeof usage>
const column = (key: string, label: El | null, main: El, lines: unknown[], isLast = false) => {
const shown = Client && isExpanded ? lines.filter(isText) : []
const body = (
<Box key={`${key}-body`} flexDirection="column" flexShrink={isLast ? 1 : 0} minWidth={isLast ? 0 : undefined}>
{main}
{shown.map((d, i) => (
<Text key={`${key}-${i}`} dimColor wrap={isLast ? 'truncate-end' : undefined}>
{d}
</Text>
))}
</Box>
)
if (label === null) return body
return (
<Box key={key} gap={1} alignItems="flex-start" flexShrink={0}>
{label}
{body}
</Box>
)
}Licence text (MIT)
MIT License Copyright (c) 2026 Lapis0x0 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
drives Claudetool callsremembers
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 d0b535134857 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.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.starts no programs |
| 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 Lapis0x0/long-live-the-claude/plugin install long-live-the-claude@long-live-the-claudeThis installs the marketplace's latest commit, which may not be the one read here (d0b535134857). 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 "lapis0x0-long-live-the-claude" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…Timer● MonAprNo timer runningStopResume last CollapseFri week./meter.tsxUnbilled Wed h$1.24 · expenses MarMayToday, Oct 6This week
-
Ask Claude…Notes⚠ A team of Never uses your Claude usage much faster.Showing:buildbuildbuildHide completed:buildbuildbuildSet team size:DefaultDefaultDefaultSet model:NotesNotesNotesWorkflowYour next prompt can hand work to Never Notes helpers.● Fix login · Tool agents42% AllCopy failed2h 10m● Fix login · Tool agents42% AllCopy failed2h 10m● Fix login · Tool agents42% AllCopy failed2h 10m
-
Open a file first: /crit-tui file <path>Reopen this one in the crit browser view.Ask Claude…
-
Auto compact%System tools Compact▲Context is already at 42%, past Weekly%. Auto compact:NowAfter my next compactOnly in new chatsUsage limits show after the first reply.Auto compactToolsbuild42%Toolsbuild42%Toolsbuild42%Context12.4 free of 12.4k42% usedbuild12.4kbuild12.4kbuild12.4kAsk Claude…claude-code-usage-quota: Compact
-
spending-effort-with-jev: no TypeSafe API key, so effort tips are off. Set it in /plugin.⚠ effort: long run, fuzzy spec → have Claude interview you, then go maxAsk Claude…
-
✦ explain as pick how Claude answers×3 ● build3 ● build3 ● build▸ VideoAsk Claude…