SLOPSHOPPER

spmock

Ostrakon v2 design mockups (phase D, part 2): static renders of every pane state

panebandcommand
★ 2v0.0.1MITupdated 2026-10-24gaius-codius/ostrakon/tools/mockups
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · spmock
│ ┃ ostrakon ✕ › fix the failing auth test and add an audit log call │ ┃ ❯ ▏search notesthis project · 5 open │ ┃ ──────────────────────────────────────────── ⏺ Read(src/auth.ts) │ ┃ 1 check why the cache test is flaky… ● cc ⎿ Read 6 lines │ ┃ 2 rename the store helpers to match… ● cc ⏺ Update(src/auth.ts) │ ┃ 3 ◆ login returns 401 right after a t… ● cc ⎿ Added 2 lines, removed 1 line │ ┃ 4 try bun:test for the merge proper… ● cc ⏺ Bash(bun test) │ ┃ 5 add a /jot section to the README ● cc ⎿ 3 pass, 1 fail │ ┃ ──────────────────────────────────────────── │ ┃ check why the cache test is flaky on CI. sta ● Done. refresh now rejects expired claims and logs an audit event. │ ┃ the redis bump, only on the arm runners │ ┃ you · ~/Work/cc · main · 12m ago ✻ Worked for 42s · done 4:20 PM │ ┃ │ ┃ ctrl+s all projects ctrl+n new ctrl+x i › /mock │ ⎿ spmock: mock search-empty │ │ ⟨Claude Code's own drawing⟩ 1: check why the cac… 2: rename the store … 3: ◆ login returns 401… ✎ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
⟨Claude Code's own drawing⟩ 1: check why the cac… 2: rename the store … 3: ◆ login returns 401… ✎
Pane · ostrakon
❯ ▏search notesthis project · 5 open ─────────────────────────────────────────────────────── 1 check why the cache test is flaky… ● cc 12m 2 rename the store helpers to match… ● cc 1h 3 ◆ login returns 401 right after a t… ● cc 3h 4 try bun:test for the merge proper… ● cc 1d 5 add a /jot section to the README ● cc 2d ─────────────────────────────────────────────────────── check why the cache test is flaky on CI. started after the redis bump, only on the arm runners you · ~/Work/cc · main · 12m ago ctrl+s all projects ctrl+n new ctrl+x i keys
README

<h1> <img src="brand/lockup-light.svg" alt="ostrakon" width="300"> </h1>

A scratchpad for Claude Code. Halfway through a prompt, something else comes to mind: open the pane, note it, close the pane, and your prompt is back as you left it. Later, pull the note into the prompt when you get to it. Claude can jot notes for you too.

In the demo: note something mid-prompt, then add a saved note to the prompt.

<img src="docs/images/demo.gif" alt="Half a prompt typed in Claude Code; the ostrakon pane opens and the prompt empties, a note is typed and saved, and when the pane closes the prompt is back as it was. Then the pane opens again, a search finds a note Claude jotted, and t adds it to the prompt under the draft">

Notes are kept per project, and the pane shows all of them. Syncing between machines and a phone app are optional.

What it does

  • Capture a note in under two seconds, even while Claude is working. Mid-prompt, ctrl+x s opens the pane and ctrl+n starts a note; close the pane and your draft is back. In an empty prompt, /jot text or // saves one without opening anything.
  • Gives Claude a jot tool: Claude jots notes it thinks are important or wants to pass on to you. You can also ask it to add one: "jot that down". Claude can also list your notes and archive one once it's done.
  • Triage open notes across all your projects in a searchable pane: edit, move, archive, bundle several into one prompt.
  • Dispatch a note into the prompt. This project's open notes sit in a row of numbered chips above the prompt (the "pocket"); type ; and a note's number (;2) in an empty prompt to pull it in. A lone number is left alone, so it still answers Claude's numbered questions. Mid-prompt, find the note in the pane and press t: it goes in under what you've typed.
  • Harvest (opt-in): after each turn, an extra review looks for side issues that came up and offers them as notes, which you keep or dismiss. It doesn't change what Claude is doing.
  • Sync: two-way sync enabled by multiple methods. Through a small hub, a plain folder, Obsidian or a combination of methods (Sync).
  • Desktop: save a note from a key on your desktop, or from a script, without opening Claude Code: ostrakon jot (Notes from the desktop).
  • Phone: capture and triage from your phone with the hub's web app, installed to the Home Screen, or send a note from the share sheet or Siri with an iOS Shortcut.

Notes are plain Markdown files with some YAML. One per note, in ~/.local/share/ostrakon/ by default, so they are yours to read, grep and back up.

The ostrakon pane docked beside a Claude Code session, listing open notes across projects, with this project's notes as numbered chips above the prompt

Sync

Sync is optional and works both ways. Add, edit, move or archive a note on one machine or on your phone, and the change shows up everywhere else. If the same note changes in two places, the later change wins everywhere. There are a few ways to sync; use one or combine them:

  • The hub (server/): a small service you run on one of your machines. Your other machines and your phone reach it over Tailscale (the easy option) or your own HTTPS proxy, tunnel or VPN. Changes show up in other sessions within seconds, and the hub also serves the phone app. Setup: the hub and the phone app.
  • A folder (the mirrorDir option): ostrakon keeps a copy of your notes in a folder, and whatever syncs that folder (Dropbox, Syncthing, any synced drive) carries them between machines. Point it at an Obsidian vault and you can edit notes there too; your edits come back. Obsidian shows each note's metadata as Properties at the top; to hide them, set Settings → Editor → Properties in document to Hidden. No server needed.
  • Both at once: they work independently, so you can use the hub for your phone and a folder for Obsidian.

On your phone, the hub's web app installs to the Home Screen and opens straight to a note field. You can triage there too (edit, move, archive, mark sent), and anything you capture offline is kept until the hub is reachable again. To pair a phone, scan the QR code that ostrakon pair shows. An iOS Shortcut can send a note from the share sheet or Siri without opening the app. Details: docs/phone.md.

Install

There are two ways to install it:

  • The install script gets you the mod and the ostrakon command: jot, update, doctor, pair, and the hub for syncing and the phone app. Updates come through ostrakon update.
  • Claude Code's plugin marketplace gets you the mod only. There's no ostrakon command, so you can't run the hub or pair a phone from it; folder sync, and a hub set up on another machine, still work. Updates come through Claude Code.

Use one or the other. The install script offers to add the keybindings; with the marketplace, add them yourself.

Requirements

  • Claude Code with mods support (see the mods docs). Tested with 2.1.310; mods are still changing, so a much older or newer version may not work.
  • git, and python3 for the install script (without it, the script tells you the one line to add yourself).
  • For the hub: Bun (tested with 1.4.4) to run the hub and to use ostrakon pair and ostrakon jot, and qrencode for the pairing QR code. install.sh --hub sets the hub up as a systemd service, so that part is Linux-only for now; elsewhere, run ostrakon hub however you like to keep things running.

Tested on Linux. macOS should work for the mod but hasn't been tried yet; reports are welcome.

With the install script

One command clones ostrakon into ~/.local/share/ostrakon-src and installs the newest release:

curl -fsSL https://raw.githubusercontent.com/gaius-codius/ostrakon/main/get.sh | bash

Add -s -- --hub after bash to set up the hub too, or -s -- --main to follow the newest code on main instead of releases. Running it again updates what's there. To read the script before running it: curl -fsSL https://raw.githubusercontent.com/gaius-codius/ostrakon/main/get.sh -o get.sh, look it over, then bash get.sh.

Or clone the repo wherever you like and run the install script yourself:

git clone https://github.com/gaius-codius/ostrakon.git
cd ostrakon && ./install.sh --release

Either way, the install script:

  • switches to the newest release (leave out --release to run what's on main),
  • loads the mod in every Claude Code session, by setting CLAUDE_CODE_PLUGIN_DIRS in ~/.claude/settings.json (only if it isn't set already, and it keeps a .bak copy),
  • and adds the ostrakon command to ~/.local/bin.

It's safe to run again. ./install.sh --hub also sets up the hub (below).

To try it without installing anything, load it for a single session: claude --plugin-dir ostrakon/plugin. To install by hand, add the folder to ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/ostrakon/plugin" } }

From the plugin marketplace

claude plugin marketplace add gaius-codius/ostrakon
claude plugin install ostrakon@ostrakon

Update it with claude plugin update ostrakon@ostrakon, or turn on auto-update for the marketplace in /plugin. A new copy arrives with each release. If you also run the install script, it sees the plugin and doesn't load the mod a second time.

Updating

ostrakon update             # or ./update.sh in the repo
ostrakon update --main      # switch to the newest code on main instead of releases
ostrakon update --release   # switch back to releases
ostrakon version

If you installed a release, update moves you to the newest one; if you're on a branch, it pulls that branch (and stops rather than touch commits of your own). It restarts the hub if it's running here, after new code or when the hub still runs an older release, and lists what changed. Restart any open Claude Code sessions to pick up the new version. Each release's changes are in CHANGELOG.md.

If something isn't working

ostrakon doctor

It checks that the mod loads, which Claude Code version last ran it and whether anything went wrong there, your notes folder, the hub and its token, and the tools ostrakon needs, and says what to fix. It changes nothing and never prints your token, so its output is safe to paste into a bug report.

Keybindings

A mod can't add keyboard shortcuts of its own, so ostrakon borrows some existing Claude Code actions (which is why the names below look unrelated). The install script asks whether to add these to ~/.claude/keybindings.json (--keys adds them without asking, --no-keys skips them). It leaves alone any key you've bound to something else, and any of these actions you've already given a key. To add them by hand:

{
  "bindings": [
    { "context": "Chat", "bindings": { "ctrl+x s": "app:cycleDiffBase", "ctrl+x tab": "app:openArtifact" } },
    {
      "context": "Pane",
      "bindings": {
        "ctrl+x s": "app:cycleDiffBase", "ctrl+x tab": "app:openArtifact", "ctrl+q": "pane:previous",
        "ctrl+f": "app:toggleDiffNoiseFilter", "ctrl+s": "app:toggleDiffPreSession", "ctrl+n": "pane:next",
        "ctrl+x i": "app:toggleReplTab"
      }
    },
    {
      "context": "PaneField",
      "bindings": {
        "ctrl+x s": "app:cycleDiffBase", "ctrl+x tab": "app:openArtifact", "ctrl+q": "pane:previous",
        "ctrl+f": "app:toggleDiffNoiseFilter", "ctrl+s": "app:toggleDiffPreSession", "ctrl+n": "pane:next",
        "ctrl+x i": "app:toggleReplTab"
      }
    }
  ]
}

ctrl+x s opens and closes the pane, and ctrl+x tab moves the keyboard between the pane and the prompt, leaving the pane open (it takes the place of Claude Code's ctrl+x tab, which focuses the band above the prompt; a click still does). The other keys work inside the pane. /jot and // need no setup. The full key list is in docs/SPEC.md §4.

Configuration

Set these under the plugin's options (pluginConfigs.ostrakon.options in your settings, or pluginConfigs["ostrakon@ostrakon"].options if you installed it with claude plugin install):

OptionDefaultWhat it does
notesDir~/.local/share/ostrakonWhere notes are stored. The OSTRAKON_DIR environment variable overrides it.
pocket / pocketMaxon / 5The numbered chips above the prompt, and how many show.
harvestoffReview each finished turn for side issues worth keeping.
harvestModeforkfork reviews the whole conversation, tool output included, so it sees more but costs more as the conversation grows. light has a small model read only your prompt and Claude's final answer: much cheaper, but it misses more.
harvestMaxPerTurn3The most notes harvest offers after one turn.
hubUrl / hubTokenemptyThe hub to sync with, and its token. Empty: no hub.
mirrorDiremptyA folder to keep a synced copy of your notes in, such as a Dropbox or Syncthing folder or part of an Obsidian vault.

The hub and the phone app (optional)

The hub is a single Bun file (server/hub.ts) that stores notes in SQLite. It only listens on the machine it runs on and needs a token for every request, so you choose how other devices reach it. We use Tailscale, the simplest option: tailscale serve gives it an HTTPS address only your devices can reach, and install.sh and ostrakon pair set it up for you.

./install.sh --hub

This creates a token in ~/.config/ostrakon-hub/env (if there isn't one yet) and installs and starts the hub as a systemd user service (server/ostrakon-hub.service). It then prints the two steps left for you: loginctl enable-linger, so the hub keeps running when you log out, and tailscale serve, to put it on your tailnet.

To pair a phone, run ostrakon pair (it needs qrencode) and scan the QR code. The code in it works once and expires after 5 minutes, so the QR never contains the token itself; --token prints a link that does.

To run the hub in the foreground instead: HUB_TOKEN=$(openssl rand -hex 24) ostrakon hub. The ostrakon command reads HUB_TOKEN from the environment or from ~/.config/ostrakon-hub/env.

Not using Tailscale? Any HTTPS reverse proxy, tunnel or VPN works too; see Open it.

The service runs ~/.local/bin/ostrakon hub, so it doesn't matter where the repo lives. Phone setup, the Home Screen app and the iOS Shortcut are covered in docs/phone.md. Read SECURITY.md before making the hub reachable from other devices.

Notes from the desktop

Save a note without opening Claude Code. Needs Bun.

ostrakon jot call the plumber
ostrakon jot -p cc fix the flaky test     # file it under a project
  • Where it goes: this machine's notes folder, so it shows in your sessions here. If the mod has a hub set, the note goes to the hub at once and reaches your phone and other machines within seconds.
  • Hub down? The note stays here, and a session sends it to the hub later.
  • --project / -p takes a project your notes already know, by name or key.
  • No mod on this machine? Set OSTRAKON_HUB_URL and OSTRAKON_HUB_TOKEN. If either is set, both are read from the environment.

A quick-note key

ostrakon jot --ask opens a one-line prompt, saves what you type and shows a notification. Start the line with @name to file it under a project: @cc fix the flaky test.

Bind ~/.local/bin/ostrakon jot --ask to a key in your desktop's keyboard settings or your window manager's config. On Hyprland, in bindings.conf:

bindd = SUPER SHIFT, J, Ostrakon note, exec, ~/.local/bin/ostrakon jot --ask

On Omarchy, in ~/.config/hypr/bindings.lua:

o.bind("SUPER + SHIFT + J", "Ostrakon note", "~/.local/bin/ostrakon jot --ask")

The prompt comes from a tool you likely have already: walker, fuzzel, rofi, wofi or zenity. On Omarchy it uses Omarchy's own prompt. On macOS it uses osascript, which is untested so far.

From other apps

A Slack bot, a script or another machine can post to the hub's /api/jot with a source. The note is yours, and the source is kept as where it came from. See docs/phone.md.

Known limitations

These come from Claude Code's mods interface, which is still new, and should go away as it matures.

  • Long notes in the pane's text field. When a note is longer than the capture or edit field, the text doesn't scroll with you: it disappears past the end of the field, while the cursor keeps moving and can even drop to an empty "second" line. What you type is all there, though, and the whole note shows in full just below the field as you write. It needs a text field that wraps or scrolls, which mods don't have yet.
  • Claude Code updates can break things. Mods change between versions. If something stops working after an update, run ostrakon doctor and mention your Claude Code version when you report it.

More, including a couple of folder-sync edge cases, in ROADMAP.md.

Development

  • How it's designed, and notes on the platform it builds on: docs/SPEC.md. How it looks: docs/DESIGN.md. Ideas for what's next: ROADMAP.md.
  • tools/check.sh runs every check: claude plugin validate, the design check (docs/DESIGN.md against the code), the type-check, claude plugin test and the hub's tests. The mod's tests and type-check need the claude CLI installed, because the mods test kit and types ship with it. CI runs the tests on the version bin/tested-with names.
  • The hub's tests need only Bun: cd server && bun test.
  • How to contribute, and how releases are made: CONTRIBUTING.md.
  • tools/ also has the screenshot pipeline and some experiment scripts; they write to working-docs/, which git ignores.

License

MIT

Source 2 files
hooks/register.tsx 866 lines
1import { atom, read, update } from 'claude-code'
2import type { Elements, Register } from 'claude-code'
3
4// Design mockups (phase D, part 2): static renders of every pane state in three directions, from
5// fixed sample data. Nothing here is interactive; the real pane is built in P2.
6//   /mock <quiet|cards|ledger|mix> <view>     views: see VIEWS
7//   /mockband <off|a|b> <pocket0|pocket3|pocket9|harvest>
8
9type E = Elements['terminal']
10type Direction = 'quiet' | 'cards' | 'ledger' | 'mix'
11
12const direction = atom({ plugin: 'spmock', key: 'direction' } as const, 'quiet')
13const view = atom({ plugin: 'spmock', key: 'view' } as const, 'search-empty')
14const band = atom({ plugin: 'spmock', key: 'band' } as const, 'off')
15
16const PANE = 'ostrakon'
17const VIEWS = [
18  'search-empty',
19  'search-typing',
20  'search-nomatch',
21  'unfocused',
22  'list-grouped',
23  'list-folded',
24  'list-history',
25  'picked',
26  'bundle',
27  'capture',
28  'edit',
29  'empty',
30  'empty-history',
31]
32
33// ---- sample data ----
34
35type Note = {
36  id: string
37  text: string
38  project: string
39  age: string
40  by?: 'claude' | 'phone'
41  status?: 'sent' | 'archived'
42  branch?: string
43}
44
45const CURRENT = 'cc'
46const NOTES: Note[] = [
47  { id: 'a', project: 'cc', age: '12m', branch: 'main', text: 'check why the cache test is flaky on CI. started after the redis bump, only on the arm runners' },
48  { id: 'b', project: 'cc', age: '1h', branch: 'main', text: 'rename the store helpers to match the spec (createStore, change, scan)' },
49  { id: 'c', project: 'cc', age: '3h', by: 'claude', branch: 'main', text: 'login returns 401 right after a token refresh; retry ignores Retry-After' },
50  { id: 'd', project: 'cc', age: '1d', branch: 'p1', text: 'try bun:test for the merge property tests' },
51  { id: 'e', project: 'cc', age: '2d', branch: 'main', text: 'add a /jot section to the README' },
52  { id: 'f', project: 'infra', age: '1h', text: 'add a cache invalidation metric to the hub dashboard' },
53  { id: 'g', project: 'infra', age: '2d', text: 'rotate the staging api keys before friday' },
54  { id: 'h', project: 'infra', age: '5d', text: 'tailscale serve on the server for the ostrakon hub' },
55  { id: 'i', project: 'api', age: '2d', text: 'document the cache-key format in the api readme' },
56  { id: 'j', project: 'api', age: '1w', text: 'pagination cursor is off by one on the last page' },
57  { id: 'k', project: 'unfiled', age: '4h', by: 'phone', text: 'book the dentist' },
58  { id: 'l', project: 'unfiled', age: '3d', by: 'phone', text: 'idea: weekly digest of what got sent' },
59]
60const HISTORY: Note[] = [
61  { id: 'x', project: 'cc', age: '2d', status: 'sent', text: 'bump redis to 7.2 in the test compose file' },
62  { id: 'y', project: 'cc', age: '5d', status: 'archived', text: 'remove the old v1 notes file' },
63]
64const PATHS: Record<string, string> = { cc: '~/Work/cc', infra: '~/code/infra', api: '~/Work/api', unfiled: '' }
65
66// Project colours: theme keys only (they follow light and dark); the current project gets the accent.
67const PALETTE = ['suggestion', 'success', 'merged', 'planMode', 'warning', 'autoAccept']
68const colourOf = (project: string) => {
69  if (project === CURRENT) return 'claude'
70  if (project === 'unfiled') return 'inactive'
71  let hash = 0
72  for (const char of project) hash = (hash * 31 + char.charCodeAt(0)) >>> 0
73  return PALETTE[hash % PALETTE.length] ?? 'suggestion'
74}
75
76const fit = (text: string, width: number) => {
77  const flat = text.replaceAll('\n', ' ')
78  return flat.length <= width ? flat.padEnd(width) : `${flat.slice(0, Math.max(0, width - 1))}…`
79}
80
81// Matched characters of a query: a contiguous hit if there is one, else a greedy subsequence.
82const segments = (text: string, query: string): [string, boolean][] => {
83  if (query === '') return [[text, false]]
84  const at = text.toLowerCase().indexOf(query.toLowerCase())
85  if (at >= 0) return [[text.slice(0, at), false], [text.slice(at, at + query.length), true], [text.slice(at + query.length), false]]
86  return [[text, false]]
87}
88
89const matches = (query: string) => NOTES.filter(note => note.text.toLowerCase().includes(query.toLowerCase()))
90
91// ---- shared pieces ----
92
93type RowSpec = {
94  note: Note
95  width: number
96  number?: number
97  isSelected?: boolean
98  isPicked?: boolean
99  showPicks?: boolean
100  query?: string
101  isHistory?: boolean
102  // Grouped list rows leave the project out: the group header names it.
103  isGrouped?: boolean
104}
105
106const Highlighted = ({ el, text, query, width, isDim }: { el: E; text: string; query: string; width: number; isDim?: boolean }) => {
107  const { Text } = el
108  const cut = fit(text, width)
109  return (
110    <Text dimColor={isDim}>
111      {segments(cut, query).map(([part, isHit]) =>
112        isHit ? (
113          <Text bold color="claude" underline>
114            {part}
115          </Text>
116        ) : (
117          part
118        ),
119      )}
120    </Text>
121  )
122}
123
124const marker = (spec: RowSpec) => {
125  if (spec.isHistory) return spec.note.status === 'sent' ? '↗' : '·'
126  if (spec.note.by === 'claude') return '◆'
127  if (spec.note.by === 'phone') return '▪'
128  return ' '
129}
130
131// ---- direction: quiet ----
132// Almost no chrome. Selected row: a background band with an accent bar. Projects as coloured
133// words at the right. One footer line of keys.
134
135const QuietRow = ({ el, spec }: { el: E; spec: RowSpec }) => {
136  const { Box, Text } = el
137  const { note, width } = spec
138  const pick = spec.showPicks ? (spec.isPicked ? '● ' : '○ ') : ''
139  const right = spec.isGrouped ? ` ${note.age.padStart(4)}` : `${fit(note.project, 8).trimEnd().padStart(8)} ${note.age.padStart(4)}`
140  const textWidth = width - 3 - pick.length - right.length - 1
141  return (
142    <Box width={width} backgroundColor={spec.isSelected ? 'subtle' : undefined}>
143      <Text color="claude">{spec.isSelected ? '▌' : ' '}</Text>
144      <Text color={marker(spec) === '◆' ? 'claude' : 'inactive'}>{marker(spec)} </Text>
145      {pick !== '' && <Text color={spec.isPicked ? 'claude' : 'inactive'}>{pick}</Text>}
146      <Highlighted el={el} text={note.text} query={spec.query ?? ''} width={textWidth} isDim={spec.isHistory} />
147      <Text> </Text>
148      {!spec.isGrouped && <Text color={spec.isHistory ? 'inactive' : colourOf(note.project)}>{fit(note.project, 8).trimEnd().padStart(8)}</Text>}
149      <Text dimColor> {note.age.padStart(4)}</Text>
150    </Box>
151  )
152}
153
154// ---- direction: cards ----
155// Framed search, project pills on the left, preview in a card, primary actions as buttons.
156
157const Pill = ({ el, project, isDim }: { el: E; project: string; isDim?: boolean }) => {
158  const { Text } = el
159  return (
160    <Text backgroundColor={isDim ? 'inactive' : colourOf(project)} color="inverseText">
161      {` ${project.slice(0, 7).padEnd(7)} `}
162    </Text>
163  )
164}
165
166const CardsRow = ({ el, spec }: { el: E; spec: RowSpec }) => {
167  const { Box, Text } = el
168  const { note, width } = spec
169  const pick = spec.showPicks ? (spec.isPicked ? '● ' : '○ ') : ''
170  const textWidth = width - 2 - (spec.isGrouped ? 0 : 10) - 1 - pick.length - 2 - 5
171  return (
172    <Box width={width} backgroundColor={spec.isSelected ? 'subtle' : undefined}>
173      <Text color="claude">{spec.isSelected ? '▌ ' : '  '}</Text>
174      {!spec.isGrouped && <Pill el={el} project={note.project} isDim={spec.isHistory} />}
175      <Text> </Text>
176      {pick !== '' && <Text color={spec.isPicked ? 'claude' : 'inactive'}>{pick}</Text>}
177      <Text color={marker(spec) === '◆' ? 'claude' : 'inactive'}>{marker(spec)} </Text>
178      <Highlighted el={el} text={note.text} query={spec.query ?? ''} width={textWidth} isDim={spec.isHistory} />
179      <Text dimColor>{note.age.padStart(5)}</Text>
180    </Box>
181  )
182}
183
184// ---- direction: ledger ----
185// A table: numbered rows (1-9 jump), a column header, coloured dots for projects, selection
186// drawn inverse like the native focus ring.
187
188const LedgerRow = ({ el, spec }: { el: E; spec: RowSpec }) => {
189  const { Box, Text } = el
190  const { note, width } = spec
191  const num = spec.number !== undefined && spec.number <= 9 ? String(spec.number) : ' '
192  const pick = spec.showPicks ? (spec.isPicked ? '●' : '○') : marker(spec)
193  const textWidth = width - 4 - (spec.isGrouped ? 0 : 12) - 5
194  return (
195    <Box width={width}>
196      <Text color="claude" bold>
197        {num}
198      </Text>
199      <Text color={spec.isPicked || pick === '◆' ? 'claude' : 'inactive'}> {pick} </Text>
200      <Text inverse={spec.isSelected}>
201        <Highlighted el={el} text={note.text} query={spec.query ?? ''} width={textWidth} isDim={spec.isHistory} />
202      </Text>
203      {!spec.isGrouped && <Text color={spec.isHistory ? 'inactive' : colourOf(note.project)}> ● </Text>}
204      {!spec.isGrouped && <Text dimColor>{fit(note.project, 9)}</Text>}
205      <Text dimColor>{note.age.padStart(5)}</Text>
206    </Box>
207  )
208}
209
210// ---- direction: mix (Quiet + Ledger, the picked one) ----
211// Ledger's numbered rows and bold footer keys; Quiet's band-and-bar selection and coloured project
212// word. No column header. Two rules only: heavy under the search, light above preview and footer.
213
214const MixRow = ({ el, spec }: { el: E; spec: RowSpec }) => {
215  const { Box, Text } = el
216  const { note, width } = spec
217  const num = spec.number !== undefined && spec.number <= 9 ? String(spec.number) : ' '
218  const pick = spec.showPicks ? (spec.isPicked ? '●' : '○') : marker(spec)
219  const right = spec.isGrouped ? ` ${note.age.padStart(4)}` : `${fit(note.project, 8).trimEnd().padStart(8)} ${note.age.padStart(4)}`
220  const textWidth = width - 5 - right.length - 1
221  return (
222    <Box width={width} backgroundColor={spec.isSelected ? 'subtle' : undefined}>
223      <Text color="claude">{spec.isSelected ? '▌' : ' '}</Text>
224      <Text color={spec.isSelected ? undefined : 'claude'} bold>
225        {num}
226      </Text>
227      <Text color={spec.isPicked || pick === '◆' ? 'claude' : 'inactive'}> {pick} </Text>
228      <Highlighted el={el} text={note.text} query={spec.query ?? ''} width={textWidth} isDim={spec.isHistory} />
229      <Text> </Text>
230      {!spec.isGrouped && <Text color={spec.isHistory ? 'inactive' : colourOf(note.project)}>{fit(note.project, 8).trimEnd().padStart(8)}</Text>}
231      <Text dimColor> {note.age.padStart(4)}</Text>
232    </Box>
233  )
234}
235
236const Row = ({ el, dir, spec }: { el: E; dir: Direction; spec: RowSpec }) =>
237  dir === 'quiet' ? (
238    <QuietRow el={el} spec={spec} />
239  ) : dir === 'cards' ? (
240    <CardsRow el={el} spec={spec} />
241  ) : dir === 'mix' ? (
242    <MixRow el={el} spec={spec} />
243  ) : (
244    <LedgerRow el={el} spec={spec} />
245  )
246
247// ---- header (search / capture) ----
248
249type Header = { mode: 'search' | 'capture' | 'edit'; query: string; right: string; isFocused: boolean }
250
251const HeaderLine = ({ el, dir, width, header }: { el: E; dir: Direction; width: number; header: Header }) => {
252  const { Box, Text } = el
253  const isCapture = header.mode === 'capture'
254  const glyph = isCapture ? '✎' : '❯'
255  const label = isCapture ? 'new note' : ''
256  const caret = header.isFocused ? '▏' : ''
257  const placeholder = isCapture ? 'write a note, ⏎ to save' : 'search notes'
258  const content = (
259    <Box width={dir === 'cards' ? width - 4 : width}>
260      <Text color={isCapture ? 'claude' : header.isFocused ? 'claude' : 'inactive'} bold>
261        {glyph}{' '}
262      </Text>
263      {label !== '' && (
264        <Text color="claude" bold>
265          {label}{' '}
266        </Text>
267      )}
268      {header.query === '' ? (
269        <Text dimColor>
270          {caret}
271          {placeholder}
272        </Text>
273      ) : (
274        <Text bold={isCapture}>
275          {header.query}
276          {caret}
277        </Text>
278      )}
279      {dir === 'mix' && header.mode === 'search' && header.isFocused && <Text dimColor> ⏎ to list</Text>}
280      <Box flexGrow={1} />
281      <Text dimColor>{header.right}</Text>
282    </Box>
283  )
284  if (dir === 'cards') {
285    return (
286      <Box borderStyle="round" borderColor={isCapture ? 'claude' : header.isFocused ? 'promptBorder' : 'inactive'} paddingX={1} width={width}>
287        {content}
288      </Box>
289    )
290  }
291  if (dir === 'ledger' || dir === 'mix') {
292    return (
293      <Box flexDirection="column" width={width}>
294        {content}
295        <Text dimColor>{'━'.repeat(width)}</Text>
296      </Box>
297    )
298  }
299  return (
300    <Box flexDirection="column" width={width}>
301      {content}
302      <Text dimColor>{'─'.repeat(width)}</Text>
303    </Box>
304  )
305}
306
307const LedgerColumns = ({ el, width }: { el: E; width: number }) => {
308  const { Text } = el
309  return <Text dimColor>{`#   ${'note'.padEnd(width - 4 - 12 - 5)}  project     age`}</Text>
310}
311
312// ---- preview ----
313
314const Preview = ({ el, dir, width, note }: { el: E; dir: Direction; width: number; note: Note }) => {
315  const { Box, Text } = el
316  const who = note.by === 'claude' ? '◆ claude' : note.by === 'phone' ? 'phone' : 'you'
317  const meta = [who, PATHS[note.project] || 'unfiled', note.branch, `${note.age} ago`].filter(Boolean).join(' · ')
318  const body = (
319    <Box flexDirection="column">
320      <Text wrap="wrap">{note.text}</Text>
321      <Text dimColor>{meta}</Text>
322    </Box>
323  )
324  if (dir === 'cards') {
325    return (
326      <Box borderStyle="round" borderColor="inactive" paddingX={1} width={width} flexDirection="column">
327        {body}
328      </Box>
329    )
330  }
331  return (
332    <Box flexDirection="column" width={width}>
333      <Text dimColor>{(dir === 'ledger' ? '┄' : '─').repeat(width)}</Text>
334      {body}
335    </Box>
336  )
337}
338
339// ---- footer ----
340
341type Key = [string, string]
342// The pane's footers as keysFor (plugin/src/model.ts) shows them: a text field's `keys` is the chord.
343const FIELD_KEYS: Key = ['ctrl+x i', 'keys']
344// `ctrl+s` names where it goes: all projects from this project's scope, this project from all.
345const SEARCH_KEYS: Key[] = [['ctrl+s', 'all projects'], ['ctrl+n', 'new'], ['ctrl+q', 'close'], FIELD_KEYS]
346// Nothing picked: the note's own actions lead, then move and copy, as the pane's row does.
347const ROW_KEYS: Key[] = [
348  ['t', 'to prompt'],
349  ['s', 'send'],
350  ['e', 'edit'],
351  ['d', 'archive'],
352  ['m', 'move'],
353  ['y', 'copy'],
354  ['v', 'pick'],
355  ['z', 'fold'],
356  ['h', 'history'],
357  ['i', 'keys'],
358]
359const UNFOCUSED_KEYS: Key[] = [
360  ['ctrl+x tab', 'focus'],
361  ['ctrl+x s', 'close'],
362]
363// The pane's first four pairs rank before the legend (WIDTH.footerPairs).
364const FIRST_PAIRS = 4
365
366const isSheetPair = ([key]: Key) => key === 'i' || key === FIELD_KEYS[0]
367const pairSize = ([key, label]: Key) => key.length + (label === '' ? 0 : 1 + label.length)
368
369// The pane's fitFooter, on one line: the first four actions, the legend, then the rest, dropped
370// from the right until the line fits; `i keys` stays on the right. Shown in order, the legend last.
371const fitFooter = (keys: Key[], legend: string | undefined, lead: string, width: number) => {
372  const sheet = keys.find(isSheetPair)
373  const actions = keys.filter(pair => !isSheetPair(pair))
374  const legendPair: Key | undefined = legend === undefined ? undefined : [legend, '']
375  let kept = [...actions.slice(0, FIRST_PAIRS), ...(legendPair ? [legendPair] : []), ...actions.slice(FIRST_PAIRS)]
376  // As the pane's footerRows: a pair that alone is wider than the line still takes it. The spacer
377  // before `i keys` takes one more gap than the pairs between them, hence `width - 2`.
378  const isOneLine = () => {
379    let used = lead.length
380    for (const pair of [...kept, ...(sheet ? [sheet] : [])]) {
381      if (used > 0 && used + 2 + pairSize(pair) > width - 2) return false
382      used += (used === 0 ? 0 : 2) + pairSize(pair)
383    }
384    return true
385  }
386  while (kept.length > 0 && !isOneLine()) kept = kept.slice(0, -1)
387  return { pairs: kept.filter(pair => pair !== legendPair), legend: legendPair && kept.includes(legendPair) ? legend : undefined, sheet }
388}
389
390const Footer = ({ el, dir, width, keys, status, legend }: { el: E; dir: Direction; width: number; keys: Key[]; status?: string; legend?: string }) => {
391  const { Box, Text } = el
392  if (dir === 'cards') {
393    const [first, second, ...rest] = keys
394    return (
395      <Box flexDirection="column" width={width}>
396        <Box gap={1}>
397          {[first, second].filter((key): key is Key => key !== undefined).map(([k, label]) => (
398            <Text bold color="claude">
399              [ {k} {label} ]
400            </Text>
401          ))}
402          <Box flexGrow={1} />
403          {status !== undefined && <Text color="claude">{status}</Text>}
404        </Box>
405        <Box flexWrap="wrap" columnGap={2}>
406          {rest.map(([k, label]) => (
407            <Text dimColor>
408              {k} {label}
409            </Text>
410          ))}
411          {legend !== undefined && <Text dimColor>{legend}</Text>}
412        </Box>
413      </Box>
414    )
415  }
416  const fitted = fitFooter(keys, legend, status ?? '', width)
417  const Pair = ({ pair: [k, label] }: { pair: Key }) => (
418    <Text>
419      <Text color={dir === 'quiet' ? 'claude' : undefined} bold={dir === 'ledger' || dir === 'mix'}>
420        {k}
421      </Text>
422      {label !== '' && <Text dimColor> {label}</Text>}
423    </Text>
424  )
425  return (
426    <Box flexDirection="column" width={width}>
427      {dir === 'ledger' && <Text dimColor>{'━'.repeat(width)}</Text>}
428      {dir === 'mix' && <Text dimColor>{'─'.repeat(width)}</Text>}
429      <Box columnGap={2} width={width} height={1}>
430        {status !== undefined && (
431          <Text color="claude" bold>
432            {status}
433          </Text>
434        )}
435        {fitted.pairs.map(pair => (
436          <Pair pair={pair} />
437        ))}
438        {fitted.legend !== undefined && <Text dimColor>{fitted.legend}</Text>}
439        <Box flexGrow={1} />
440        {fitted.sheet && <Pair pair={fitted.sheet} />}
441      </Box>
442    </Box>
443  )
444}
445
446// ---- group header (list view) ----
447
448const GroupHeader = ({ el, dir, width, project, count, isFolded }: { el: E; dir: Direction; width: number; project: string; count: number; isFolded?: boolean }) => {
449  const { Box, Text } = el
450  const fold = isFolded ? '▸' : '▾'
451  if (dir === 'cards') {
452    return (
453      <Box width={width}>
454        <Text dimColor>{fold} </Text>
455        <Pill el={el} project={project} />
456        <Text dimColor> {count}</Text>
457      </Box>
458    )
459  }
460  if (dir === 'ledger') {
461    const label = ` ${project} · ${count} `
462    return (
463      <Text>
464        <Text dimColor>{fold}─</Text>
465        <Text color={colourOf(project)}>{label}</Text>
466        <Text dimColor>{'─'.repeat(Math.max(0, width - label.length - 2))}</Text>
467      </Text>
468    )
469  }
470  return (
471    <Text>
472      <Text dimColor>{fold} </Text>
473      <Text color={colourOf(project)} bold>
474        {project}
475      </Text>
476      {dir !== 'mix' && <Text dimColor> · {count}</Text>}
477    </Text>
478  )
479}
480
481// ---- views ----
482
483type Ctx = { el: E; dir: Direction; width: number }
484
485const rowsOf = (
486  ctx: Ctx,
487  notes: Note[],
488  options: { selected?: string; picked?: string[]; query?: string; isHistory?: boolean; isGrouped?: boolean; firstNumber?: number } = {},
489) =>
490  notes.map((note, i) => (
491    <Row
492      el={ctx.el}
493      dir={ctx.dir}
494      spec={{
495        note,
496        width: ctx.width,
497        number: (options.firstNumber ?? 1) + i,
498        isSelected: note.id === options.selected,
499        isPicked: options.picked?.includes(note.id),
500        showPicks: (options.picked?.length ?? 0) > 0,
501        query: options.query,
502        isHistory: options.isHistory,
503        isGrouped: options.isGrouped,
504      }}
505    />
506  ))
507
508const legendFor = (notes: Note[]) => (notes.some(note => note.by === 'claude') ? '◆ from Claude' : undefined)
509
510// Unfocused: the pane isn't holding the keyboard, so its footer shows only the chords that work
511// from the prompt.
512const SearchView = (ctx: Ctx, query: string, isUnfocused = false) => {
513  const { Box, Text } = ctx.el
514  const here = NOTES.filter(note => note.project === CURRENT)
515  const found = query === '' ? here : matches(query)
516  const scope = query === '' ? 'this project' : 'all'
517  const total = query === '' ? here.length : NOTES.length
518  const right = query === '' ? `${scope} · ${here.length} open` : `${scope} · ${found.length} of ${total}`
519  return (
520    <Box flexDirection="column" width={ctx.width}>
521      <HeaderLine el={ctx.el} dir={ctx.dir} width={ctx.width} header={{ mode: 'search', query, right, isFocused: !isUnfocused }} />
522      {ctx.dir === 'ledger' && <LedgerColumns el={ctx.el} width={ctx.width} />}
523      {found.length === 0 ? (
524        <Box flexDirection="column" paddingY={1}>
525          <Text dimColor>No notes match. ⏎ saves it to cc.</Text>
526        </Box>
527      ) : (
528        <Box flexDirection="column">{rowsOf(ctx, found, { query })}</Box>
529      )}
530      {found[0] !== undefined && <Preview el={ctx.el} dir={ctx.dir} width={ctx.width} note={found[0]} />}
531      <Box height={1} />
532      <Footer
533        el={ctx.el}
534        dir={ctx.dir}
535        width={ctx.width}
536        keys={
537          isUnfocused
538            ? UNFOCUSED_KEYS
539            : found.length === 0
540              ? [['⏎', 'save as note'], ['ctrl+s', 'this project'], ['ctrl+q', 'close'], FIELD_KEYS]
541              : query === ''
542                ? SEARCH_KEYS
543                : [['ctrl+s', 'this project'], ...SEARCH_KEYS.slice(1)]
544        }
545        legend={legendFor(found)}
546      />
547    </Box>
548  )
549}
550
551const GROUPS = ['cc', 'infra', 'api', 'unfiled']
552
553const ListView = (ctx: Ctx, options: { folded?: string[]; history?: boolean; picked?: string[]; selected: string }) => {
554  const { Box } = ctx.el
555  let shown = 0
556  const groups = GROUPS.map(project => {
557    const notes = NOTES.filter(note => note.project === project)
558    const history = options.history ? HISTORY.filter(note => note.project === project) : []
559    const isFolded = options.folded?.includes(project)
560    const firstNumber = shown + 1
561    if (!isFolded) shown += notes.length + history.length
562    return (
563      <Box flexDirection="column">
564        <GroupHeader el={ctx.el} dir={ctx.dir} width={ctx.width} project={project} count={notes.length} isFolded={isFolded} />
565        {!isFolded && rowsOf(ctx, notes, { selected: options.selected, picked: options.picked, isGrouped: true, firstNumber })}
566        {!isFolded && history.length > 0 && rowsOf(ctx, history, { selected: options.selected, isHistory: true, isGrouped: true, firstNumber: firstNumber + notes.length })}
567      </Box>
568    )
569  })
570  const selected = [...NOTES, ...HISTORY].find(note => note.id === options.selected)
571  const picked = options.picked?.length ?? 0
572  return (
573    <Box flexDirection="column" width={ctx.width}>
574      <HeaderLine
575        el={ctx.el}
576        dir={ctx.dir}
577        width={ctx.width}
578        header={{ mode: 'search', query: '', right: `list · all · ${NOTES.length} open${options.history ? ' + history' : ''}`, isFocused: false }}
579      />
580      <Box flexDirection="column" gap={ctx.dir === 'cards' ? 1 : 0}>
581        {groups}
582      </Box>
583      {selected !== undefined && <Preview el={ctx.el} dir={ctx.dir} width={ctx.width} note={selected} />}
584      <Box height={1} />
585      <Footer
586        el={ctx.el}
587        dir={ctx.dir}
588        width={ctx.width}
589        keys={
590          options.history
591            ? [['u', 'restore'], ['h', 'hide history'], ['z', 'fold'], ['f', 'search'], ['i', 'keys']]
592            : picked > 0
593              ? [['b', 'bundle'], ['v', 'pick'], ['x', 'clear picks'], ['t', 'to prompt'], ['i', 'keys']]
594              : ROW_KEYS
595        }
596        status={picked > 0 ? `${picked} picked` : undefined}
597        legend={picked > 0 ? undefined : legendFor(NOTES)}
598      />
599    </Box>
600  )
601}
602
603const BundleView = (ctx: Ctx) => {
604  const { Box, Text } = ctx.el
605  const picked = ['a', 'c', 'f'].map(id => NOTES.find(note => note.id === id)).filter((note): note is Note => note !== undefined)
606  const prompt = [
607    'Please look at these notes from my ostrakon:',
608    '',
609    ...picked.map(note => `- ${note.project === CURRENT ? '' : `[${note.project}] `}${note.text}`),
610  ]
611  return (
612    <Box flexDirection="column" width={ctx.width}>
613      <Box width={ctx.width}>
614        <Text color="claude" bold>
615          ⇢ bundle{' '}
616        </Text>
617        <Text>3 notes into one prompt</Text>
618        <Box flexGrow={1} />
619        <Text dimColor>1 from infra</Text>
620      </Box>
621      <Text dimColor>{'─'.repeat(ctx.width)}</Text>
622      <Box borderStyle={ctx.dir === 'cards' ? 'round' : 'quote'} borderColor="inactive" paddingX={ctx.dir === 'cards' ? 1 : 0} flexDirection="column" width={ctx.width}>
623        {prompt.map(line => (
624          <Text wrap="wrap">{line === '' ? ' ' : line}</Text>
625        ))}
626      </Box>
627      <Box height={1} />
628      <Text dimColor>The picked notes are marked sent once the prompt goes in. Nothing is removed before.</Text>
629      <Box height={1} />
630      <Footer el={ctx.el} dir={ctx.dir} width={ctx.width} keys={[['⏎', 'send'], ['t', 'to prompt (edit first)'], ['esc', 'back']]} />
631    </Box>
632  )
633}
634
635const CaptureView = (ctx: Ctx) => {
636  const { Box, Text } = ctx.el
637  const saved = ['check whether the hub needs a nightly backup cron', 'ask about arm runner minutes']
638  return (
639    <Box flexDirection="column" width={ctx.width}>
640      <HeaderLine
641        el={ctx.el}
642        dir={ctx.dir}
643        width={ctx.width}
644        header={{ mode: 'capture', query: 'the inline pane only has 11 rows at 100 columns', right: 'cc', isFocused: true }}
645      />
646      <Box flexDirection="column" paddingY={1}>
647        {saved.map(text => (
648          <Text>
649            <Text color="success">✓ </Text>
650            <Text>{text}</Text>
651            <Text dimColor> · just now</Text>
652          </Text>
653        ))}
654      </Box>
655      <Text dimColor>Notes save to cc. Keep typing for the next one.</Text>
656      <Box height={1} />
657      <Footer el={ctx.el} dir={ctx.dir} width={ctx.width} keys={[['⏎', 'save'], ['esc', 'back to search'], ['ctrl+s', 'project'], FIELD_KEYS]} />
658    </Box>
659  )
660}
661
662const EditView = (ctx: Ctx) => {
663  const { Box, Text } = ctx.el
664  const here = NOTES.filter(note => note.project === CURRENT)
665  return (
666    <Box flexDirection="column" width={ctx.width}>
667      <HeaderLine el={ctx.el} dir={ctx.dir} width={ctx.width} header={{ mode: 'search', query: '', right: `this project · ${here.length} open`, isFocused: false }} />
668      {rowsOf(ctx, here.slice(0, 1))}
669      <Box width={ctx.width} borderStyle="round" borderColor="claude" flexDirection="column" paddingX={1}>
670        <Text>
671          <Text color="claude" bold>
672            edit{' '}
673          </Text>
674          rename the store helpers to match the spec (createStore, change, scan) and the tests▏ ⏎ save
675        </Text>
676        <Box gap={2}>
677          <Text>[ esc back ]</Text>
678          <Text color="claude" bold>
679            [ ⏎ save ]
680          </Text>
681          <Box flexGrow={1} />
682          <Text dimColor>draft kept if the pane closes</Text>
683        </Box>
684      </Box>
685      {rowsOf(ctx, here.slice(2), { firstNumber: 3 })}
686      <Box height={1} />
687      <Footer el={ctx.el} dir={ctx.dir} width={ctx.width} keys={[['⏎', 'save'], ['esc', 'back, draft kept'], FIELD_KEYS]} />
688    </Box>
689  )
690}
691
692const EmptyView = (ctx: Ctx) => {
693  const { Box, Text } = ctx.el
694  const ways: [string, string][] = [
695    ['//', 'in the prompt, even mid-turn: // check the flaky test ⏎  (space first for a literal //)'],
696    ['ctrl+x s', 'opens this pane, and keeps your prompt draft'],
697    ['phone', 'my-server.ts.net: notes land here within seconds'],
698    ['◆', 'Claude can leave notes for you'],
699  ]
700  return (
701    <Box flexDirection="column" width={ctx.width}>
702      <HeaderLine el={ctx.el} dir={ctx.dir} width={ctx.width} header={{ mode: 'search', query: '', right: 'this project · 0 open', isFocused: true }} />
703      <Box flexDirection="column" paddingY={1} paddingX={2} borderStyle={ctx.dir === 'cards' ? 'round' : undefined} borderColor="inactive">
704        <Text bold>Nothing pending in cc.</Text>
705        <Box height={1} />
706        {ways.map(([key, text]) => (
707          <Text>
708            <Text color="claude" bold>
709              {key.padEnd(10)}
710            </Text>
711            <Text dimColor>{text}</Text>
712          </Text>
713        ))}
714      </Box>
715      <Footer el={ctx.el} dir={ctx.dir} width={ctx.width} keys={[['ctrl+n', 'new'], ['ctrl+s', 'all projects'], ['ctrl+q', 'close'], FIELD_KEYS]} />
716    </Box>
717  )
718}
719
720// Nothing open here, but some history: this project's heading stands in for the empty page.
721const EmptyHistoryView = (ctx: Ctx) => {
722  const { Box } = ctx.el
723  return (
724    <Box flexDirection="column" width={ctx.width}>
725      <HeaderLine el={ctx.el} dir={ctx.dir} width={ctx.width} header={{ mode: 'search', query: '', right: 'this project · 0 open', isFocused: true }} />
726      <GroupHeader el={ctx.el} dir={ctx.dir} width={ctx.width} project={CURRENT} count={0} />
727      <Box height={1} />
728      <Footer el={ctx.el} dir={ctx.dir} width={ctx.width} keys={[['↓', 'history'], ...SEARCH_KEYS]} />
729    </Box>
730  )
731}
732
733const render = (ctx: Ctx, name: string) => {
734  switch (name) {
735    case 'search-empty':
736      return SearchView(ctx, '')
737    case 'search-typing':
738      return SearchView(ctx, 'cache')
739    case 'search-nomatch':
740      return SearchView(ctx, 'kubernetes')
741    case 'unfocused':
742      return SearchView(ctx, '', true)
743    case 'list-grouped':
744      return ListView(ctx, { selected: 'b' })
745    case 'list-folded':
746      return ListView(ctx, { selected: 'b', folded: ['infra', 'api'] })
747    case 'list-history':
748      return ListView(ctx, { selected: 'x', history: true, folded: ['infra', 'api', 'unfiled'] })
749    case 'picked':
750      return ListView(ctx, { selected: 'f', picked: ['a', 'c', 'f'] })
751    case 'bundle':
752      return BundleView(ctx)
753    case 'capture':
754      return CaptureView(ctx)
755    case 'edit':
756      return EditView(ctx)
757    case 'empty-history':
758      return EmptyHistoryView(ctx)
759    default:
760      return EmptyView(ctx)
761  }
762}
763
764// ---- the band ----
765
766const POCKET = NOTES.filter(note => note.project === CURRENT)
767const POCKET_MANY: Note[] = [
768  ...POCKET,
769  ...['bump bun to 1.3 in the hub image', 'screenshot the inline pane at 100 cols', 'ask about arm runner minutes', 'tidy the fixture generator'].map(
770    (text, i): Note => ({ id: `p${i}`, project: CURRENT, age: `${i + 3}d`, text }),
771  ),
772]
773const chipLabel = (note: Note) => `${note.by === 'claude' ? '◆ ' : ''}${fit(note.text, 18).trimEnd()}`
774
775export const register: Register = on => {
776  on('session.start', async ($, e, next) => {
777    await $.command.register({ name: 'mock', description: 'mockups: /mock <quiet|cards|ledger|mix> <view>', immediate: true })
778    await $.command.register({ name: 'mockband', description: 'mockups: /mockband <off|a|b> <pocket0|pocket3|pocket9|harvest>', immediate: true })
779    return next(e)
780  })
781
782  on('command.run', { command: 'mock' }, async ($, e) => {
783    const [dir = 'quiet', name = 'search-empty'] = String(e.args).trim().split(/\s+/)
784    await update($, direction, () => dir)
785    await update($, view, () => (VIEWS.includes(name) ? name : 'search-empty'))
786    const opened = await $.ui.open({ id: PANE, title: 'ostrakon', closeOnEscape: true })
787    return { text: `mock ${dir} ${name} ${opened.isPlaced ? '' : opened.reason}` }
788  })
789
790  on('command.run', { command: 'mockband' }, async ($, e) => {
791    const [style = 'off', which = 'pocket3'] = String(e.args).trim().split(/\s+/)
792    await update($, band, () => (style === 'off' ? 'off' : `${style}:${which}`))
793    return { text: `band ${style} ${which}` }
794  })
795
796  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
797    const el = $.ui.resolve(e) as E
798    const dir = (await read($, direction)) as Direction
799    const name = await read($, view)
800    return render({ el, dir, width: e.props.bodyColumns - 1 }, name)
801  })
802
803  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
804    const setting = await read($, band)
805    if (setting === 'off' || e.surface !== 'terminal' || e.props.hasSurvey) return next(e)
806    const { Box, Text, Button } = $.ui.resolve(e)
807    const [style, which] = setting.split(':')
808    const below = await next(e)
809    if (which === 'harvest') {
810      const proposals = [
811        'retry ignores Retry-After on 429',
812        'the arm runner image is 3 weeks old',
813        'merge.ts has no test for tombstones',
814      ]
815      return (
816        <Box flexDirection="column">
817          {below}
818          <Box gap={2}>
819            <Text color="claude" bold>
820              ◆ 3 notes from this turn
821            </Text>
822            {proposals.map((text, i) => (
823              <Button key={`h${i}`} plain hotkey={String(i + 1)} label={fit(text, 22).trimEnd()} onPress={() => undefined} />
824            ))}
825            <Button key="h0" plain hotkey="0" label="keep all" onPress={() => undefined} />
826            <Button key="hopen" plain label="✎" onPress={() => undefined} />
827          </Box>
828          <Text dimColor>1–3 keep one · 0 keep all · the rest wait in the pane under “proposed”</Text>
829        </Box>
830      )
831    }
832    const notes = which === 'pocket0' ? [] : which === 'pocket3' ? POCKET.slice(0, 3) : POCKET_MANY
833    const shown = notes.slice(0, 5)
834    const more = notes.length - shown.length
835    if (style === 'b') {
836      return (
837        <Box flexDirection="column">
838          {below}
839          <Box gap={1}>
840            <Text color={notes.length > 0 ? 'claude' : 'inactive'}>✎ {CURRENT}</Text>
841            {notes.length > 0 && <Text dimColor>│</Text>}
842            {shown.map((note, i) => (
843              <Button key={`p${i}`} plain hotkey={String(i + 1)} label={chipLabel(note)} onPress={() => undefined} />
844            ))}
845            {more > 0 && <Text dimColor>+{more} more</Text>}
846            <Box flexGrow={1} />
847            <Text dimColor>{notes.length > 0 ? 'digit ⏎ to use' : 'ctrl+x s · // to jot'}</Text>
848          </Box>
849        </Box>
850      )
851    }
852    return (
853      <Box flexDirection="column">
854        {below}
855        <Box gap={2}>
856          {shown.map((note, i) => (
857            <Button key={`p${i}`} plain hotkey={String(i + 1)} label={chipLabel(note)} onPress={() => undefined} />
858          ))}
859          {more > 0 && <Button key="more" plain dimColor label={`+${more}`} onPress={() => undefined} />}
860          <Button key="open" plain label="✎" onPress={() => undefined} />
861        </Box>
862      </Box>
863    )
864  })
865}
866
types/index.d.ts 12 lines
1export type SpmockPlaceholder = never
2
3declare module 'claude-code' {
4  interface PluginState {
5    spmock: {
6      direction: string
7      view: string
8      band: string
9    }
10  }
11}
12