modscode JA

modscode / Gallery / visible-compact

visible-compact

Shows the conversation before and after /compact side by side in a pane; /show-last-compact reopens it

Code you can checkTerminal + desktopPaneToastBoxButtonMarkdownSelectText

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

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 visible-compact by Sravan (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/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.

What its code calls

writes filesenv varsdrives Clauderemembers

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 b59803631553 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.hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.2 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.its repository's .claude-plugin/marketplace.json does not list it: no install line to give
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's .claude-plugin/marketplace.json does not list it, so there is no install line to give. Read it as code, or follow its author's README.

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 "nvsravank-visible-compact" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs