ModsCode / Claude Code Mods / Ranking / visible-compact
visible-compact
Shows the conversation before and after /compact side by side in a pane; /show-last-compact reopens it
What it does
- Draws a pane, toasts
- Hooks session.compact, session.end, session.start
- Keeps its own state between turns
Good points
- No network calls
- Starts no processes
- Written in TypeScript
- Handles errors
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like visible-compact by Sravan (pane, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/nvsravank-visible-compact/
// 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: "Your compaction history" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text, Markdown } = $.ui.resolve(e)
const tokens = '…'
const tokens2 = '…'
const durationMs = '…'
const messages = '…'
const total = '…'
const at = '…'
const pageCount = '…'
const role = '…'
const m = '…'
const i = '…'
const n = '…'
const text = '…'
const role2 = '…'
const role3 = '…'
const pageCount2 = '…'
const messages2 = '…'
const total2 = '…'
const pageCount3 = '…'
const role4 = '…'
const role5 = '…'
const role6 = '…'
const pageCount4 = '…'
return (
<Box flexDirection="column">
<Box justifyContent="space-between">
<Box flexDirection="column">
<Button plain />
<Button plain />
<Button plain />
</Box>
<Box gap={1}>
<Box />
<Box />
<Box />
<Button plain>
☾
</Button>
</Box>
</Box>
<Box justifyContent="space-between">
<Text>
<Text dimColor>
{"Tokens reduced to "}
</Text>
<Text bold>
{tokens}
</Text>
<Text dimColor>
{" from "}
</Text>
<Text bold>
{tokens2}
</Text>
</Text>
<Text dimColor>
{"Took: "}
{durationMs}
s
</Text>
</Box>
<Box marginTop={1}>
<Text wrap="wrap">
<Text bold>
{"Instructions: "}
</Text>
<Text dimColor>
none typed after /compact (the default summary prompt only)
</Text>
</Text>
</Box>
<Box flexDirection="row">
<Box flexDirection="column" paddingRight={1}>
<Box justifyContent="space-between">
<Text bold underline>
After
{" ("}
{messages}
{" msgs, "}
{total}
{" chunks)"}
</Text>
<Box gap={1}>
<Button plain>
{`‹ Previous`}
</Button>
<Text dimColor>
{`${at}1`}
/
{pageCount}
</Text>
<Button plain>
Next ›
</Button>
</Box>
</Box>
<Text dimColor>
(empty)
</Text>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role2}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role3}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box marginTop={1} justifyContent="flex-end">
<Box gap={1}>
<Button plain>
{`‹ Previous`}
</Button>
<Text dimColor>
{`${at}1`}
/
{pageCount2}
</Text>
<Button plain>
Next ›
</Button>
</Box>
</Box>
</Box>
<Box flexDirection="column" paddingRight={1} marginTop="1">
<Box justifyContent="space-between">
<Text bold underline>
After
{" ("}
{messages2}
{" msgs, "}
{total2}
{" chunks)"}
</Text>
<Box gap={1}>
<Button plain>
{`‹ Previous`}
</Button>
<Text dimColor>
{`${at}1`}
/
{pageCount3}
</Text>
<Button plain>
Next ›
</Button>
</Box>
</Box>
<Text dimColor>
(empty)
</Text>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role4}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role5}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold>
{role6}
</Text>
{" "}
{"· msg "}
{`${m}1`}
{` · part ${i}1/${n}`}
</Text>
<Markdown text={`${text}`} />
</Box>
<Box marginTop={1} justifyContent="flex-end">
<Box gap={1}>
<Button plain>
{`‹ Previous`}
</Button>
<Text dimColor>
{`${at}1`}
/
{pageCount4}
</Text>
<Button plain>
Next ›
</Button>
</Box>
</Box>
</Box>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const error = '…'
await $.ui.toast(`visible-compact: could not save the compaction (${error})`)
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 214–373 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const ui = $.ui.resolve(e)
const { Box, Text, Button, Markdown } = ui
const all = await read($, index)
if (all.length === 0) return <Text dimColor>No compaction recorded for this session yet.</Text>
const pick = await read($, selected)
const meta = all.find(m => m.id === pick) ?? all[all.length - 1]!
const mode = await read($, view)
const page = await read($, pages)
const columns = e.props.bodyColumns
const colorTheme = await read($, theme)
const colors = PALETTES[colorTheme]
const setView = (next: ViewMode) => () => void update($, view, () => next)
// Laid out as the columns are: after on the left, before on the right.
// A Button's label is one plain string, so the selected mode is drawn as bold
// text in its column's color instead; pressing it would change nothing anyway.
const modes = [
{ mode: 'after' as const, label: '◧ After', selected: <Text bold color={colors.after}>◧ After</Text> },
{
mode: 'both' as const,
label: '◫ Both',
selected: (
<Text>
<Text bold color={colors.after}>◫ Bo</Text>
<Text bold color={colors.before}>th</Text>
</Text>
),
},
{ mode: 'before' as const, label: '◨ Before', selected: <Text bold color={colors.before}>◨ Before</Text> },
]
const toggle = (
<Box gap={1}>
{modes.map(m =>
m.mode === mode ? (
<Box key={m.mode}>{m.selected}</Box>
) : (
<Button key={m.mode} plain dimColor onPress={setView(m.mode)}>
{m.label}
</Button>
),
)}
{/* Shows the mode a press switches to: ☾ while light, ☀ while dark. */}
<Button plain onPress={() => void toggleTheme($)}>
{colorTheme === 'light' ? '☾' : '☀'}
</Button>
</Box>
)
const newestFirst = [...all].reverse()
const options = newestFirst.map((m, i) => ({
value: m.id,
label: `${i === 0 ? '(latest) ' : ''}${optionLabel(m)}`,
}))
const pickId = (id: string) => void show($, id === newestFirst[0]?.id ? null : id)
// Mobile draws no Select: there the latest few are buttons instead.
const picker =
'Select' in ui ? (
<ui.Select key="compaction" label="Compaction: " value={meta.id} options={options} onSelect={pickId} />
) : (
<Box flexDirection="column">
{options.slice(0, 5).map(o => (
<Button key={o.value} plain dimColor={o.value !== meta.id} onPress={() => pickId(o.value)}>
{o.label}
</Button>
))}
</Box>
)
// When, who and what triggered it are in the picker; message counts head each column.
const stats = (
<Box justifyContent="space-between">
{/* Only the words are dim, so the bold numbers don't inherit it. */}
<Text>
<Text dimColor>Tokens reduced to </Text>
<Text bold color={colors.after}>
{tokens(meta.tokensAfter)}
</Text>
<Text dimColor> from </Text>
<Text bold color={colors.before}>
{tokens(meta.tokensBefore)}
</Text>
</Text>
<Text dimColor>Took: {(meta.durationMs / 1000).toFixed(1)}s</Text>
</Box>
)
// `gap` is the blank rows above the column, so a stacked Before stands apart from After's end.
const column = async (side: Side, width: number, gap = 1) => {
const total = meta.chunks[side]
const pageCount = Math.max(1, Math.ceil(total / PAGE_CHUNKS))
const at = Math.min(page[side], pageCount - 1)
const chunks = await readChunks($, meta.id, side, at * PAGE_CHUNKS, PAGE_CHUNKS)
const turn = (by: number) => () =>
void update($, pages, p => ({ ...p, [side]: Math.max(0, Math.min(pageCount - 1, at + by)) }))
const pager = pageCount > 1 && (
<Box gap={1}>
<Button plain dimColor={at === 0} onPress={turn(-1)}>
‹ Previous
</Button>
<Text dimColor>
{at + 1}/{pageCount}
</Text>
<Button plain dimColor={at === pageCount - 1} onPress={turn(1)}>
Next ›
</Button>
</Box>
)
return (
<Box flexDirection="column" width={width} paddingRight={1} marginTop={gap}>
<Box justifyContent="space-between">
<Text bold underline color={colors[side]}>
{side === 'after' ? 'After' : 'Before'} ({meta.messages[side]} msgs, {total} chunks)
</Text>
{pager}
</Box>
{chunks.length === 0 && <Text dimColor>(empty)</Text>}
{chunks.map((chunk: Chunk) => (
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
<Text bold color={chunk.role === 'user' ? colors.user : colors.assistant}>
{chunk.role}
</Text>{' '}
· msg {chunk.m + 1}
{chunk.n > 1 ? ` · part ${chunk.i + 1}/${chunk.n}` : ''}
</Text>
<Markdown text={chunk.text} />
</Box>
))}
{pager && (
<Box marginTop={1} justifyContent="flex-end">
{pager}
</Box>
)}
</Box>
)
}
const isSideBySide = mode === 'both' && columns >= SIDE_BY_SIDE_MIN
const half = isSideBySide ? Math.floor(columns / 2) : columns
const body =
mode === 'after' ? (
await column('after', columns)
) : mode === 'before' ? (
await column('before', columns)
) : (
<Box flexDirection={isSideBySide ? 'row' : 'column'}>
{await column('after', half)}
{await column('before', half, isSideBySide ? 1 : 3)}
</Box>
)
return (
<Box flexDirection="column">
<Box justifyContent="space-between">
{picker}
{toggle}Licence text (MIT)
MIT License Copyright (c) 2026 nvsravank 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.
How to build this: Pane (panel), Keep state with $.store
What its code calls
writes filesenv varsdrives Clauderemembers
What its code shows
Read from the source at commit b59803631553. 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.its repository's .claude-plugin/marketplace.json does not list it: no marketplace line to give; the page shows how to try the commit read |
| 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 something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads environment variables, files, but reaches nothing outside |
| 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 |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).calls no tool, MCP server or command |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command ? |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: command.run · also: session.start, session.end, session.compact, ui.render (Pane) |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: HOME, USERPROFILE, TMPDIR, TEMP, TMP; files: a path computed at run time |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.files: a path computed at run time, …/index.json |
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 its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
Its repository's .claude-plugin/marketplace.json does not list it, so there is no marketplace line to give.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/nvsravank/visible-compactgit -C visible-compact checkout b59803631553d1fec13eec89148e2953e3334e82claude plugin validate visible-compactclaude --plugin-dir visible-compactThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude about it
With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:
Read the ModsCode mod "nvsravank-visible-compact" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- glanceflowAntreas-Strb★ 3
- linear-claude-modrjohnt★ 1
- prdeckVishal K Setti★ 1
- agent-busNoah Airmet★ 0
- agent-rulesMahadSalim★ 0
- ccmod-chroniclem-aoki★ 0
More by Sravan
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/nvsravank-visible-compact/)