A denser Claude Code status line and a pane of the files, links and folders this session produced, with a fuzzy filter and four palettes.

A denser Claude Code status line and a pane of the files, links and folders your session produced, with a fuzzy filter.

The status line, one row:
Opus 5.5 │ Coding │ main* +12 -3 │ ▪▪▪▪▪ 3 · 1h 20m

Opus 5.5 is the model.Coding is the directory the session runs in.main* is the branch, with * when there is uncommitted work, ↑2 ↓1 when it is ahead of or behind its upstream, and detached in red when there is no branch.+12 -3 is the lines added and removed against HEAD, shown only when the tree is dirty.▪▪▪▪▪ is the context window, one square per 20 %. It turns from calm to yellow to red as it fills.3 (after a file icon) is how many rows the Files pane holds: files, links and folders alike.1h 20m (after a clock icon) is how long the session has run.When the terminal is too narrow, segments drop in this order: model, directory, file count, churn, clock, branch, and the context bar last. The row never wraps.
The pane opens with /files or ctrl+x f. It is the session's hub: the files, links and folders this session produced, newest first, eight to a page, the newest 48 kept. Each row starts with its kind (▪ file, ↗ link, ▸ folder) and ends with a muted tail that says where it is: the file's folder, the link's host and port, the folder's parent.

On a terminal narrower than 110 columns the pane sits inline above the prompt and a page is as long as the rows it is given; the hint shrinks to one row:

Keys: Enter or the row's digit (1–8) opens the row; j/k move the selection and wrap around (k on the first row reaches the last entry of the last page, j on the last entry the first row); h/l turn the page and wrap likewise; o opens the folder the row sits in (a folder opens itself; a link has none); f finds: a field appears, the list narrows as you type (fuzzy over the name and the tail: the typed characters in order, gaps allowed), Enter opens the top match, Tab moves into the matches (walk them as above) and f brings you back to the field with your text kept, Esc returns to the list; Esc in the list closes the pane. The arrows and Tab also walk the selection, since a pane cannot bind them. A thing that opened takes you to another app and the pane closes behind it. When the newest file is a PNG, it is also drawn in the pane, in terminals that can show pictures (kitty and Ghostty); elsewhere a line says so. The preview hides while you filter.

What counts:
/c/Users/… is read as C:/Users/…. Also an absolute path to one alone on a reply line, when the file exists (Claude listing files it wants you to see). A file:// link in a reply counts on the same lines a web link does (see below) and becomes the file or folder row it points at.gh pr create / gh issue create / gh release create, a deploy tool (mcp__*deploy*), and a dev server a command started (localhost, 127.0.0.1, a LAN address with a port; 0.0.0.0 is shown as localhost). Other URLs in command output (registry notices, docs) are not collected. And from a reply, as it streams: a link alone on its line (bare, a bullet, or text), or on a line that contains one of the open words — open, öffne, ansehen, view, review by default, the openWords option in the config menu.mkdir and git worktree add in a command (once it exists), and an absolute path alone on a reply line that is a directory.A file or folder that vanished drops off the list; a link is never checked. The status-line count is every row the pane holds.
Leaving files out. On first start the mod writes ~/.claude/cockpit/ignore (under CLAUDE_CONFIG_DIR if you set one). Every line in it starts commented out, so nothing is left out until you say so. It lists the usual configuration files (package.json, tsconfig.json, requirements.txt, *.log and others): remove the # in front of one to keep it off the list, or add your own lines. A pattern without / matches the file name in any folder, one with / the end of the full path; * is any run of characters within a folder, ? one character, and case does not count. The file is read again every 30 seconds, so an edit takes effect without a restart, and a listed file it now names drops off.
plain.Inside Claude Code:
/plugin install cockpit --marketplace LolerHero/claude-cockpit
or from your shell: claude plugin marketplace add LolerHero/claude-cockpit, then claude plugin install cockpit@cockpit. That installs the Files pane and /files.
A plugin cannot set your status line or your keybindings, so one more step wires those up, from the copy the install made:
node ~/.claude/plugins/marketplaces/cockpit/setup.mjs # macOS, Linux
node "$env:USERPROFILE\.claude\plugins\marketplaces\cockpit\setup.mjs" # Windows PowerShell
Add --palette tokyo-night, --glyphs plain, --dry-run or --force as needed, then restart claude. The status line runs from that copy, which /plugin updates in place, so updates reach it too.
From source instead: git clone https://github.com/LolerHero/claude-cockpit, then node setup.mjs in the clone; setup then also loads the plugin from that folder. To stay on a release tested against your Claude Code build, clone its tag (git clone --branch v0.2.6 …); CHANGELOG.md names the build each release was tested on.
What setup changes, in ~/.claude (or CLAUDE_CONFIG_DIR):
settings.json → statusLine runs statusline/statusline.mjs. A status line you already have is kept unless you pass --force.settings.json → env.CLAUDE_CODE_PLUGIN_DIRS gains the folder, so the plugin loads in every session. Only from a source clone: installed through /plugin it loads already.keybindings.json → ctrl+x f opens /files, unless that chord is already bound to something else.settings.json is backed up next to itself before the first write. --dry-run prints the changes and writes nothing.
rose-pine (the default), catppuccin-mocha, tokyo-night and ansi. ansi uses your terminal's own 16 colors, so it follows whatever theme you run and works without truecolor.
The palette, the glyphs and the open words are options of the cockpit plugin in Claude Code's config menu. Change them there and the next redraw picks them up (openWords on the next session).
The mod runs inside Claude Code and writes the file count and the terminal width to ~/.claude/cockpit/<session id>.json, one small file per session, so two open sessions never mix their numbers. The status line is a separate Node process that reads its session's file, plus settings.json for your options. Both draw from palettes.js: the status line its colours, the Files pane its ground (base), with your terminal's own foreground on it.
Everything the mod in hooks/register.tsx reads, writes and runs. It makes no network requests and sends nothing anywhere; a link opens in your browser only when you pick it.
~/.claude/cockpit/ignore once, with every line commented out, if it does not exist yet (see Leaving files out); it is read at start and every 30 seconds and never written again. And ~/.claude/cockpit/<session id>.json (under CLAUDE_CONFIG_DIR if you set one), holding { "files": <count>, "columns": <terminal width> }. The status line script reads it to draw the count and to fit the row; the width comes from a hook on the row above the prompt (AbovePrompt), which measures it and draws nothing of its own. The path includes the session id, so it cannot be written as fixed text. Nothing else is written by the mod; setup.mjs, which you run yourself, edits settings.json and keybindings.json as listed under Install.CLAUDE_CONFIG_DIR, USERPROFILE and HOME to find the config folder for that file, and OS to tell Windows apart when opening something.classic.MessageDisplay) and on tool calls (tool.call, including Write and Edit) look for the files, links and folders to list, and pass every reply and call on unchanged. After a session switch the list is rebuilt from the same session's transcript. The list lives in the session's own state; nothing from the conversation leaves Claude Code.o for its folder) runs your system's opener with that file, folder or link: on Windows cmd /c start "" <path> for a file or folder and rundll32 url.dll,FileProtocolHandler <url> for a link, on macOS open <target>, on Linux xdg-open <target>. The target is built from the row, which is why the command cannot be written as fixed text.uname once, to tell macOS (open) from Linux (xdg-open)./files, which opens the pane. The pane's own keys work only while it is open.claude plugin validate .
claude plugin test .
node --test "test/*.test.mjs"
MIT
hooks/register.tsx 912 lines1// cockpit — a pane of what this session made, and the figures the status line needs.
2//
3// Opus 5.5 │ Coding │ main* │ ▪▪▪▪▪ 3 · 1h 20m ← status line
4//
5// 1 Open 2026-10-03-report.pdf ← the pane: /files, /shots, or ctrl+x f
6// 2 Open home-1440.png
7//
8// THE PANE: files a tool wrote or produced this session, newest first, one key each. Only things
9// a person opens (documents, images, archives) — never source, which belongs in the editor.
10// THE STATUS FILE: the status line is a separate Node process and cannot measure the terminal or
11// count files; this module publishes both to <config dir>/cockpit/<session id>.json on every change.
12//
13// The hint line under the prompt is left to the engine. Tried and dropped on 2.1.288: the hint
14// prop carries only the coaching text, the mode words are a pill no hook sees, and a rewritten
15// hint is drawn as its own element even when empty, between two separators.
16
17import { paletteOf } from '../palettes.js'
18import { atom, read, update } from 'claude-code'
19import type { Register, EngineInterface } from 'claude-code'
20
21import type { Doc, Entry, EntryKind } from '../types'
22
23const PANE = 'files'
24export const KEEP = 48
25// One page is what the dialog asks rows for, whatever the list holds: a dialog taller than the
26// terminal pushed every redraw (spinner ticks) into scrollback, stacking copies over the chat.
27export const PER_PAGE = 8
28const INLINE_MAX_BYTES = 400_000 // a tree carries bounded text; a big PNG gets the button alone
29// The hint is two rows: the walk (j k h n/N l) and the actions (o f, what Enter and Esc do).
30export const HINT_ROWS = 2
31export const IMAGE_ROWS = 10 // the inline preview's height in cells; `openPane` asks room for it
32// 8 rows + 2 hint rows + 10-row image and its gap = 21 rows: inside a normal window.
33
34// The key reaches the pane through `/files`, not a Button `action`: ~/.claude/keybindings.json
35// binds `ctrl+x f` to `command:files` in the Chat context (setup.mjs writes that binding).
36
37const files = atom({ plugin: 'cockpit', key: 'files' } as const, [])
38
39// Legacy rows (`{ path }`, before v0.2.0) are read as files: the state outlives an update of the module.
40const asEntry = (d: Entry | Doc): Entry =>
41 'target' in d ? d : { kind: 'file', target: d.path, label: d.label, tail: tailOf('file', d.path), at: d.at }
42
43// Trimmed on read, not only on the next write: a session that stored more under an older, larger
44// KEEP showed all of it until a new file came in.
45const stored = async ($: EngineInterface) => (await read($, files)).slice(-KEEP).map(asEntry)
46
47// Which page the pane shows and which row on it holds the focus ring. Module-level: a reload
48// starts on page 1, which is where a reopened pane starts anyway.
49let page = 0
50let focused = 0
51// Filter mode: `f` draws an Input (key `q`) whose text narrows the list; Esc returns to the list.
52let filtering = false
53let query = ''
54
55// Module-level: a reload starts at 0 until the next draw measures again; the status line then
56// falls back to its own width sources.
57let columns = 0
58
59// `$.env`, never `process.env`: the module runs in an environment of its own, with no Node.
60const configDir = async ($: EngineInterface) => {
61 const set = await $.env.get('CLAUDE_CONFIG_DIR').catch(() => null)
62 if (set) return set
63 const home = (await $.env.get('USERPROFILE').catch(() => null)) ?? (await $.env.get('HOME').catch(() => null))
64 return home ? `${home}/.claude` : null
65}
66
67// One file per session (`cockpit/<session id>.json`, the id the status line's payload carries as
68// `session_id`), so two open sessions never draw each other's count or width. Never rejects: it
69// runs un-awaited from a render, where a rejection has no one to land on.
70// ponytail: one ~40-byte file per session, never pruned; prune by age if the folder ever matters.
71const publish = async ($: EngineInterface) => {
72 try {
73 const dir = await configDir($)
74 const id = await $.session.id()
75 if (!dir || !/^[\w-]+$/.test(id)) return
76 // Counts what is still on disk, and drops the rest from the list, so a deleted file leaves
77 // the count and the pane together. At most KEEP exists checks. Links are taken as given.
78 // The count is every row: a link or folder behind a 0 in the bar is one no one opens.
79 // A file the ignore file has since named goes the same way.
80 const docs = await stored($)
81 const gone = new Set<string>()
82 for (const e of docs) {
83 if (e.kind === 'link') continue
84 if ((e.kind === 'file' && ignored(e.target)) || !(await $.fs.exists(e.target).catch(() => false))) gone.add(e.target)
85 }
86 if (gone.size) await update($, files, list => list.map(asEntry).filter(e => !gone.has(e.target)))
87 const fileCount = docs.filter(e => !gone.has(e.target)).length
88 await $.fs.write(`${dir}/cockpit/${id}.json`, JSON.stringify({ files: fileCount, columns }))
89 } catch {
90 // the status line falls back to its own width sources and omits the count
91 }
92}
93
94// ─── what this session made ──────────────────────────────────────────────────────────────────
95
96// Things a person opens, not things a person greps. Deliberately NOT .ts/.py — source belongs in
97// the editor, and listing it buries the one file they wanted among forty imports. txt/json/log
98// joined 2026-10-09 (Julian): a password file, a data export and a backup log are ones to open;
99// the config files that come with .json are the ignore file's to leave out, not the list's.
100const OPENABLE = 'png|jpe?g|webp|gif|svg|pdf|docx?|xlsx?|pptx?|csv|md|html?|zip|txt|json|log'
101
102// ─── the ignore file ─────────────────────────────────────────────────────────────────────────
103
104// <config dir>/cockpit/ignore, written once with every line commented out: nothing is left out
105// until the person says so. Read at session start and on the 30 s clock, so an edit takes effect
106// without a restart.
107export const IGNORE_TEMPLATE = `# cockpit: files the Files pane leaves out.
108#
109# One pattern a line; "#" starts a comment. A pattern without "/" matches the file name in any
110# folder; one with "/" matches the end of the full path (write "/" on Windows too). "*" is any
111# run of characters within one folder, "?" one character. Case does not count.
112# Uncomment a line to leave that file out, or add your own.
113
114# Package and build configuration
115# package.json
116# package-lock.json
117# tsconfig.json
118# tsconfig.*.json
119# jsconfig.json
120# composer.json
121# deno.json
122# biome.json
123# turbo.json
124# vercel.json
125# components.json
126# .eslintrc.json
127# .prettierrc.json
128# appsettings*.json
129# .vscode/*.json
130
131# Python and other text manifests
132# requirements*.txt
133# robots.txt
134# LICENSE.txt
135# CMakeLists.txt
136
137# Logs
138# npm-debug.log*
139# yarn-error.log
140# *.log
141`
142
143const globPart = (glob: string) =>
144 glob.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^/]*').replace(/\?/g, '[^/]')
145
146// The patterns of an ignore file as one test over a forward-slash path. Not text (a missing or
147// unreadable file): nothing is left out.
148export const ignoreMatcher = (text: unknown): ((path: string) => boolean) => {
149 if (typeof text !== 'string') return () => false
150 const tests = text
151 .split(/\r?\n/)
152 .map(l => l.trim())
153 .filter(l => l && !l.startsWith('#'))
154 .map(p => p.replace(/\\/g, '/').replace(/^\/+/, ''))
155 .map(p => ({ onPath: p.includes('/'), re: new RegExp(p.includes('/') ? `(?:^|/)${globPart(p)}$` : `^${globPart(p)}$`, 'i') }))
156 if (!tests.length) return () => false
157 return path => {
158 const full = path.replace(/\\/g, '/')
159 const name = full.split('/').pop() ?? full
160 return tests.some(t => t.re.test(t.onPath ? full : name))
161 }
162}
163
164let ignored: (path: string) => boolean = () => false
165
166// Writes the template when there is none, then reads it. Never rejects: a failed read leaves the
167// last matcher in place.
168const loadIgnore = async ($: EngineInterface) => {
169 try {
170 const dir = await configDir($)
171 if (!dir) return
172 const path = `${dir}/cockpit/ignore`
173 if (!(await $.fs.exists(path).catch(() => false))) await $.fs.write(path, IGNORE_TEMPLATE)
174 ignored = ignoreMatcher(await $.fs.read(path))
175 } catch {
176 // keep the matcher there was
177 }
178}
179
180// Absolute OR relative: Playwright answers `./shot.png`, and an absolute-only pattern silently
181// found nothing. The separator classes take a RUN, because JSON.stringify escapes a Windows path
182// and a single-separator branch eats the drive letter (`C:/Users/…` → `/Users/…`). Names take any
183// letter (`Rechnung-März.pdf`), not just ASCII. ponytail: a space ends a path in free text, so
184// `my report.pdf` in a command's output reads as `report.pdf`; the mtime check in `collect`
185// drops it unless the call produced that file. A Write never goes through this pattern.
186const FILE_PATH = new RegExp(
187 String.raw`(?:[A-Za-z]:[\\/]+|\.{0,2}[\\/]+)?[\p{L}\p{N}_.\-][\p{L}\p{N}_.\-\\/]*\.(?:${OPENABLE})`,
188 'giu',
189)
190const IS_OPENABLE = new RegExp(String.raw`\.(?:${OPENABLE})$`, 'i')
191// The engine spills an MCP result's image block to <session>/tool-results/mcp-<server>-blob-<n>-<id>.png
192// and names that copy in the result. It is a duplicate of the file the tool itself saved, kept in
193// the transcript's store: never something the person made. (Its 43-char name, cut to 40 by
194// `label`, is what showed up as `mcp-playwright-blob-…-g5ctsr` with no extension.)
195const ENGINE_BLOB = /(?:^|\/)mcp-[\w-]*-blob-\d+-\w+\.\w+$/
196
197const isAbsolute = (p: string) => /^(?:[A-Za-z]:\/|\/)/.test(p)
198
199export const pathsIn = (value: unknown, cwd?: string): string[] => {
200 const text = typeof value === 'string' ? value : JSON.stringify(value ?? '')
201 const found = (text.match(FILE_PATH) ?? []).map(p => p.replace(/[\\/]+/g, '/').replace(/^\.\//, ''))
202 const base = cwd?.replace(/\\/g, '/').replace(/\/+$/, '')
203 // De-duplicated AFTER normalising: one file named in several escapings (Playwright's link,
204 // comment and code) is one path, not three.
205 return [...new Set(found.map(p => (isAbsolute(p) || !base ? p : `${base}/${p}`)))].filter(
206 p => !ENGINE_BLOB.test(p),
207 )
208}
209
210// A relative path is tried under each root in turn, first that exists wins: the project root
211// first (Playwright MCP saves relative to it), then the cwd (a shell `cd` moves only that one).
212// Git Bash on Windows prints `/c/Users/…` for `C:\Users\…`; the engine reads that as a folder `c` on
213// the current drive, so the drive spelling is tried after the path as written (measured 2026-10-09:
214// `wc -c` named `/c/Users/bloed/.restic/password.txt` and the row never appeared).
215const msysDrive = (path: string) => /^\/([A-Za-z])\//.exec(path) ? `${path[1]!.toUpperCase()}:${path.slice(2)}` : null
216const resolve = async ($: EngineInterface, path: string, roots: string[]) => {
217 const drive = msysDrive(path)
218 const tries = isAbsolute(path) || !roots.length
219 ? [path, ...(drive ? [drive] : [])]
220 : roots.map(root => `${root.replace(/\\/g, '/').replace(/\/+$/, '')}/${path}`)
221 for (const full of tries) if (await $.fs.exists(full).catch(() => false)) return full
222 return null
223}
224
225const label = (path: string) => path.split('/').pop()?.slice(0, 40) ?? 'file'
226// One file, one spelling: Windows answers `e:\` from one call and `E:\` from another, and the
227// list took them for two files.
228const sameDrive = (path: string) => path.replace(/^([a-z]):/, (_, d: string) => `${d.toUpperCase()}:`)
229// What makes two spellings one file: a drive-letter path is Windows, where case and separator do not
230// count (`E:\work\Prep.md` is `e:/work/prep.md`). Elsewhere case counts. Links compare as written.
231const keyOf = (target: string) => (/^[A-Za-z]:/.test(target) ? target.replace(/\\/g, '/').toLowerCase() : target)
232// The folder a file sits in, for telling two files of one name apart.
233const folderOf = (path: string) => path.split('/').slice(-2, -1)[0] ?? ''
234const hostOf = (url: string) => url.replace(/^https?:\/\//, '').split(/[/?#]/)[0] ?? url
235const parentOf = (path: string) => path.split('/').slice(0, -1).join('/')
236// The muted tail of a row: where the thing is, in the words that tell two of a name apart.
237export const tailOf = (kind: EntryKind, target: string) =>
238 kind === 'file' ? folderOf(target) : kind === 'link' ? hostOf(target) : parentOf(target)
239const labelOf = (kind: EntryKind, target: string) =>
240 kind === 'link' ? target.replace(/^https?:\/\//, '').slice(0, 40) : label(target)
241// PNG only: the terminal's Image takes PNG data, and anything else refuses the WHOLE pane.
242const isPng = (path: string) => /\.png$/i.test(path)
243
244type Found = { kind: EntryKind; target: string }
245const link = (target: string): Found => ({ kind: 'link', target })
246// A `gh … create` prints the URL of the thing it made; any other Bash output's URLs are noise.
247const GH_CREATE = /\bgh\s+(?:pr|issue|release)\s+create\b/
248const DEPLOY_TOOL = /^mcp__.*deploy/i
249
250// What a tool answered, as text: `text` when the engine flattened it; a Bash result's stdout and
251// stderr; an MCP result's text blocks; else the result as JSON. Not JSON for the first three: a
252// stringified `\n` is a backslash and an `n`, which a URL pattern reads as part of the URL.
253const textOf = (ran: { text?: unknown; result?: unknown }): string => {
254 if (typeof ran.text === 'string') return ran.text
255 const r = ran.result as { stdout?: unknown; stderr?: unknown; content?: unknown } | undefined
256 if (r && (typeof r.stdout === 'string' || typeof r.stderr === 'string')) {
257 return `${typeof r.stdout === 'string' ? r.stdout : ''}\n${typeof r.stderr === 'string' ? r.stderr : ''}`
258 }
259 if (r && Array.isArray(r.content)) {
260 return r.content.map(b => (b && typeof b.text === 'string' ? b.text : '')).join('\n')
261 }
262 return JSON.stringify(ran.result ?? ran ?? '')
263}
264
265// The host starts with a letter, digit or `[`: a bare `https://` in prose is a word, not a link.
266// A backtick ends it, so `` `https://x` `` in a reply is `https://x`.
267const URL_RE = /https?:\/\/[\w[][^\s<>()"'\]`]*/g
268// A dev server: localhost, loopback, the unspecified address or a private IPv4, each with a port.
269const SERVER_RE =
270 /(?<![\w.:/])(?:https?:\/\/)?(localhost|127\.0\.0\.1|0\.0\.0\.0|10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2}):(\d{2,5})(\/[^\s<>()"']*)?/g
271const trimUrl = (u: string) => u.replace(/[.,;:!?)\]]+$/, '')
272// A line a person is meant to follow: a bare URL, `- url`, `[text](url)`, or one with an open word.
273const ALONE_RE = /^(?:[-*]\s+)?(?:\[[^\]]*\]\()?https?:\/\/\S+\)?$/
274
275// `tool`: every URL (an artifact publish, `gh … create`, a deploy tool). `servers`: dev-server
276// addresses only, so a build log's registry and docs links stay out; `0.0.0.0` is not a place a
277// browser can go, so it is written as `localhost`. `reply`: a line's URLs when the line is the
278// link alone or carries one of `openWords`. De-duplicated, in order of first appearance.
279export const linksIn = (text: string, mode: 'tool' | 'servers' | 'reply', openWords: string[] = []): string[] => {
280 const out: string[] = []
281 const words = openWords.map(w => w.toLowerCase())
282 for (const raw of text.split('\n')) {
283 const line = raw.trim()
284 if (mode === 'reply' && !ALONE_RE.test(line) && !words.some(w => line.toLowerCase().includes(w))) continue
285 if (mode !== 'servers') for (const u of line.match(URL_RE) ?? []) out.push(trimUrl(u))
286 for (const m of line.matchAll(SERVER_RE)) {
287 const host = m[1] === '0.0.0.0' ? 'localhost' : m[1]
288 out.push(trimUrl(`http://${host}:${m[2]}${m[3] ?? ''}`))
289 }
290 }
291 return [...new Set(out)]
292}
293
294const norm = (p: string) => p.replace(/\\/g, '/').replace(/\/+$/, '')
295// `command`: the paths `mkdir` and `git worktree add` name (quotes honoured, `-b <branch>` skipped).
296// `reply`: an absolute path alone on its line, backticks or not — a relative one is not taken, the
297// reply has no cwd of its own (Julian, 2026-10-04). Forward slashes, no trailing slash, de-duplicated.
298// ponytail: a `mkdir` behind `cd x &&` is taken relative to the session cwd, not `x`; `resolve`
299// drops it when it does not exist there.
300export const foldersIn = (text: string, source: 'command' | 'reply'): string[] => {
301 const out: string[] = []
302 if (source === 'reply') {
303 for (const raw of text.split('\n')) {
304 const m = /^\**`?((?:[A-Za-z]:[\\/]|\/)[^\s`*]*)`?\**$/.exec(raw.trim())
305 if (m?.[1]) out.push(norm(m[1]))
306 }
307 return [...new Set(out)]
308 }
309 for (const part of text.split(/&&|\|\||;|\|/)) {
310 const words = (part.trim().match(/"[^"]*"|'[^']*'|\S+/g) ?? []).map(w => w.replace(/^["']|["']$/g, ''))
311 if (words[0] === 'mkdir') out.push(...words.slice(1).filter(w => !w.startsWith('-')))
312 if (words[0] === 'git' && words[1] === 'worktree' && words[2] === 'add') {
313 const args: string[] = []
314 for (let i = 3; i < words.length; i++) {
315 const w = words[i] ?? ''
316 if (w === '-b' || w === '-B') i++ // the branch name, not a path
317 else if (!w.startsWith('-')) args.push(w)
318 }
319 if (args[0]) out.push(args[0])
320 }
321 }
322 return [...new Set(out.map(norm))]
323}
324
325// An absolute path alone on a reply line: an openable file is a file row, anything else a folder row
326// (collect drops it unless it is a directory). Julian, 2026-10-04: a file Claude lists is one to open.
327// 2026-10-05: so is an openable file in backticks anywhere on a line — that is how a path gets named
328// mid-sentence. Folders and bare prose paths still need a line of their own.
329const TICKED_FILE = new RegExp(String.raw`\x60((?:[A-Za-z]:[\\/]|/)[^\x60\n]*\.(?:${OPENABLE}))\x60`, 'giu')
330export const replyPaths = (text: string, openWords: string[] = []): Found[] =>
331 [...new Set([
332 ...foldersIn(text, 'reply'),
333 ...[...text.matchAll(TICKED_FILE)].map(m => norm(m[1] ?? '')),
334 ...fileLinksIn(text, openWords),
335 ])].map(target => ({
336 kind: IS_OPENABLE.test(target) ? 'file' as const : 'folder' as const,
337 target,
338 }))
339
340// A `file://` link in the reply, taken on the same lines as a web link (alone, `- url`, `[text](url)`,
341// or an open word) and turned into its path: `file:///E:/x` → `E:/x`, `%20` decoded.
342// ponytail: `file://host/share` (UNC) is not handled; no one has written one yet.
343const FILE_URL_RE = /file:\/\/([^\s<>()"'\]`]+)/g
344const FILE_ALONE_RE = /^(?:[-*]\s+)?(?:\[[^\]]*\]\()?`?file:\/\/\S+\)?$/
345const fileLinksIn = (text: string, openWords: string[]): string[] => {
346 const words = openWords.map(w => w.toLowerCase())
347 const out: string[] = []
348 for (const raw of text.split('\n')) {
349 const line = raw.trim()
350 if (!FILE_ALONE_RE.test(line) && !words.some(w => line.toLowerCase().includes(w))) continue
351 for (const m of line.matchAll(FILE_URL_RE)) {
352 let p = trimUrl(m[1] ?? '').replace(/`$/, '')
353 try {
354 p = decodeURIComponent(p)
355 } catch {
356 // a stray % — keep it as written
357 }
358 out.push(norm(p.replace(/^\/([A-Za-z]:)/, '$1')))
359 }
360 }
361 return out
362}
363
364// fzf-flavoured: every query char in order; +3 for continuing a run, +2 at a word start, +1 elsewhere.
365// ponytail: greedy leftmost positions, not the best alignment; good enough for 48 short rows.
366const WORD_START = /[\s/\-_.:]/
367export const fuzzyScore = (query: string, text: string): number | null => {
368 const q = query.toLowerCase()
369 const t = text.toLowerCase()
370 let score = 0
371 let from = 0
372 let prev = -2
373 for (const ch of q) {
374 const at = t.indexOf(ch, from)
375 if (at < 0) return null
376 score += at === prev + 1 ? 3 : at === 0 || WORD_START.test(t[at - 1] ?? '') ? 2 : 1
377 prev = at
378 from = at + 1
379 }
380 return score
381}
382// Best first, ties newest first; an empty query is the list newest first. Label and tail both count.
383export const fuzzy = <E extends { label: string; tail: string; at: number }>(query: string, entries: E[]): E[] =>
384 entries
385 .map(e => ({ e, s: fuzzyScore(query, `${e.label} ${e.tail}`) }))
386 .filter((x): x is { e: E; s: number } => x.s !== null)
387 .sort((a, b) => b.s - a.s || b.e.at - a.e.at)
388 .map(x => x.e)
389
390// The kind, one glyph a row: a file, a link out, a folder in.
391const MARK: Record<EntryKind, string> = { file: '▪', link: '↗', folder: '▸' }
392
393// A Button hotkey is ONE digit or ONE lowercase letter (the engine refuses anything else), and
394// it is the only key a pane can bind: the arrows and Tab belong to the engine, which walks the
395// focus ring with them. So rows take 1–8 and the navigation takes h/j/k/l, as Buttons of its own.
396const NAV = { j: 'nav:j', k: 'nav:k', h: 'nav:h', l: 'nav:l', o: 'nav:o', f: 'nav:f' } as const
397const isNav = (key: string | undefined) => !!key?.startsWith('nav:')
398
399// Turns to `to` (clamped by the caller), redraws, and puts the ring on row `row` of it.
400const go = async ($: EngineInterface, to: number, row: number) => {
401 page = to
402 focused = row
403 $.ui.invalidate('ui.render')
404 await $.ui.focus({ requestId: PANE, key: `row:${row}` }).catch(() => null)
405}
406
407// Top level, not nested in `register`: the validator only traces `$` into a function declared at
408// the top of the file, and refuses a module that hands it to a closure it cannot follow.
409// `since`: keep only files modified after it, so a path a command merely printed (`git status`
410// listing README.md) is not taken for one it produced. 2 s of slack for coarse file-system clocks.
411// Publishes even when nothing is collected: every tool call is where a deletion can have happened.
412// Files and folders must exist (a folder must be a directory); links are taken as given.
413const collect = async ($: EngineInterface, found: Found[], since?: number, roots: string[] = []) => {
414 const keep: Found[] = []
415 for (const f of found) {
416 if (f.kind === 'link') {
417 keep.push(f)
418 continue
419 }
420 const resolved = await resolve($, f.target, roots)
421 if (!resolved) continue
422 const target = sameDrive(resolved)
423 if (f.kind === 'file' && ignored(target)) continue
424 const stat = await $.fs.stat(target).catch(() => null)
425 if (f.kind === 'folder' && stat?.kind !== 'dir') continue
426 if (f.kind === 'file' && since !== undefined && (!stat || stat.mtimeMs < since - 2000)) continue
427 // One row a file: a rebuild hands every mention over in one batch. The last mention wins the slot.
428 const dup = keep.findIndex(k => keyOf(k.target) === keyOf(target))
429 if (dup >= 0) keep.splice(dup, 1)
430 keep.push({ kind: f.kind, target })
431 }
432 if (keep.length) {
433 const at = await $.clock.now()
434 await update($, files, list => {
435 // A target produced again moves to the newest slot: a regenerated file is this session's
436 // latest output, and left in its old place a full list drops it on the next new file.
437 const targets = new Set(keep.map(k => keyOf(k.target)))
438 const kept = list.map(asEntry).filter(e => !targets.has(keyOf(e.target)))
439 const fresh = keep.map(k => ({ ...k, label: labelOf(k.kind, k.target), tail: tailOf(k.kind, k.target), at }))
440 return [...kept, ...fresh].slice(-KEEP)
441 })
442 }
443 await publish($)
444}
445
446// The tools whose answer names a file they produced. Bash is collected live (its call time
447// separates produced from merely printed) but never replayed, where that time is gone.
448const SCREENSHOT_TOOLS = [
449 'mcp__playwright__browser_take_screenshot',
450 'mcp__claude-in-chrome__computer',
451 'mcp__plugin_figma_figma__get_screenshot',
452]
453
454// The list is host state for the session id; a trip through the agent screen hands the same
455// conversation a new id and an empty state. The transcript survives it, so an empty list is
456// rebuilt from it, oldest first so the newest call ends up on top: Writes, screenshots, artifact
457// publishes, and the links and folders the replies named. Never rejects.
458const rebuild = async ($: EngineInterface, openWords: string[]) => {
459 try {
460 const messages = await $.session.messages()
461 const roots = [await $.session.root().catch(() => ''), await $.session.cwd().catch(() => '')].filter(Boolean)
462 const found: Found[] = []
463 const file = (target: string): Found => ({ kind: 'file', target })
464 for (const m of messages) {
465 if (m.role === 'assistant' && m.text) {
466 found.push(...linksIn(m.text, 'reply', openWords).map(link))
467 found.push(...replyPaths(m.text, openWords))
468 }
469 for (const use of m.toolUses ?? []) {
470 if (use.isError) continue
471 if ((use.tool === 'Write' || use.tool === 'Edit') && typeof use.input?.file_path === 'string') {
472 const path = use.input.file_path.replace(/\\/g, '/')
473 if (IS_OPENABLE.test(path)) found.push(file(path))
474 } else if (use.tool === 'Artifact') {
475 found.push(...linksIn(use.text ?? JSON.stringify(use.result ?? ''), 'tool').map(link))
476 } else if (SCREENSHOT_TOOLS.includes(use.tool)) {
477 found.push(...pathsIn(use.result ?? use.text ?? '').map(file))
478 }
479 }
480 }
481 if (found.length) await collect($, found, undefined, roots)
482 } catch {
483 // no transcript to read (a fresh session): the list stays empty
484 }
485}
486
487// Open as a dialog: it takes the keyboard at once (so a hotkey works without `ctrl+x tab`), Esc
488// closes it, and toasts wait behind it rather than landing on the list being picked from.
489// `rows` is what makes the arrows walk the list: a dialog tall enough to show whole has nothing
490// to scroll, and while it has, the engine spends the arrows on scrolling (measured 2026-10-03:
491// opened a third tall, a 20-row image box made the list scroll and the arrows dead).
492// One page at most, never the whole list: see PER_PAGE.
493const openPane = async ($: EngineInterface, openWords: string[]) => {
494 // An empty list may be a new session id over an old conversation: rebuild it before opening.
495 // Here, not in the draw: the host refuses a state write while a render is dispatched.
496 if (!(await stored($)).length) await rebuild($, openWords)
497 const list = await stored($)
498 const newest = list[list.length - 1]
499 page = 0
500 focused = 0
501 filtering = false
502 query = ''
503 const rows = Math.min(PER_PAGE, Math.max(1, list.length)) + HINT_ROWS + (newest && isPng(newest.target) ? IMAGE_ROWS + 1 : 0)
504 await $.ui.open({ id: PANE, title: 'Files', focus: true, closeOnEscape: true, holdToasts: true, rows })
505}
506
507// The host's own opener, no shell. Windows: `cmd /c start "" <path>` — the empty string is
508// `start`'s title argument, without it a quoted path becomes the title; a URL goes through the
509// URL handler instead, because `cmd /c start` re-parses its line and an `&` in a query string
510// would split it. macOS: `open`. Linux: `xdg-open` (both take a URL as they take a path). A
511// failure says so: a silent dead press is the worst outcome for a button.
512const openerFor = async ($: EngineInterface, target: string): Promise<string[]> => {
513 const os = ((await $.env.get('OS').catch(() => null)) ?? '').toLowerCase()
514 const windows = os.includes('windows') || !!(await $.env.get('USERPROFILE').catch(() => null))
515 if (windows) {
516 return /^https?:\/\//.test(target)
517 ? ['rundll32', 'url.dll,FileProtocolHandler', target]
518 : ['cmd', '/c', 'start', '', target.replace(/\//g, '\\')]
519 }
520 const uname = await $.process.run(['uname'], { timeoutMs: 2000 }).catch(() => null)
521 return [(uname?.stdout ?? '').trim() === 'Darwin' ? 'open' : 'xdg-open', target]
522}
523
524// The `openWords` option: comma-separated, trimmed, case folded in `linksIn`.
525const wordsOf = (v: unknown) => String(v ?? '').split(',').map(w => w.trim()).filter(Boolean)
526
527export const register: Register = (on, options) => {
528 const openWords = wordsOf(options.openWords)
529 // ponytail: Button labels take the terminal's foreground (no colour prop), so a light terminal on a
530 // dark base reads poorly; every palette here is dark-ground, which is who picks one.
531 const BASE = paletteOf(options.palette).base
532
533 // The reply as it streams: every flush is whole lines but the last, which ends the message, so
534 // each line is complete when read and a URL is never taken half. Passed on: a settings hook
535 // beneath still runs.
536 on('classic.MessageDisplay', async ($, e, next) => {
537 const found: Found[] = [
538 ...linksIn(e.delta, 'reply', openWords).map(link),
539 ...replyPaths(e.delta, openWords),
540 ]
541 if (found.length) await collect($, found)
542 return next(e)
543 })
544
545 on('session.start', async ($, e, next) => {
546 const started = await next(e)
547 await $.command.register({ name: 'files', description: 'Open a file, link or folder this session produced' })
548 await loadIgnore($) // before the rebuild, so an ignored file never reaches the list
549 await rebuild($, openWords) // a resumed or re-identified conversation: the count is right before /files
550 await publish($)
551 // A file deleted outside Claude (Explorer, another shell) fires no hook: recount on a clock.
552 // The ignore file is re-read on the same clock, so an edit to it lands within 30 s.
553 $.clock.every(30_000, () => void loadIgnore($).then(() => publish($)))
554 return started
555 })
556
557 on('command.run', { command: 'files' }, async $ => {
558 await openPane($, openWords)
559 return {} // silent: the pane itself is the answer
560 })
561
562 // A Write always names the file it wrote, absolute: taken as is, spaces and all.
563 on('tool.call', { tool: 'Write' }, async ($, e, next) => {
564 const ran = await next(e)
565 const path = e.file_path?.replace(/\\/g, '/')
566 const ok = ran.deny === undefined && ran.isError !== true && path && IS_OPENABLE.test(path)
567 await collect($, ok ? [{ kind: 'file', target: path }] : [])
568 return ran
569 })
570
571 // An Edit names the file it changed the same way (Julian, 2026-10-05: a doc edited is one to open).
572 on('tool.call', { tool: 'Edit' }, async ($, e, next) => {
573 const ran = await next(e)
574 const path = e.file_path?.replace(/\\/g, '/')
575 const ok = ran.deny === undefined && ran.isError !== true && path && IS_OPENABLE.test(path)
576 await collect($, ok ? [{ kind: 'file', target: path }] : [])
577 return ran
578 })
579
580 // Everything else, one hook with no matcher (a matcher over a list of names sent tsc into
581 // TS2589): read the answer, keep what is openable AND on disk. Bash is here because the
582 // scripts that produce the real artefacts — invoices, reports — are run, not written; it also
583 // yields dev-server addresses from its output (every URL when it is a `gh … create`, whose
584 // output is the thing made) and the folders its command made. A screenshot tool names the
585 // file it saved. A published artifact and a deploy tool of any MCP server name a URL.
586 on('tool.call', async ($, e, next) => {
587 const since = await $.clock.now()
588 const ran = await next(e)
589 if (ran.deny !== undefined || ran.isError === true) return ran
590 const producesFiles = e.tool === 'Bash' || SCREENSHOT_TOOLS.includes(e.tool)
591 const producesLinks = e.tool === 'Artifact' || DEPLOY_TOOL.test(e.tool)
592 if (!producesFiles && !producesLinks) return ran
593 const found: Found[] = []
594 const roots: string[] = []
595 if (producesFiles) {
596 roots.push(await $.session.root().catch(() => ''), await $.session.cwd().catch(() => ''))
597 found.push(...pathsIn(ran).map(target => ({ kind: 'file' as const, target })))
598 }
599 if (e.tool === 'Bash') {
600 const cmd = typeof e.command === 'string' ? e.command : ''
601 found.push(...linksIn(textOf(ran), GH_CREATE.test(cmd) ? 'tool' : 'servers').map(link))
602 found.push(...foldersIn(cmd, 'command').map(target => ({ kind: 'folder' as const, target })))
603 }
604 if (producesLinks) found.push(...linksIn(textOf(ran), 'tool').map(link))
605 await collect($, found, since, roots.filter(Boolean))
606 return ran
607 })
608
609 // No band of its own: the hook only measures the width for the status line, then lets the
610 // engine draw whatever belongs there.
611 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
612 const width = e.viewport?.columns ?? 0
613 if (width && width !== columns) {
614 columns = width
615 void publish($)
616 }
617 return next(e)
618 })
619
620 // The arrows and Tab walk every Button, the h/j/k/l ones too; the ring stays on the rows, so
621 // an arrow past the page's edge stops there (j/k turn the page instead). Tracks the row too.
622 on('ui.focus', { requestId: PANE }, async ($, e, next) => {
623 if (isNav(e.element)) return {}
624 const row = /^row:(\d+)$/.exec(e.element ?? '')
625 if (row) focused = Number(row[1])
626 return next(e)
627 })
628
629 // Esc while the filter is up returns to the list; the pane stays. The engine's Esc reaches us
630 // as a close (closeOnEscape): answered without `next`, it is refused and the list is drawn.
631 on('ui.close', { id: PANE }, async ($, e, next) => {
632 if (filtering && e.origin.kind === 'person') {
633 filtering = false
634 query = ''
635 page = 0
636 focused = 0
637 $.ui.invalidate('ui.render')
638 // Esc has already handed the keyboard back to the prompt before the close reaches us
639 // (Julian 2026-10-04: the list stayed, the focus went to the prompt). Ask for it again and
640 // put the ring on row 1; not awaited, the close is still being answered.
641 void $.ui
642 .open({ id: PANE, title: 'Files', focus: true, closeOnEscape: true, holdToasts: true })
643 .then(() => $.ui.focus({ requestId: PANE, key: 'row:0' }))
644 .catch(() => null)
645 return { value: undefined } // answered here: the pane stays
646 }
647 return next(e)
648 })
649
650 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
651 const { Box, Text, Button } = $.ui.resolve(e)
652 // The pane paints its own ground (Julian 2026-10-04): under a `*-ansi` Claude Code theme the
653 // dialog takes an ANSI grey from the terminal's scheme, and neither the rows nor the engine's
654 // blue hotkeys read on it. The palette's base, filling the body; text keeps the terminal's
655 // foreground. Docked the body is the screen; inline it is what the layout spares.
656 const ground = { flexDirection: 'column' as const, backgroundColor: BASE, minHeight: e.props?.scroll?.bodyRows }
657 const all = await stored($)
658
659 // Only what is still on disk: a file can be deleted or moved after it was collected, and a
660 // button that opens nothing reads as the mod being broken rather than as a missing file.
661 // A link is never checked: there is no disk to ask.
662 const checked = await Promise.all(
663 all.map(async entry =>
664 entry.kind === 'link' || (await $.fs.exists(entry.target).catch(() => false)) ? entry : null,
665 ),
666 )
667 const list = checked.filter((entry): entry is Entry => entry !== null)
668
669 // The newest entry doubles as the empty check: `noUncheckedIndexedAccess` types it undefined.
670 const newest = list[list.length - 1]
671 if (!newest) {
672 return (
673 <Box {...ground}>
674 <Text>Nothing to open yet this session.</Text>
675 </Box>
676 )
677 }
678 // A page is as long as the body the surface granted, less the hint rows. Docked (fullscreen
679 // from 110 columns) that is floor to ceiling; inline above the prompt it is what the layout
680 // spares, which a wrapped prompt shortens. A page taller than the body made the engine scroll
681 // it: the hint fell off and the arrows scrolled instead of walking.
682 const body = e.props?.scroll?.bodyRows ?? Infinity
683 // The Input takes a row off the page while it is up.
684 // The pages are cut from `pool`: the list newest first, or the matches best first.
685 const pool = filtering && query ? fuzzy(query, list) : list.slice().reverse()
686 // Two hint rows only when they cost no entry; tight (inline under a long transcript) the hint is
687 // one row of keys, o and f first, the walk after them, no prose (Julian 2026-10-04: the walk is
688 // learned once, o and f are rarer). Hidden Buttons would lose their hotkeys, so the keys stay.
689 const room = body - (filtering ? 1 : 0)
690 const hintRows = room - HINT_ROWS >= Math.min(PER_PAGE, Math.max(1, pool.length)) ? HINT_ROWS : 1
691 const perPage = Math.max(1, Math.min(PER_PAGE, room - hintRows))
692 const pages = Math.max(1, Math.ceil(pool.length / perPage))
693 page = Math.min(page, pages - 1) // a file deleted since can shorten the list under us
694 const shown = pool.slice(page * perPage, (page + 1) * perPage)
695 const last = shown.length - 1
696 focused = Math.min(focused, Math.max(0, last)) // a shorter page than the one the ring was on
697 const lastRow = (p: number) => Math.min(perPage, pool.length - p * perPage) - 1
698
699 const startFilter = () => {
700 filtering = true
701 query = ''
702 page = 0
703 focused = 0
704 $.ui.invalidate('ui.render')
705 void $.ui.focus({ requestId: PANE, key: 'q' }).catch(() => null)
706 }
707
708 // j past the last row turns to the next page's first; k before the first, to the previous
709 // page's last. The list is a ring (Julian, 2026-10-04): past either end it comes round, j
710 // from the last entry to page 1's first row, k from the first to the last page's last.
711 const down = () => (focused < last ? go($, page, focused + 1) : go($, (page + 1) % pages, 0))
712 const up = () => {
713 const p = focused > 0 ? page : (page - 1 + pages) % pages
714 return go($, p, focused > 0 ? focused - 1 : lastRow(p))
715 }
716 const turn = (to: number) => () => go($, (to + pages) % pages, 0)
717
718 // A thing that opened takes the person to another app; the pane closes behind it, so they do
719 // not come back to a dialog they have to dismiss. A failed open keeps it to pick again.
720 const open = (entry: Entry) => () =>
721 openerFor($, entry.target)
722 .then(cmd => $.process.run(cmd))
723 .then(r =>
724 r.exitCode === 0
725 ? $.ui.close({ id: PANE })
726 : $.ui.toast(`could not open ${entry.label} (exit ${r.exitCode})`),
727 )
728 .catch(() => $.ui.toast(`could not open ${entry.label}`))
729 // `o`: the folder of the focused row — a file's parent, a folder itself; a link has none.
730 const folderOfRow = () => {
731 const entry = shown[focused]
732 if (!entry) return
733 if (entry.kind === 'link') return $.ui.toast('Links have no folder')
734 const target = entry.kind === 'folder' ? entry.target : parentOf(entry.target)
735 return open({ ...entry, target, label: target })()
736 }
737
738 // The field, while filtering. Its text is drawn back on every change, so a redraw (a new
739 // entry arriving) does not empty it. Enter opens the best match; nothing when there is none.
740 // Resolved under the surfaces that have an `Input` (mobile does not), as `Image` is below.
741 let header = null
742 if (filtering && (e.surface === 'terminal' || e.surface === 'desktop' || e.surface === 'vscode')) {
743 const { Input } = $.ui.resolve(e)
744 header = (
745 <Input
746 key="q"
747 label="find"
748 value={query}
749 // Short: the hint row says the keys. A long placeholder pushed the Enter label onto a row
750 // of its own, and the engine's default label `submit` named nothing this field does.
751 placeholder="type to filter"
752 submitLabel="open"
753 autoFocus
754 onInput={(value: string) => {
755 query = value
756 page = 0
757 focused = 0
758 $.ui.invalidate('ui.render')
759 }}
760 onSubmit={() => (pool[0] ? open(pool[0])() : undefined)}
761 />
762 )
763 }
764
765 let inline = null
766 // The newest file only, on page 1 only, and not while filtering (the list needs the rows):
767 // it is what `openPane` asked rows for. Left out when the body cannot hold it under the rows
768 // and the hint: a row is worth more than a preview.
769 const roomForImage = body >= shown.length + hintRows + IMAGE_ROWS + 1
770 if (page === 0 && !filtering && e.surface === 'terminal' && isPng(newest.target) && roomForImage) {
771 // Resolved here, not above: `Image` exists only in the terminal's element table, and
772 // narrowing on e.surface is what hands it over. A module has no element globals.
773 const { Image } = $.ui.resolve(e)
774 const stat = await $.fs.stat(newest.target).catch(() => null)
775 if (stat && stat.size <= INLINE_MAX_BYTES) {
776 const file = await $.fs.read(newest.target, { as: 'bytes' }).catch(() => null)
777 if (file) {
778 // A fixed, small box: it is what `openPane` asks rows for, and a terminal cell is about
779 // twice as tall as wide, so 3 columns a row keeps a screenshot roughly in proportion.
780 const cols = Math.min(IMAGE_ROWS * 3, Math.max(10, (e.props?.bodyColumns ?? 60) - 2))
781 inline = (
782 <Image
783 source={{ png: file.base64 }} // FsBytes is `{ base64 }`, already encoded
784 columns={cols}
785 rows={IMAGE_ROWS}
786 // The engine draws pixels in kitty and Ghostty only; everywhere else, this.
787 alt="(image preview needs kitty or Ghostty)"
788 />
789 )
790 }
791 }
792 }
793
794 if (!pool.length) {
795 // A filter that matches nothing: the field stays, so the person can retype or Esc back.
796 return (
797 <Box {...ground}>
798 {header}
799 <Text>{`No match for ‹${query}›.`}</Text>
800 </Box>
801 )
802 }
803
804 return (
805 <Box {...ground}>
806 {header}
807 {shown.map((entry, i) => (
808 // `autoFocus?: true` is a literal-true type, so `false` is not "off", it is an
809 // invalid prop — and one invalid prop refuses the WHOLE tree, not just that element.
810 // Keyed by position: `row:N` is what `go` focuses after a page turn. The ring starts on
811 // the row the pane holds (`go` focuses the same one), so a redraw keeps it; while the
812 // field is up, the field keeps it. The muted tail says where the thing is, which tells
813 // two files of one name apart.
814 <Box key={`line:${i}`} flexDirection="row" columnGap={1}>
815 <Button
816 key={`row:${i}`}
817 plain
818 hotkey={String(i + 1)}
819 autoFocus={!filtering && i === focused ? true : undefined}
820 onPress={open(entry)}
821 >
822 {`${MARK[entry.kind]} ${entry.label}`}
823 </Button>
824 {/* The terminal's own foreground on the palette's base (`ground`); italic sets the tail apart. */}
825 <Text italic wrap="truncate-end">
826 {entry.tail}
827 </Text>
828 </Box>
829 ))}
830 {/* The hint, always drawn, two rows (HINT_ROWS) or one when tight: its keys are live Buttons (`j: ↓`), so it cannot
831 drift from what works. `openPane` counts these rows. */}
832 {/* A short last page keeps the page's height (Julian 2026-10-04): the hint stays where it was,
833 so a turn from 8 rows to 7 reads as a turn, not as an entry gone. Only with a second page. */}
834 {pages > 1
835 ? Array.from({ length: perPage - shown.length }, (_, i) => <Text key={`pad:${i}`}> </Text>)
836 : null}
837 {(() => {
838 const walk = [
839 <Button key={NAV.j} plain dimColor hotkey="j" onPress={down}>
840 ↓
841 </Button>,
842 <Button key={NAV.k} plain dimColor hotkey="k" onPress={up}>
843 ↑
844 </Button>,
845 ...(pages > 1
846 ? [
847 <Button key={NAV.h} plain dimColor hotkey="h" onPress={turn(page - 1)}>
848 ‹
849 </Button>,
850 // Which entries, not only which page: a wrap from page 1 to a shorter last page read
851 // as an entry lost (Julian 2026-10-04, 15 entries: 8 then 7).
852 <Box key="range" flexShrink={0}>
853 <Text bold>{`${page * perPage + 1}–${page * perPage + shown.length} of ${pool.length} · ${page + 1}/${pages}`}</Text>
854 </Box>,
855 <Button key={NAV.l} plain dimColor hotkey="l" onPress={turn(page + 1)}>
856 ›
857 </Button>,
858 ]
859 : []),
860 ]
861 // While filtering, o and f are bare keys (Julian 2026-10-05: the field explains itself); f is
862 // the way back from the matches to the field, text kept (only Shift+Tab came back before,
863 // and a missing f fell through to the prompt).
864 const acts = [
865 <Button key={NAV.o} plain dimColor hotkey="o" onPress={folderOfRow}>
866 {filtering ? '' : 'folder'}
867 </Button>,
868 <Button
869 key={NAV.f}
870 plain
871 dimColor
872 hotkey="f"
873 onPress={filtering ? () => void $.ui.focus({ requestId: PANE, key: 'q' }).catch(() => null) : startFilter}
874 >
875 {filtering ? '' : 'find'}
876 </Button>,
877 ]
878 // Filtering, the row leads with the way into the matches, then how to walk them.
879 const tab = filtering
880 ? [
881 <Box key="tab" flexShrink={0}>
882 <Text>Tab: matches</Text>
883 </Box>,
884 ]
885 : []
886 return hintRows === HINT_ROWS ? (
887 <>
888 <Box flexDirection="row" columnGap={1}>
889 {tab}
890 {walk}
891 </Box>
892 <Box flexDirection="row" columnGap={1}>
893 {acts}
894 <Text wrap="truncate-end">
895 {filtering ? '· Enter opens the top match · Esc back' : '· Enter or 1–8 opens · Esc closes'}
896 </Text>
897 </Box>
898 </>
899 ) : (
900 <Box flexDirection="row" columnGap={1}>
901 {/* Short, and cut at the edge rather than wrapped: this row has no second line to spill into. */}
902 {filtering ? [...tab, ...walk, ...acts] : [...acts, ...walk]}
903 <Text wrap="truncate-end">{filtering ? '· Esc back' : '· Enter opens · Esc closes'}</Text>
904 </Box>
905 )
906 })()}
907 {inline}
908 </Box>
909 )
910 })
911}
912palettes.js 61 lines1// One palette table for the mod (runs in the engine) and the status line (runs in Node).
2// Seven roles, named by what they mean on the row, not by hue. A value is `#rrggbb`, or one of
3// the ANSI color names below so the `ansi` palette works on any terminal without truecolor.
4//
5// Sources, read 2026-10-03:
6// rose-pine https://github.com/rose-pine/palette (palette.json)
7// catppuccin-mocha https://github.com/catppuccin/palette (palette.json, flavor mocha)
8// tokyo-night https://github.com/folke/tokyonight.nvim (extras/lua/tokyonight_night.lua)
9
10export const ROLES = ['muted', 'subtle', 'gold', 'love', 'foam', 'iris', 'track', 'base']
11
12export const PALETTES = {
13 'rose-pine': {
14 muted: '#6e6a86', // separators, secondary counts
15 subtle: '#908caa', // the readable default
16 gold: '#f6c177', // uncommitted work, warnings
17 love: '#eb6f92', // detached head, context nearly full, alerts
18 foam: '#9ccfd8', // room to spare, lines added
19 iris: '#c4a7e7', // accent
20 track: '#403d52', // unlit bar cells (highlight-med)
21 base: '#191724', // the Files pane's ground (base)
22 },
23 'catppuccin-mocha': {
24 muted: '#6c7086', // overlay0
25 subtle: '#a6adc8', // subtext0
26 gold: '#f9e2af', // yellow
27 love: '#f38ba8', // red
28 foam: '#94e2d5', // teal
29 iris: '#cba6f7', // mauve
30 track: '#45475a', // surface1
31 base: '#1e1e2e', // base
32 },
33 'tokyo-night': {
34 muted: '#565f89', // comment
35 subtle: '#a9b1d6', // fg_dark
36 gold: '#e0af68', // yellow
37 love: '#f7768e', // red
38 foam: '#1abc9c', // teal
39 iris: '#bb9af7', // magenta
40 track: '#3b4261', // fg_gutter
41 base: '#1a1b26', // bg
42 },
43 // The terminal's own 16 colors: whatever theme the user runs, these follow it.
44 ansi: {
45 muted: 'gray',
46 subtle: 'white',
47 gold: 'yellow',
48 love: 'red',
49 foam: 'cyan',
50 iris: 'magenta',
51 track: 'gray',
52 base: 'black',
53 },
54}
55
56export const DEFAULT_PALETTE = 'rose-pine'
57
58/** The palette for a settings value; anything unknown is the default, never a crash. */
59export const paletteOf = name =>
60 typeof name === 'string' && Object.hasOwn(PALETTES, name) ? PALETTES[name] : PALETTES[DEFAULT_PALETTE]
61types/index.d.ts 12 lines1export type EntryKind = 'file' | 'link' | 'folder'
2/** One row of the pane: what this session produced and a person may open. */
3export type Entry = { kind: EntryKind; target: string; label: string; tail: string; at: number }
4/** The shape stored before v0.2.0; read as a file entry. */
5export type Doc = { path: string; label: string; at: number }
6
7declare module 'claude-code' {
8 interface PluginState {
9 cockpit: { files: (Entry | Doc)[] }
10 }
11}
12