modscode JA

modscode / Gallery / session-hud

session-hud

Session Tracker above the prompt box: context window with a /compact recommendation, 5-hour plan limit, prompt clocks and session cost.

Code you can checkTerminal + desktopBandToastBoxText

What it does

  • Draws a band above the prompt, toasts
  • Watches tool calls
  • Hooks prompt.submit, session.compact, session.start, turn.complete

Good points

  • No network calls
  • Starts no processes
  • Small: 243 lines
  • Written in TypeScript

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)

register.tsx
import type { Register } from 'claude-code'

// Drawn like session-hud by Ofek Levy (band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/ofeklevy11-session-hud/
// 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 } = $.ui.resolve(e)
    return (
      <Box flexDirection="column">
        <Text bold color="blueBright" wrap="truncate">
          ⚡ Session Tracker
        </Text>
        {await next(e)}
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const compactAt = '…'
    const clock = '…'
    await $.ui.toast(`💡 Context passed ${compactAt} tokens: Compact recommended, type /compact`)
    await $.ui.toast(`✅ Turn finished in ${clock}`)
    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.

session-hud/hooks/register.tsx lines 111–222 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const below = await next(e)
    if (e.props.hasSurvey) return below

    const st = await read($, hud)
    const now = await $.clock.now()
    const { Box, Text } = $.ui.resolve(e)
    const W = Math.max(20, (e.props.bodyColumns ?? 80) - 6)

    // Section header: the mod's name
    const header = <Text bold color="blueBright" wrap="truncate">{'⚡ Session Tracker'}</Text>
    const five = st.limits.find(l => l.kind === 'five_hour')

    const ctxLeft = st.ctxTokens === null ? st.ctxWindow : Math.max(0, st.ctxWindow - st.ctxTokens)
    // Two clocks: the prompt running now (or the last one), and every prompt of the session added up
    const total = cleanTotal(st.totalSeconds) + (st.isRunning ? st.turnSeconds : 0)
    // Labels in blue, values in their own color
    const label = (t: string) => <Text bold color="blueBright">{t}</Text>

    // Side-by-side cards: each metric is a small titled column, and the cards wrap with the width
    const bar = (cells: number, pct: number | null) => {
      const p = pct ?? 0
      const filled = Math.max(pct === null ? 0 : 1, Math.min(cells, Math.round((p / 100) * cells)))
      return [
        <Text color={tone(p)}>{'█'.repeat(filled)}</Text>,
        <Text dimColor>{'░'.repeat(Math.max(0, cells - filled))}</Text>,
        <Text bold color={tone(p)}>{pct === null ? ' —' : ` ${Math.round(p)}%`}</Text>,
      ]
    }
    const reset5 = five ? inTime(five.resetsAt, now) : ''
    const card = (width: number, ...rowsOfSpans: any[][]) => (
      <Box flexDirection="column" width={width}>
        {rowsOfSpans.map(spans => <Text wrap="truncate">{spans}</Text>)}
      </Box>
    )
    const isOver = st.ctxTokens !== null && st.ctxWindow > 0 && st.ctxTokens >= compactAt(st.ctxWindow)
    const isHard = isOver && st.ctxTokens !== null && st.ctxTokens >= compactHard(st.ctxWindow)
    // Mods cannot press /compact for you here, so the card tells you what to type
    const compactHint = isOver
      ? <Text bold color={isHard ? 'red' : 'yellow'}>{'👉 Type /compact now'}</Text>
      : null
    const ctxNote = st.ctxTokens === null
      ? <Text dimColor>no data yet</Text>
      : isHard
        ? <Text bold color="red">{`⚠ ${short(st.ctxTokens)} · Compact recommended 300-400K+ (if 1M context window)`}</Text>
        : isOver
        ? <Text color="yellow">{`💡 ${short(st.ctxTokens)} · Compact recommended 300-400K+ (if 1M context window)`}</Text>
        : <Text dimColor>{`${short(ctxLeft)} left of ${short(st.ctxWindow)}`}</Text>
    const ctxCard = (w: number) => (
      <Box flexDirection="column" width={w}>
        <Text wrap="truncate">{label('🧠 Context window')}</Text>
        <Text wrap="truncate">{bar(Math.max(4, w - 6), st.ctxPercent)}</Text>
        <Text wrap="truncate">{ctxNote}</Text>
        {compactHint ? <Text wrap="truncate">{compactHint}</Text> : null}
      </Box>
    )
    const fiveCard = (w: number) => card(w,
      [label('⚡ 5-hour limit')],
      five ? bar(Math.max(4, w - 6), five.percent) : [<Text dimColor>after the first reply</Text>],
      [<Text dimColor>{reset5 ? `↻ ${reset5.replace('resets in ', '')}` : ''}</Text>],
    )
    const timeCard = (w: number) => card(w,
      [label('⏱ Prompt time')],
      [<Text dimColor>{st.isRunning ? 'now  ' : 'last  '}</Text>, <Text bold color={st.isRunning ? 'cyan' : undefined}>{clock(st.turnSeconds)}</Text>],
      [<Text dimColor>{'all   '}</Text>, <Text bold>{clock(total)}</Text>],
    )
    const costCard = (w: number) => card(w,
      [label('💵 Session cost')],
      [<Text bold color="green">{usd(st.costUsd)}</Text>],
      [<Text dimColor>{'this session'}</Text>],
    )
    // One line for the clocks and the cost, used when only two cards fit across
    const statsLine = (
      <Text wrap="truncate">
        {label('⏱ ')}<Text bold color={st.isRunning ? 'cyan' : undefined}>{clock(st.turnSeconds)}</Text>
        <Text dimColor>{st.isRunning ? ' now' : ' last'}</Text>
        <Text dimColor>{'  ·  '}</Text>
        {label('⌛ ')}<Text bold>{clock(total)}</Text><Text dimColor>{' all'}</Text>
        <Text dimColor>{'  ·  '}</Text>
        {label('💵 ')}<Text bold color="green">{usd(st.costUsd)}</Text>
      </Text>
    )

    const GAP = 3
    let rows: any[]
    if (W >= 96) {
      // Wide: four cards in one band
      const w = Math.floor((W - GAP * 3) / 4)
      rows = [<Box flexDirection="row" columnGap={GAP}>{ctxCard(w)}{fiveCard(w)}{timeCard(w)}{costCard(w)}</Box>]
    } else if (W >= 40) {
      // Medium and split view: the two gauges side by side, then one stats line
      const w = Math.floor((W - GAP) / 2)
      rows = [<Box flexDirection="row" columnGap={GAP}>{ctxCard(w)}{fiveCard(w)}</Box>, statsLine]
    } else {
      // Very narrow: one compact line per gauge, then the stats
      const cells = Math.max(4, W - 26)
      rows = [
        <Text wrap="truncate">{label('🧠 ')}{bar(cells, st.ctxPercent)}<Text dimColor>{st.ctxTokens === null ? '' : ` ${short(ctxLeft)} left`}</Text></Text>,
        <Text wrap="truncate">{label('⚡ ')}{five ? bar(cells, five.percent) : <Text dimColor>—</Text>}<Text dimColor>{reset5 ? ` ↻ ${reset5.replace('resets in ', '')}` : ''}</Text></Text>,
        statsLine,
      ]
      if (isOver) rows.push(<Text wrap="truncate" bold color={isHard ? 'red' : 'yellow'}>{'💡 Compact recommended · type /compact'}</Text>)
    }

    return (
      <Box flexDirection="column">
        {header}
        {rows}
        {below}
      </Box>
    )
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 Ofek Levy

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

tool calls

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 c90cb1cd1a60 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 readEvery module hooks/hooks.json names was read.session-hud/hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.1 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo 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 openNetwork 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 drawsThe 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 lineWhether 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 WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether 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 sendsWhether it both reads files or environment variables and reaches the network.reaches no network
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn 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 ofeklevy11/claude-code-hud
/plugin install session-hud@claude-code-hud

This installs the marketplace's latest commit, which may not be the one read here (c90cb1cd1a60). 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 "ofeklevy11-session-hud" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs