modscode / Gallery / context-window
context-window
A pane listing everything that entered the context window since the session started, by turn and by category
What it does
- Draws a pane
- Adds /context-window
- Hooks prompt.compose, prompt.context, session.append, session.compact and 5 more
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)
import type { Register } from 'claude-code'
// Drawn like context-window by Chris Han (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/chrishan17-context-window/
// 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: "Context" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button, Markdown } = $.ui.resolve(e)
const t = '…'
const hotkey = '…'
const t2 = '…'
const title = '…'
const note = '…'
const label = '…'
const detail = '…'
const fileLink = '…'
const badge = '…'
const label2 = '…'
const detail2 = '…'
const badge2 = '…'
const label3 = '…'
const detail3 = '…'
const badge3 = '…'
const label4 = '…'
const detail4 = '…'
const badge4 = '…'
const label5 = '…'
const detail5 = '…'
const badge5 = '…'
const label6 = '…'
const detail6 = '…'
const badge6 = '…'
const label7 = '…'
const detail7 = '…'
const badge7 = '…'
const label8 = '…'
const detail8 = '…'
const badge8 = '…'
const label9 = '…'
const detail9 = '…'
const badge9 = '…'
const label10 = '…'
const detail10 = '…'
const badge10 = '…'
const label11 = '…'
const detail11 = '…'
const badge11 = '…'
const label12 = '…'
const detail12 = '…'
const badge12 = '…'
const title2 = '…'
const label13 = '…'
const detail13 = '…'
const badge13 = '…'
const label14 = '…'
const detail14 = '…'
const badge14 = '…'
const label15 = '…'
const detail15 = '…'
const badge15 = '…'
const label16 = '…'
const detail16 = '…'
const badge16 = '…'
return (
<Box flexDirection="column" paddingTop={1}>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0}>
<Text>
<Text bold>
{t}
</Text>
<Text bold>
{" —"}
</Text>
<Text dimColor>
{` ${t}`}
</Text>
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} justifyContent="flex-end" marginLeft={2} marginRight={3}>
<Text dimColor wrap="truncate-start" />
</Box>
</Box>
<Text>
<Text>
━━━━━━━━
</Text>
<Text dimColor>
────────
</Text>
</Text>
<Box flexDirection="row" flexWrap="wrap" columnGap={2}>
<Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
<Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
<Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
<Button plain label={`${t}`} hotkey="r" dimColor />
</Box>
<Text dimColor wrap="wrap">
{t2}
</Text>
</Box>
<Box flexDirection="column">
<Box flexDirection="column">
<Box flexDirection="row" marginTop={1}>
<Box flexShrink={0}>
<Text bold>
{title}
</Text>
<Text dimColor>
{` ${note}`}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
<Text dimColor wrap="truncate">
────────
</Text>
</Box>
<Box flexShrink={0} width={5} />
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text bold />
</Box>
</Box>
<Text dimColor>
{` ${t}`}
</Text>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label2}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail2}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge2}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label3}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail3}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge3}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label4}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail4}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge4}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} />
<Button plain dimColor label={`${t}`} />
</Box>
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label5}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail5}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge5}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label6}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail6}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge6}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label7}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail7}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge7}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label8}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail8}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge8}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} />
<Button plain dimColor label={`${t}`} />
</Box>
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label9}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail9}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge9}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label10}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail10}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge10}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label11}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail11}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge11}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label12}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail12}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge12}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} />
<Button plain dimColor label={`${t}`} />
</Box>
</Box>
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row" marginTop={1}>
<Box flexShrink={0}>
<Text bold>
{title2}
</Text>
<Text dimColor>
{` ${note}`}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
<Text dimColor wrap="truncate">
────────
</Text>
</Box>
<Box flexShrink={0} width={5} />
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text bold />
</Box>
</Box>
<Text dimColor>
{` ${t}`}
</Text>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label13}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail13}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge13}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label14}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail14}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge14}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label15}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail15}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge15}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{label16}
</Text>
</Box>
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail16}
</Text>
</Box>
<Box flexShrink={0} marginLeft={2}>
<Markdown text={`${fileLink}`} dimColor />
</Box>
</Box>
<Box flexShrink={0} marginLeft={1}>
<Text>
{badge16}
</Text>
</Box>
<Box flexShrink={0} width={5} justifyContent="flex-end">
<Text dimColor />
</Box>
<Box flexShrink={0} width={7} justifyContent="flex-end">
<Text />
</Box>
</Box>
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} />
<Button plain dimColor label={`${t}`} />
</Box>
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexShrink={0} width={2}>
<Text dimColor>
│
</Text>
</Box>
<Box flexShrink={0} width={2}>
<Button plain dimColor label="▾" />
</Box>
<Box flexShrink={0} width={2}>
<Text>
{"✗ "}
</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row" />
</Box>
</Box>
</Box>
</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.
plugins/context-window/hooks/register.tsx lines 257–287 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const isInline = e.props.placement === 'inline'
if (isInline && !(await read($, asked))) {
// Opened at session start on a layout with no sidebar: step aside.
void $.clock.after(0, () => void $.ui.close({ id: PANE }))
const { Text } = $.ui.resolve(e)
return <Text dimColor>context-window: /context-window to open</Text>
}
const current = normalizeLog(await read($, log))
return drawPane(
$.ui.resolve(e),
{
fill: await read($, fill),
startup: await read($, startup),
entries: current.entries,
epoch: current.epoch,
view: await read($, view),
toggled: await read($, toggled),
lang: await read($, lang),
columns: Math.max(24, e.props.bodyColumns),
isInline,
},
{
toggle: key => void toggle($, key),
setView: next => void update($, view, () => next),
refresh: () => void refresh($),
},
)
})plugins/context-window/hooks/view.tsx lines 146–305 · Pane
export function drawPane(ui: Ui, data: PaneData, act: PaneActions) {
const { Box, Text, Button, Markdown } = ui
const { lang } = data
const tr = (text: string | undefined, arg?: string | number) =>
text === undefined ? undefined : hasKey(text) ? t(lang, text, arg ?? '') : text
const isOpen = (key: string, byDefault: boolean) => byDefault !== data.toggled.includes(key)
/** The indent guides for a row `depth` levels down, one fixed cell each. */
const indent = (depth = 0) =>
Array.from({ length: depth }, () => (
<Box flexShrink={0} width={INDENT_WIDTH}>
<Text dimColor>│</Text>
</Box>
))
const live = data.entries.filter(entry => entry.epoch === data.epoch)
const inWindow = live.filter(entry => !entry.isOutside)
const groups = data.startup?.groups ?? []
const startupTokens = sum(groups)
const hasShare = data.view === 'top' || data.view === 'category' || data.view === 'origin'
/**
* One row on a fixed grid: guides, toggle, glyph | name, detail or file link
* (each truncated on its own, the detail first) | badge | share | tokens,
* the last two right-aligned columns.
*/
const row = (props: RowProps) => {
const color = props.isError ? 'error' : props.color
// A detail that only restates the name ("Environment Environment") is dropped.
const detail = props.detail && props.detail.toLowerCase() !== props.label.toLowerCase() ? props.detail : undefined
const tokenColor = props.tokens === undefined || props.isQuiet ? undefined : sizeColor(props.tokens)
return (
<Box flexDirection="row">
{indent(props.depth)}
<Box flexShrink={0} width={TOGGLE_WIDTH}>
{props.toggleKey ? (
<Button
key={props.toggleKey}
plain
dimColor
label={props.isOpenNow ? '▾' : '▸'}
onPress={() => act.toggle(props.toggleKey as string)}
/>
) : null}
</Box>
<Box flexShrink={0} width={GLYPH_WIDTH}>
<Text color={color}>{`${props.isError ? '✗' : props.glyph} `}</Text>
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
<Box flexShrink={1} minWidth={0}>
<Text bold={props.isBold} dimColor={props.isQuiet} wrap="truncate-end">
{props.label}
</Text>
</Box>
{detail && !props.path ? (
<Box flexShrink={100} minWidth={0} marginLeft={2}>
<Text dimColor wrap="truncate-end">
{detail}
</Text>
</Box>
) : null}
{props.path ? (
<Box flexShrink={0} marginLeft={2}>
<Markdown text={fileLink(props.path)} dimColor />
</Box>
) : null}
</Box>
{props.badge ? (
<Box flexShrink={0} marginLeft={1}>
<Text color={props.badgeColor} dimColor={!props.badgeColor}>
{props.badge}
</Text>
</Box>
) : null}
{hasShare ? (
<Box flexShrink={0} width={SHARE_WIDTH} justifyContent="flex-end">
<Text dimColor>{props.share ?? ''}</Text>
</Box>
) : null}
<Box flexShrink={0} width={TOKENS_WIDTH} justifyContent="flex-end">
<Text color={tokenColor} dimColor={!tokenColor}>
{props.tokens === undefined || (props.tokens === 0 && props.isQuiet) ? '' : formatTokens(props.tokens)}
</Text>
</Box>
</Box>
)
}
/** A section heading: title, dim note, a rule to the edge, its total. */
const heading = (title: string, tokens?: number, note?: string) => {
// Longer than any room it gets: the Box's edge cuts it, on any font.
const rule = Math.max(2, data.columns)
return (
<Box flexDirection="row" marginTop={1}>
<Box flexShrink={0}>
<Text bold>{title}</Text>
{note ? <Text dimColor>{` ${note}`}</Text> : null}
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
<Text dimColor wrap="truncate">
{'─'.repeat(rule)}
</Text>
</Box>
{hasShare ? <Box flexShrink={0} width={SHARE_WIDTH} /> : null}
<Box flexShrink={0} width={TOKENS_WIDTH} justifyContent="flex-end">
<Text bold>{tokens === undefined ? '' : formatTokens(tokens)}</Text>
</Box>
</Box>
)
}
/** Items under an open group, each on a branch, the first few then "N more". */
const itemRows = (items: readonly StartupItem[], depth: number, key: string, total?: number) => {
const shown = isOpen(`${key}:all`, false) ? items : items.slice(0, TOP_ITEMS)
const more = items.length - shown.length
return (
<Box flexDirection="column">
{shown.map(item =>
row({
depth,
glyph: '·',
color: 'inactive',
label: tr(item.label) ?? '',
detail: tr(item.detail, item.detailArg),
path: item.path,
share: total ? `${Math.round((item.tokens / total) * 100)}%` : undefined,
tokens: item.tokens > 0 ? item.tokens : undefined,
}),
)}
{more > 0 && (
<Box flexDirection="row">
{indent(depth)}
<Box flexShrink={0} width={TOGGLE_WIDTH + GLYPH_WIDTH} />
<Button key={`${key}:all`} plain dimColor label={t(lang, 'more', more)} onPress={() => act.toggle(`${key}:all`)} />
</Box>
)}
</Box>
)
}
// ── Timeline ──────────────────────────────────────────────────────────────
/** The entries under each parent, in the order they came. */
const children = new Map<string, Entry[]>()
const ids = new Set(live.map(entry => entry.id))
for (const entry of live) {
if (!entry.parent || !ids.has(entry.parent)) continue
children.set(entry.parent, [...(children.get(entry.parent) ?? []), entry])
}
const subtree = (entry: Entry): Entry[] => [entry, ...(children.get(entry.id) ?? []).flatMap(subtree)]
/** One entry on its branch and, while open, its children and preview. */
const node = (entry: Entry, depth: number) => {
const style = KINDS[entry.kind]
const kids = children.get(entry.id) ?? []
const key = `node:${entry.id}`
// An Agent's own steps live in its window, a preview is long: shut until asked.
const open = isOpen(key, entry.kind !== 'agent' && kids.length > 0)Licence text (MIT)
MIT License Copyright (c) 2026 Chris Han 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
env varsdrives Claude
What its code shows
Read from the source at commit 041fa4383b8f 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.plugins/context-window/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.4 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 chrishan17/claude-mod-context-window/plugin install context-window@claude-mod-context-windowThis installs the marketplace's latest commit, which may not be the one read here (041fa4383b8f). 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 "chrishan17-context-window" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…HandoffHandoffHandoff… the rest of the step is in the handoff████████░░░░░░░░ /clear in 4spress 1 to clear now, or send a prompt to stay
-
Ask Claude…self-relayrelay packet: 3 chars (view truncated, full packet kept)c x
-
Ask Claude…packpack: 3 chars (view truncated, full pack kept)c x
-
Ask Claude…Question guideAwaiting answer Questions from Claude (3)Freeform answer1/3p ◀ Previousn Next ▶l Latesta AI explanation: ONh Hide historyCloseAI tokens this session: 3$1.24▍Your recent instructions▍Claude's preceding explanationCancelledFreeform answerExplainf Full context✦ AI explanation (instructions, context, effects, recommendation)compact context42%Generating… (you can keep answering)Freeform answerCould not generate an explanation: Freeform answerOFF (enable for the next question with [a])────────Past questions and answers31/3 ▶ Selected[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer→ Freeform: Explain31/3 ▶ Selected[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer→ Freeform: Explain31/3 ▶ Selected[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer[Freeform answer] Question guide → Awaiting answer→ Freeform: Explain
-
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…Glossary BrowserGlossary openContextsContextsContexts▲ prevWrite1/Glossary▼ nextContexts