modscode JA

modscode / Gallery / session-inbox

session-inbox

Collects what is waiting on you in a session: questions, Claude's notes and PR reviews

Code you can checkTerminal + desktopPaneBandToastBoxButtonLinkText

What it does

  • Draws a band above the prompt, a pane, toasts
  • Adds /inbox
  • Watches tool calls and can refuse them
  • Hooks config.set, prompt.compose, prompt.context, prompt.submit and 5 more
  • Keeps its own state between turns

Good points

  • No network calls
  • Written in TypeScript
  • Handles errors
  • Writes no files

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-inbox by petekp (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/petekp-session-inbox/
// 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)
    const goal = '…'
    const now = '…'
    const hidden = '…'
    const prAlert = '…'
    const run = '…'
    const run2 = '…'
    const run3 = '…'
    return (
      <Box flexDirection="column">
        <Text wrap="truncate-end">
          <Text color="claude">
            {"◆ "}
          </Text>
          <Text dimColor>
            {goal}
            {` · ${now}`}
          </Text>
          <Text color="warning">
            {" · "}
            {hidden}
            {" older waiting on you in /inbox"}
          </Text>
          <Text color="autoAccept">
            {" · "}
            1 note
            {" in /inbox"}
          </Text>
          <Text color="planMode">
            {" · "}
            {prAlert}
          </Text>
        </Text>
        <Text wrap="truncate-end">
          <Text color="success">
            {" ● "}
          </Text>
          <Text dimColor>
            {run}
          </Text>
        </Text>
        <Text wrap="truncate-end">
          <Text color="success">
            {" ● "}
          </Text>
          <Text dimColor>
            {run2}
          </Text>
        </Text>
        <Text wrap="truncate-end">
          <Text color="success">
            {" ● "}
          </Text>
          <Text dimColor>
            {run3}
          </Text>
        </Text>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Session inbox" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Button, Text } = $.ui.resolve(e)
    const hotkey = '…'
    const label = '…'
    const count = '…'
    const count2 = '…'
    const count3 = '…'
    const length = '…'
    const name = '…'
    const url = '…'
    const name2 = '…'
    const url2 = '…'
    const name3 = '…'
    const url3 = '…'
    const title = '…'
    const d = '…'
    const d2 = '…'
    const d3 = '…'
    const decisionText = '…'
    const decisionText2 = '…'
    const decisionText3 = '…'
    const status = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box backgroundColor="userMessageBackground" paddingX={1} paddingY={1}>
          <Box flexDirection="row" columnGap={3} flexGrow={1}>
            <Box flexDirection="row">
              <Button plain hotkey={`${hotkey}`} label={`${label}`} dimColor />
              <Text>
                {" "}
                {count}
              </Text>
            </Box>
            <Box flexDirection="row">
              <Button plain hotkey={`${hotkey}`} label={`${label}`} dimColor />
              <Text>
                {" "}
                {count2}
              </Text>
            </Box>
            <Box flexDirection="row">
              <Button plain hotkey={`${hotkey}`} label={`${label}`} dimColor />
              <Text>
                {" "}
                {count3}
              </Text>
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column" paddingX={1} flexGrow={1}>
          <Box flexDirection="column" gap={1}>
            <Box flexDirection="column">
              <Box paddingLeft={1}>
                <Text dimColor wrap="wrap">
                  Nothing is waiting on you.
                </Text>
              </Box>
            </Box>
            <Box flexDirection="column" paddingLeft={1}>
              <Text dimColor>
                {"Running "}
                {length}
              </Text>
              <Text wrap="wrap">
                <Text color="success">
                  {"● "}
                </Text>
                <Text>
                  {name}
                  {" "}
                </Text>
                <Text dimColor>
                  {url}
                </Text>
              </Text>
              <Text wrap="wrap">
                <Text color="success">
                  {"● "}
                </Text>
                <Text>
                  {name2}
                  {" "}
                </Text>
                <Text dimColor>
                  {url2}
                </Text>
              </Text>
              <Text wrap="wrap">
                <Text color="success">
                  {"● "}
                </Text>
                <Text>
                  {name3}
                  {" "}
                </Text>
                <Text dimColor>
                  {url3}
                </Text>
              </Text>
            </Box>
            <Box flexDirection="column" paddingLeft={1}>
              <Button plain label={`▸ ${title} ${length}`} dimColor />
              <Box flexDirection="column" marginBottom={0}>
                <Text wrap="wrap">
                  <Text color="success">
                    {"✓ "}
                  </Text>
                  <Text dimColor>
                    {d}
                  </Text>
                </Text>
                <Text wrap="wrap">
                  <Text color="success">
                    {"✓ "}
                  </Text>
                  <Text dimColor>
                    {d2}
                  </Text>
                </Text>
                <Text wrap="wrap">
                  <Text color="success">
                    {"✓ "}
                  </Text>
                  <Text dimColor>
                    {d3}
                  </Text>
                </Text>
              </Box>
              <Button plain label={`▸ ${title} ${length}`} dimColor />
              <Box flexDirection="column" marginBottom={0}>
                <Text wrap="wrap" dimColor>
                  {decisionText}
                </Text>
                <Text wrap="wrap" dimColor>
                  {decisionText2}
                </Text>
                <Text wrap="wrap" dimColor>
                  {decisionText3}
                </Text>
              </Box>
            </Box>
          </Box>
        </Box>
        <Box backgroundColor="userMessageBackground" paddingX={1}>
          <Box flexDirection="row" justifyContent="space-between" columnGap={2} flexGrow={1}>
            <Box flexShrink={0}>
              <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
                <Button plain />
                <Button plain />
                <Button plain />
              </Box>
            </Box>
            <Box flexDirection="row" columnGap={2} flexShrink={1}>
              <Text dimColor wrap="truncate-start">
                {status}
              </Text>
              <Text color="error">
                update failed, retries after the next reply
              </Text>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const name = '…'
    const stderr = '…'
    await $.ui.toast(`${name} is not there anymore`)
    await $.ui.toast(`Could not open ${name}: ${stderr}`)
    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.

mods/session-inbox/hooks/register.tsx lines 979–1138 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (!isOn || e.props.hasSurvey) return next(e)
    const { Box, Button, Text } = $.ui.resolve(e)
    const [ledger, presence, prev, prs, now] = await Promise.all([
      readLedger($),
      read($, PRESENCE),
      read($, PREVIOUS),
      read($, PR_VIEWS),
      $.clock.now(),
    ])
    const isWorking = e.props.isWorking

    if (prev && ledger.turn === 0) {
      const c = prev.ledger.card
      const waiting = prev.ledger.items.length

      return (
        <Box flexDirection="column">
          <Text bold>
            Last session in this folder <Text dimColor>· {ago(now - prev.savedAt)}</Text>
          </Text>
          {c && <Text wrap="truncate-end">  Goal  {c.goal}</Text>}
          {c?.now && <Text wrap="truncate-end" dimColor>  Now   {c.now}</Text>}
          {waiting > 0 && (
            <Text wrap="truncate-end" dimColor>
              {'  '}
              {waiting} waiting on you: {prev.ledger.items.slice(0, 3).map(i => i.ask).join(' · ')}
            </Text>
          )}
          <Box flexDirection="row" gap={1}>
            {prev.isBroughtIn ? (
              <Text dimColor>  Added to your next message.</Text>
            ) : (
              <Button
                key="bring"
                label="Continue from it"
                variant="primary"
                onPress={() => update($, PREVIOUS, p => (p ? { ...p, isBroughtIn: true } : p))}
              />
            )}
            <Button key="hide-prev" label="Hide" onPress={() => update($, PREVIOUS, () => null)} />
          </Box>
        </Box>
      )
    }

    const card = ledger.card
    if (!card && ledger.items.length === 0 && ledger.notes.length === 0) return next(e)

    const batch = latestBatch(ledger)
    const older = olderItems(ledger)
    // Numbers only map back to items while no prompt has been sent since the
    // reply that asked them; answerNote applies the same rule.
    const numbered = ledger.batchTurn === ledger.turn ? batch : []
    const goal = card?.goal || 'This session'
    const waiting = ledger.items.length
    const noteCount = ledger.notes.length
    const prAlert = prAttention(Object.values(prs.views))
    // What else in /inbox wants attention, appended to the band's first line.
    const hints = [
      noteCount > 0 ? <Text color={NOTES}> · {noteCount === 1 ? '1 note' : `${noteCount} notes`} in /inbox</Text> : null,
      prAlert ? <Text color={PRS}> · {prAlert}</Text> : null,
    ]

    if (isWorking) {
      return (
        <Text wrap="truncate-end">
          <Text color={ACCENT}>◆ </Text>
          <Text dimColor>{goal}</Text>
          {waiting > 0 ? <Text color={WAITING}> · {waiting} waiting on you</Text> : null}
        </Text>
      )
    }

    const isReturn = presence.isAway && card !== null
    const shown = (isReturn ? [...older.slice(-2), ...batch] : batch).slice(-6)
    const hidden = waiting - shown.length
    const olderRows = hidden > 0 ? [<Text dimColor>  +{hidden} older in /inbox</Text>] : []
    const fit = (rows: JSX.Element[]) => <Box flexDirection="column">{rows.slice(0, Math.max(1, e.props.maxRows))}</Box>
    const itemRow = (item: Item) => {
      const handle = marker(item, numbered)
      const isInline = fitsInline(item)

      return (
        <Box flexDirection="row">
          <Box width={4} flexShrink={0}>
            <Text bold color={WAITING}>
              {handle}
            </Text>
          </Box>
          <Box flexShrink={1}>
            <Text wrap="truncate-end">
              {item.ask}
              {!isInline && item.rec ? <Text dimColor>  recommended: </Text> : null}
              {!isInline && item.rec ? <Text color={RECOMMENDED}>{item.rec}</Text> : null}
            </Text>
          </Box>
          {isInline ? (
            <Box flexDirection="row" flexShrink={0} gap={1} marginLeft={2}>
              {bandActions($, item).map(a => (
                <Button {...a} />
              ))}
            </Box>
          ) : null}
        </Box>
      )
    }
    const openRows = (card?.running ?? []).slice(0, 3).map(run => (
      <Text wrap="truncate-end">
        <Text color={DONE}>  ● </Text>
        <Text dimColor>{run}</Text>
      </Text>
    ))

    if (isReturn && card) {
      const rows = [
        <Text wrap="truncate-end">
          <Text color={ACCENT}>◆ </Text>
          <Text bold>{card.goal}</Text>
          <Text dimColor> · last active {ago(now - presence.lastActiveAt)}</Text>
          {hints}
        </Text>,
        ...(card.done.length > 0
          ? [
              <Text wrap="truncate-end">
                <Text color={DONE}>  ✓ </Text>
                <Text dimColor>{card.done.slice(-3).join(' · ')}</Text>
              </Text>,
            ]
          : []),
        <Text wrap="truncate-end">
          <Text dimColor>  → </Text>
          {card.now}
        </Text>,
        ...openRows,
        ...(ledger.decided.length > 0
          ? [
              <Text wrap="truncate-end" dimColor>
                {'  Decided: '}
                {ledger.decided
                  .slice(-2)
                  .map(decisionText)
                  .join(' · ')}
              </Text>,
            ]
          : []),
        ...(shown.length > 0
          ? [
              <Text bold color={WAITING}>
                Waiting on you
              </Text>,
              ...shown.map(itemRow),
            ]
          : []),
        ...olderRows,
      ]

      return fit(rows)
    }
mods/session-inbox/hooks/register.tsx lines 1180–1339 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Button, Link, Markdown, Text } = $.ui.resolve(e)
    const [ledger, presence, tab, prState, collapsed, selection, now, isDark] = await Promise.all([
      readLedger($),
      read($, PRESENCE),
      read($, TAB),
      read($, PR_VIEWS),
      read($, COLLAPSED),
      read($, SELECTION),
      $.clock.now(),
      read($, IS_DARK_THEME),
    ])
    const card = ledger.card
    const numbered = ledger.batchTurn === ledger.turn ? latestBatch(ledger) : []
    const prViews = Object.values(prState.views)
    const isFocused = e.props.isFocused
    const color = TAB_COLORS[tab]

    // One list row's content. Selected, a row shows its context line, its title
    // in full, its body and its keys; otherwise one line: `line`, or the title.
    type Row = {
      id: string
      handle: string
      meta: JSX.Element
      title: string
      line?: JSX.Element
      body?: JSX.Element | null
      keys: () => KeyAction[]
    }
    const itemRow = (item: Item): Row => {
      const handle = marker(item, numbered)
      const rec = item.rec && item.kind !== 'do' ? item.rec : null

      return {
        id: item.id,
        handle,
        meta: (
          <Text color={WAITING} bold>
            {item.kind === 'do' ? 'Your task' : 'Question'}
          </Text>
        ),
        title: item.ask,
        body: rec ? (
          <Text wrap="wrap">
            <Text dimColor>Recommended: </Text>
            <Text bold>{rec}</Text>
          </Text>
        ) : null,
        keys: () => itemKeys($, item, handle),
      }
    }
    const noteRow = (note: Note): Row => ({
      id: note.id,
      handle: '•',
      meta: (
        <Text wrap="truncate-end">
          <Text color={NOTES} bold>
            {noteKindLabel(note)}
          </Text>
          <Text dimColor>
            {' · '}
            {ago(now - note.at)}
            {note.path ? ` · ${baseName(note.path)}` : ''}
          </Text>
        </Text>
      ),
      title: note.title,
      line: (
        <Text wrap="truncate-end">
          {note.title}
          <Text dimColor> · {ago(now - note.at)}</Text>
        </Text>
      ),
      body: <Text wrap="wrap">{note.detail}</Text>,
      keys: () => [
        { key: `address-${note.id}`, label: 'Address it', hotkey: 'a', onPress: () => void actOnNote($, note, 'address') },
        { key: `discuss-${note.id}`, label: 'Discuss', hotkey: 'd', onPress: () => void actOnNote($, note, 'discuss') },
        { key: `drop-${note.id}`, label: 'Dismiss', hotkey: 'x', onPress: () => void removeNote($, note.id) },
      ],
    })
    const checkRow = (pr: PrView, c: PrCheck): Row => ({
      id: `${pr.ref} check ${c.name}`,
      handle: '✗',
      meta: (
        <Text color="error" bold>
          Failing check
        </Text>
      ),
      title: c.name,
      line: (
        <Text wrap="truncate-end">
          <Text color="error">{c.name}</Text>
          <Text dimColor> · failing check</Text>
        </Text>
      ),
      keys: () => [
        { key: `fix-${pr.ref}-${c.name}`, label: 'Fix', hotkey: 'f', onPress: () => void send($, prompts.fix(pr, c)) },
        { key: `log-${pr.ref}-${c.name}`, label: 'Open log', hotkey: 'o', onPress: () => void openUrl($, c.url ?? pr.url) },
      ],
    })
    const threadRow = (pr: PrView, t: PrThread): Row => {
      const latest = t.reply ?? { author: t.author, body: t.body }

      return {
        id: `${pr.ref} thread ${t.id}`,
        handle: '◦',
        meta: (
          <Text wrap="truncate-end">
            <Text color={PRS} bold>
              Review thread
            </Text>
            <Text dimColor>
              {t.replies > 0 ? ` · ${t.replies + 1} comments` : ''}
              {t.isOutdated ? ' · outdated' : ''}
            </Text>
          </Text>
        ),
        title: threadWhere(t),
        line: (
          <Text wrap="truncate-end">
            <Text dimColor>{threadWhere(t, baseName(t.path))} </Text>
            {latest.body.replace(/\s+/g, ' ')}
          </Text>
        ),
        body: (
          <Box flexDirection="column">
            {t.reply ? <Markdown dimColor text={`@${t.author}: ${clipLabel(t.body, 200)}`} /> : null}
            <Markdown text={`**@${latest.author}:** ${clipLabel(latest.body, 1200)}`} />
          </Box>
        ),
        keys: () => [
          { key: `address-${t.id}`, label: 'Address', hotkey: 'a', onPress: () => void send($, prompts.address(pr, [t])) },
          { key: `draft-${t.id}`, label: 'Draft reply', hotkey: 'r', onPress: () => void send($, prompts.draft(pr, t)) },
          { key: `discuss-${t.id}`, label: 'Discuss', hotkey: 'd', onPress: () => void send($, prompts.discuss(pr, t)) },
          { key: `open-${t.id}`, label: 'Open', hotkey: 'o', onPress: () => void openUrl($, t.reply?.url || t.url || pr.url) },
        ],
      }
    }

    // Each tab's rows in order: the cursor, the counts and the drawing all read these.
    const prGroups = prViews.map(pr => ({ pr, rows: [...failingChecks(pr).map(c => checkRow(pr, c)), ...waitingThreads(pr).map(t => threadRow(pr, t))] }))
    const rows: Record<Tab, Row[]> = {
      waiting: ledger.items.map(itemRow),
      notes: [...ledger.notes].reverse().map(noteRow),
      prs: prGroups.flatMap(g => g.rows),
    }
    const ids = rows[tab].map(r => r.id)
    const indexOf = new Map(ids.map((id, n) => [id, n]))
    const at = selectedIndex(ids, selection[tab])
    // Wide enough for the longest handle, such as "you" on a task.
    const handleWidth = 3 + Math.max(1, ...rows[tab].map(r => r.handle.length))

    const keyRow = (keys: KeyAction[]) => (
      <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
        {keys.map(k => (
          <Button plain {...k} />
        ))}
      </Box>
    )
    // The selected row gets a bar in the tab's color and a tinted background,
Licence text (MIT)
MIT License

Copyright (c) 2024 Pete Petrash

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.

This code is an example in the code reference: Rewrite the prompt

What its code calls

runs programsreads filesenv varsdrives Claudetool callsremembers

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 23e2b4fe4455 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.mods/session-inbox/hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.3 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).mods/session-inbox/hooks/register.tsx:381 open (not on Windows); mods/session-inbox/hooks/register.tsx:614 open (not on Windows)
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.mods/session-inbox/hooks/register.tsx:379 a program named at run time
Reads and sendsWhether it both reads files or environment variables and reaches the network.reads environment variables and files and reaches the 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 "petekp-session-inbox" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs