modscode JA

modscode / Gallery / session-meter

session-meter

Shows a live session pane (/ctx): context breakdown, usage limits with pace, tool calls and model requests; sends the model a one-time note when limits or context cross a threshold

Code you can checkTerminal + desktopPaneBoxText

What it does

  • Draws a pane
  • Adds /ctx
  • Watches tool calls
  • Hooks prompt.submit, session.measure, session.start, turn.step

Good points

  • No network calls
  • Starts no processes
  • Written in TypeScript
  • 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)

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

// Drawn like session-meter by Mehmet Aras (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/arasovic-session-meter/
// 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 pane: open it with $.ui.open({ id: 'my-pane', title: "Session" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const t = '…'
    const t2 = '…'
    const t3 = '…'
    const right = '…'
    const t4 = '…'
    const t5 = '…'
    const t6 = '…'
    const t7 = '…'
    const t8 = '…'
    const t9 = '…'
    const t10 = '…'
    const t11 = '…'
    const t12 = '…'
    const right2 = '…'
    const t13 = '…'
    const t14 = '…'
    const t15 = '…'
    const t16 = '…'
    const t17 = '…'
    const t18 = '…'
    const t19 = '…'
    const t20 = '…'
    const t21 = '…'
    const running = '…'
    const t22 = '…'
    const t23 = '…'
    const t24 = '…'
    const t25 = '…'
    const t26 = '…'
    const t27 = '…'
    const t28 = '…'
    const t29 = '…'
    const t30 = '…'
    const model = '…'
    const t31 = '…'
    const t32 = '…'
    const t33 = '…'
    const t34 = '…'
    const t35 = '…'
    const t36 = '…'
    const t37 = '…'
    const t38 = '…'
    const t39 = '…'
    return (
      <Box flexDirection="column" paddingTop={1}>
        <Text>
          <Text>
            {t}
          </Text>
          <Text>
            {t2}
          </Text>
          <Text>
            {t3}
          </Text>
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Text>
            <Text dimColor>
              {"╭─ "}
            </Text>
            <Text bold>
              Context
            </Text>
            <Text dimColor>
              {" "}
              ────────
            </Text>
            <Text dimColor>
              {" "}
              {right}
              {" "}
            </Text>
            <Text dimColor>
              ─╮
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t4}
            </Text>
            <Text>
              {t5}
            </Text>
            <Text>
              {t6}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t7}
            </Text>
            <Text>
              {t8}
            </Text>
            <Text>
              {t9}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t10}
            </Text>
            <Text>
              {t11}
            </Text>
            <Text>
              {t12}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text dimColor>
            ╰
            ────────
            ╯
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text>
            <Text dimColor>
              {"╭─ "}
            </Text>
            <Text bold>
              Limits
            </Text>
            <Text dimColor>
              {" "}
              ────────
            </Text>
            <Text dimColor>
              {" "}
              {right2}
              {" "}
            </Text>
            <Text dimColor>
              ─╮
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t13}
            </Text>
            <Text>
              {t14}
            </Text>
            <Text>
              {t15}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t16}
            </Text>
            <Text>
              {t17}
            </Text>
            <Text>
              {t18}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t19}
            </Text>
            <Text>
              {t20}
            </Text>
            <Text>
              {t21}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text dimColor>
            ╰
            ────────
            ╯
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text>
            <Text dimColor>
              {"╭─ "}
            </Text>
            <Text bold>
              Tools
            </Text>
            <Text dimColor>
              {" "}
              ────────
            </Text>
            <Text dimColor>
              {" "}
              {`${running} running`}
              {" "}
            </Text>
            <Text dimColor>
              ─╮
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t22}
            </Text>
            <Text>
              {t23}
            </Text>
            <Text>
              {t24}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t25}
            </Text>
            <Text>
              {t26}
            </Text>
            <Text>
              {t27}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t28}
            </Text>
            <Text>
              {t29}
            </Text>
            <Text>
              {t30}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text dimColor>
            ╰
            ────────
            ╯
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text>
            <Text dimColor>
              {"╭─ "}
            </Text>
            <Text bold>
              Requests
            </Text>
            <Text dimColor>
              {" "}
              ────────
            </Text>
            <Text dimColor>
              {" "}
              {model}
              {" "}
            </Text>
            <Text dimColor>
              ─╮
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t31}
            </Text>
            <Text>
              {t32}
            </Text>
            <Text>
              {t33}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t34}
            </Text>
            <Text>
              {t35}
            </Text>
            <Text>
              {t36}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text>
            <Text dimColor>
              {"│ "}
            </Text>
            <Text>
              {t37}
            </Text>
            <Text>
              {t38}
            </Text>
            <Text>
              {t39}
            </Text>
            <Text dimColor>
              {" │"}
            </Text>
          </Text>
          <Text dimColor>
            ╰
            ────────
            ╯
          </Text>
        </Box>
      </Box>
    )
  })
}

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-meter/hooks/register.tsx lines 286–439 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const b = await read($, breakdown)
    const r = await read($, reading)
    const turns = await read($, history)
    const list = await read($, samples)
    const sent = await read($, notes)
    const calls = await read($, tools)
    const asks = await read($, requests)
    const now = await $.clock.now()
    const w = Math.max(28, e.props.bodyColumns - 1)
    const inner = w - 6
    if (!b) return <Text dimColor>Waiting for the first context reading.</Text>

    const draw = (row: Row, width: number) =>
      fit(row, width).map((s, j) => <Text key={String(j)} color={s.c} dimColor={s.d} bold={s.b}>{s.t}</Text>)
    const frame = (title: string, tone: string, rows: Row[], right = '') => {
      const rule = Math.max(0, w - 6 - title.length - (right ? right.length + 2 : 0))
      return (
        <Box key={title} flexDirection="column" marginTop={1}>
          <Text>
            <Text color={tone} dimColor>╭─ </Text>
            <Text color={tone} bold>{title}</Text>
            <Text color={tone} dimColor> {'─'.repeat(rule)}</Text>
            {right ? <Text dimColor> {right} </Text> : null}
            <Text color={tone} dimColor>─╮</Text>
          </Text>
          {rows.map((row, i) => (
            <Text key={String(i)}>
              <Text color={tone} dimColor>│  </Text>
              {draw(row, inner)}
              <Text color={tone} dimColor>  │</Text>
            </Text>
          ))}
          <Text color={tone} dimColor>╰{'─'.repeat(w - 2)}╯</Text>
        </Box>
      )
    }

    // Context: one stacked bar of what fills it, the compaction mark, a legend, the size over turns, the heaviest items.
    const used = b.categories.filter(c => c.kind === 'used' && c.tokens > 0)
    const bar: Row = used.map(c => ({ t: '█'.repeat(cells(c.tokens, b.window, inner)), c: c.color }))
    const filled = width(bar)
    const mark = b.threshold === undefined ? -1 : Math.min(inner - 1, cells(b.threshold, b.window, inner))
    for (let i = filled; i < inner; i++) bar.push(i === mark ? { t: '┊', c: 'warning' } : { t: '·', d: true, c: mark >= 0 && i > mark ? 'error' : undefined })
    // The legend is a two-column grid, names left and counts right-aligned in each column.
    const colW = Math.floor((inner - 3) / 2)
    const keys = [
      ...used.map(c => ({ mark: '■', c: c.color, name: c.name, n: tokens(c.tokens) })),
      ...(b.threshold === undefined ? [] : [{ mark: '┊', c: 'warning', name: 'compacts at', n: tokens(b.threshold) }]),
    ]
    const key = (k: (typeof keys)[number]): Row => spread([{ t: `${k.mark} `, c: k.c }, { t: k.name.slice(0, colW - k.n.length - 3) }], [{ t: k.n, d: true }], colW)
    const legend: Row[] = []
    for (let i = 0; i < keys.length; i += 2) {
      const [a, z] = [keys[i], keys[i + 1]]
      if (a) legend.push([...key(a), ...(z ? [{ t: '   ' }, ...key(z)] : [])])
    }
    const last = turns.at(-1)
    const prev = turns.at(-2)
    const delta = last !== undefined && prev !== undefined ? last - prev : undefined
    const chartCols = inner - 12
    const chart = turns.length < 2 ? [] : braille(turns, b.window, chartCols, 2)
    const contextRows: Row[] = [
      spread([{ t: tokens(b.tokens), b: true }, { t: ` of ${tokens(b.window)}`, d: true }], [{ t: `${Math.round(b.percent)}%`, c: zone(b.percent), b: true }], inner),
      [],
      bar,
      [],
      ...legend,
      [],
      ...(chart.length
        ? [
            [{ t: chart[0] ?? '', c: 'suggestion' }, { t: '  ' }, { t: `${delta !== undefined && delta >= 0 ? '+' : '-'}${tokens(Math.abs(delta ?? 0))}`, b: true }],
            [{ t: chart[1] ?? '', c: 'suggestion' }, { t: '  last turn', d: true }],
          ]
        : [[{ t: 'Size over turns shows after two turns.', d: true }]]),
      ...(b.heaviest.length ? [[] as Row, ...b.heaviest.map(item => spread([{ t: '▸ ', d: true }, { t: item.name }], [{ t: tokens(item.tokens), d: true }], inner))] : []),
    ]

    // Limits: each window's meter, its reset, and whether the current pace lasts until then.
    const limitRows: Row[] = []
    const tones: string[] = []
    const glance: Row = [{ t: 'ctx ', d: true }, { t: `${Math.round(b.percent)}%`, c: zone(b.percent), b: true }]
    for (const win of WINDOWS) {
      const limit = r.limits.find(l => l.kind === win.kind)
      if (!limit) continue
      const p = pace(list, win.kind, now)
      const tone = limit.percentUsed >= 80 || (p.kind === 'full' && p.inMs < 3_600_000) ? 'error' : p.kind === 'full' ? 'warning' : 'success'
      tones.push(tone)
      const pct = `${Math.round(limit.percentUsed)}%`.padStart(4)
      const reset = `↻${duration(resetsIn(limit.resetsAt, now))}`.padEnd(7)
      if (limitRows.length) limitRows.push([])
      limitRows.push([{ t: `${win.label} `, b: true }, { t: '▕', d: true }, ...meter(limit.percentUsed, inner - 18), { t: '▏', d: true }, { t: ` ${pct} `, c: tone, b: true }, { t: reset, d: true }])
      limitRows.push(
        p.kind === 'measuring'
          ? [{ t: '   measuring pace…', d: true }]
          : p.kind === 'full'
            ? [{ t: `   full in ~${duration(p.inMs)} at this pace`, c: tone }]
            : [{ t: '   lasts until the reset at this pace', d: true }],
      )
      glance.push({ t: `   ${win.label} `, d: true }, { t: `${Math.round(limit.percentUsed)}%`, c: tone, b: true })
    }
    // toTimeString starts with the local HH:MM:SS.
    const hhmm = (ms: number) => new Date(ms).toTimeString().slice(0, 5)
    if (sent.length) limitRows.push([], ...sent.map(n => [{ t: `${hhmm(n.at)} `, d: true }, { t: `note sent: ${n.text}` }]))
    const limitTone = tones.includes('error') ? 'error' : tones.includes('warning') ? 'warning' : 'success'

    // Tools and Requests share the rows left below; each keeps at least three.
    // The top padding and glance row, each frame's two borders and top margin, and the Requests column header.
    const fixed = 2 + (contextRows.length + 3) + (limitRows.length ? limitRows.length + 3 : 0) + 3 + 4
    const left = Math.max(6, e.props.scroll.bodyRows - fixed)
    const toolCount = Math.max(3, Math.ceil(left / 2))
    const askCount = Math.max(3, left - toolCount)

    const shown = [...calls.filter(t => t.ok === undefined), ...calls.filter(t => t.ok !== undefined)].slice(0, toolCount)
    const running = calls.filter(t => t.ok === undefined).length
    const toolRows: Row[] = shown.length
      ? shown.map(t => {
          const icon = t.ok === undefined ? { t: '◌', c: 'warning' } : t.ok ? { t: '✓', c: 'success' } : { t: '✗', c: 'error' }
          const time = t.ms === undefined ? '…' : elapsed(t.ms)
          return spread([icon, { t: ` ${(t.sub ? `↳${t.name}` : t.name).padEnd(7)} `, b: !t.sub, d: t.sub }, { t: t.target.slice(0, inner - 16), d: true }], [{ t: time, d: true }], inner)
        })
      : [[{ t: 'No tool calls yet.', d: true }]]
    const toolTone = shown.find(t => t.ok !== undefined)?.ok === false ? 'error' : 'success'

    const askRows: Row[] = asks.length
      ? [
          [{ t: 'loop          in   out  cache   time', d: true }],
          ...asks.slice(0, askCount).map(q => {
            const hit = q.input ? Math.round((q.cached / q.input) * 100) : 0
            const cacheTone = hit < 20 ? 'error' : hit < 50 ? 'warning' : undefined
            return [
              { t: q.agent.padEnd(10).slice(0, 10), b: q.agent === 'main', d: q.agent !== 'main' },
              { t: tokens(q.input).padStart(6) + tokens(q.output).padStart(6) },
              { t: `${hit}%`.padStart(7), c: cacheTone, d: cacheTone === undefined },
              { t: elapsed(q.ms).padStart(7), d: true },
            ]
          }),
        ]
      : [[{ t: 'No model requests yet.', d: true }]]
    const lastHit = asks[0] && asks[0].input ? asks[0].cached / asks[0].input : 1
    const model = asks[0]?.model.replace(/^claude-/, '') ?? ''

    return (
      <Box flexDirection="column" paddingTop={1}>
        <Text>
          {draw(glance, w - 3)}
        </Text>
        {frame('Context', zone(b.percent), contextRows)}
        {limitRows.length ? frame('Limits', limitTone, limitRows) : null}
        {frame('Tools', toolTone, toolRows, running ? `${running} running` : '')}
        {frame('Requests', lastHit < 0.5 ? 'warning' : 'success', askRows, model)}
      </Box>
    )
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 Mehmet Aras

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 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 bfa1831e396b 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-meter/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 arasovic/claude-code-mods
/plugin install session-meter@claude-code-mods

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

Search them from Claude: the MCP connector

Similar designs