← Catalog

pi-fast-resume

Fast session picker for pi — reads headers + first messages from 16KB partial reads instead of full-file parsing

Extension

Install

Install with PiG

pig install npm:pi-fast-resume

Install with Pi

pi install npm:pi-fast-resume
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./fast-resume.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.4.19 (README.md). PiG does not review it.

⚡ pi-fast-resume

Instant session picker for pi

Reads just enough of each file to show the title row — first results in 6ms.

pi extension license


/resume takes 5.6 seconds when you have 1,700+ sessions. pi-fast-resume's /fast-resume takes 6 milliseconds.

Same picker UI and keybindings as /resume. The difference is pi-fast-resume never parses the full JSONL. For each file it streams complete lines forward just until the first user message (the title), then reads a bounded tail near EOF to recover the latest session name (which pi appends on /rename). Everything between is full message history the picker never shows. Search matches against the first message only (see Known Limitations).

──────────────────────────────────────────────────────────

Resume Session (Current Folder)       ◉ Current Folder | ○ All  Name: All  Sort: Threaded
Tab scope · re:<pattern> regex · "phrase" exact
Ctrl+S sort · Ctrl+N named · Ctrl+D delete · Ctrl+P path (off) · Ctrl+R rename

search: fix auth bug_

› Fix the auth bypass in middleware                    34 2m
  Add rate limiting to API                             98 5h
  Refactor user service                              156 1d
  Auth refactor                                       67 3d

──────────────────────────────────────────────────────────

Benchmarks

Tested with 1,771 sessions, 1.46 GB of JSONL data on disk.

ApproachFirst paintFull load
Built-in /resume5,600 ms5,600 ms
node:sqlite indexed query52 ms52 ms
DuckDB persistent index49 ms49 ms
pi-fast-resume (partial read)6 ms~580 ms
DuckDB NDJSON full scan2,560 ms2,560 ms

The all-dirs stat() pass (~100 ms at scale) now runs after first paint, so first paint no longer depends on total session count — only on the current project's session dir.

Full benchmark table
ApproachTimeNotes
SessionManager.listAll() (current)~5,600 msFull parse of every file
DuckDB read_ndjson full query~2,560 msStill reads all 1.46 GB, but multithreaded
Node.js streaming partial read (this extension)~370 msAll ~2,550 sessions; stops at first user message + bounded tail
DuckDB persistent index (query all)~49 msAfter one-time build
node:sqlite persistent index (query)~52 msZero external deps
pi-fast-resume, first 30 sessions~6 msStreaming display
pi-fast-resume, stale-check for incremental~74 msCompare mtimes against last load
DuckDB CLI → JSON → Node parse~121 msShell-out approach
node:sqlite FTS5 search~0 msIndexed full-text search

Install

With pi install (recommended):

pi install npm:pi-fast-resume

Or install from GitHub:

pi install https://github.com/monotykamary/pi-fast-resume

With npm:

npm install pi-fast-resume

Manual — add to ~/.pi/agent/settings.json:

{
  "packages": ["git:github.com/monotykamary/pi-fast-resume"]
}

Local development — add the extension path directly:

{
  "extensions": ["./path/to/pi-fast-resume/fast-resume.ts"]
}

Reload with /reload after any install method.

Usage

/fast-resume command

/fast-resume              Open picker (current project)
/fast-resume auth bug     Open picker pre-filtered to "auth bug"

Keyboard shortcut

There are two ways to bind a key to the fast resume picker:

Option 1: Rebind app.session.resume (hijack mode only)

In hijack mode (default), the fast picker replaces /resume — bind app.session.resume in ~/.pi/agent/keybindings.json:

{
  "app.session.resume": "alt+u"
}

Option 2: Standalone shortcut (works regardless of hijack mode)

Set the shortcut key in ~/.pi/agent/extensions/pi-fast-resume.json:

{
  "shortcut": "ctrl+shift+f"
}

This registers an independent shortcut that opens the fast picker without overriding the built-in /resume. Works in both hijack and non-hijack modes.

See keybindings.md for the key format and all available actions.

Picker controls

Identical to built-in /resume:

KeyAction
↑ / ↓Navigate sessions
EnterSwitch to selected session
EscCancel
TabToggle scope — current project ↔ all sessions
Ctrl+SToggle sort — Threaded / Recent / Fuzzy
Ctrl+NToggle name filter — All / Named
Ctrl+PToggle session file path display
Ctrl+DDelete selected session (with confirmation)
Ctrl+RRename selected session
typingFilter sessions by text / regex / exact match

Scope

The picker opens in current project scope, showing only sessions whose working directory matches your current cwd.

Press Tab to switch to all sessions — shows every session pi knows about, with the project path displayed for each entry.

How it works

stat() current dir's .jsonl ──► sort by mtime ──► stream top 30 forward
      (~cheap, one dir)          (recent first)        (~6ms)
                                                            │
                                                            ▼
                                                    ┌─────────────────┐
                                                    │  Show picker    │
                                                    │  immediately    │
                                                    └────────┬────────┘
                                                             │
                          Background (after first paint):
                          1. stream the rest of the current dir in batches of 50 (rows appear as they load)
                          2. stat() ALL session dirs (~100ms at scale) — deferred off the critical path
                          3. forward-load all-scope headers in batches of 50 (non-blocking via setImmediate)
                          4. resolve rename names in the background (skip header-only files; bound each tail read)
  1. stat() the current project's session dir — collect paths and mtimes (cheap, one directory)
  2. Sort by mtime descending — most recent sessions first
  3. Stream the top 30 forward line by line until the first user message (~6 ms for the first screen)
  4. Show picker — user can navigate, filter, and select immediately
  5. Background load — after first paint, stream the remaining current-scope sessions in batches of 50, then stat every session dir and forward-load the all-scope headers, non-blocking
  6. Tab to switch scope — filter to current project or show everything

No indexing. No database. No persistent state. Just reads the files on disk.

Why not index?

An indexed approach would be faster for subsequent queries, but at the cost of real complexity:

(blank)Partial readIndexed (SQLite / DuckDB)
First open6 ms2–4 s (index build)
Subsequent opens6 ms (always fresh)50 ms + stale check
State to manageNoneIndex file, staleness, corruption
DependenciesNonenode:sqlite or DuckDB binary
Freshness guaranteeAlwaysRequires staleness detection

6 ms is fast enough. The data is always fresh because it's read from disk every time. No staleness bugs, no index corruption, no extra files in ~/.pi/.

Hijack mode

pi's built-in /resume is handled inside the interactive mode's onSubmit callback — it returns early before extension commands or input events are ever checked. Extensions cannot intercept built-in commands directly.

However, pi-fast-resume can prototype-patch InteractiveMode.showSessionSelector to intercept both the /resume command and the app.session.resume keybinding. Hijack mode is on by default — /resume opens the fast picker unless you opt out.

  • /resume opens the fast picker instead of the built-in one
  • Ctrl+Shift+R (or your mapped key) also opens the fast picker
  • /fast-resume is not registered (no duplicate command)
  • pi -r / pi --resume are not affected (they run before the interactive mode starts)

Config options

All options go in ~/.pi/agent/extensions/pi-fast-resume.json:

KeyTypeDefaultDescription
hijackResumebooleantrueWhen true, /resume and app.session.resume open the fast picker. Set false to use the built-in picker instead and keep /fast-resume as a separate command.
shortcutstring(none)Register a standalone keybinding to open the fast picker. Works regardless of hijackResume. Example: "ctrl+shift+f" or "alt+u".

Example:

{
  "hijackResume": false,
  "shortcut": "alt+u"
}

Reload with /reload after changing config.

How it works

On load, the extension patches InteractiveMode.prototype.showSessionSelector to open the fast picker via ctx.ui.custom(). On session_shutdown (reload, quit, session switch), the prototype is restored. The patch guards against API changes — if showSessionSelector doesn't exist or the runtime can't produce an ExtensionCommandContext, it falls back to the original.

Similar extensions

ExtensionApproachGap
pi-sessionsSearch, indexing, auto-titlingSession picker still uses SessionManager.list()
pi-session-searchFTS5 SQLite for search queriesIndex for search, not for the picker
pi-session-managerFull desktop app (Tauri)External app, not integrated into pi

None optimize the /resume picker itself — they either still fully parse every file or are standalone applications.

Known Limitations

The partial-read tradeoff that gives pi-fast-resume its speed comes with functional gaps vs. the built-in /resume. The forward stream reads exactly as many bytes as the first user message needs (no fixed window), so oversized first messages — <skill> injections, long pastes, base64 images — are parsed correctly. A rename is recovered only if it lives within a bounded tail near EOF (32 KB by default); a rename buried under more continued activity than that falls back to firstMessage.

AreaBuilt-in /resumepi-fast-resumeImpact
Search depthMatches against all messages in every session (allMessagesText)Matches against first message only (firstMessage) + name + id + cwdA query like fix oauth won't find a session where "fix oauth" appears in the 5th message but not the 1st. Name/id/cwd matches still work.

All other features — tree view, regex/exact-phrase search, sort modes, scope toggle, delete, rename, path display — are identical to the built-in picker.

License

MIT

Pi 1.0 compatibility (1.4.15)

Tested against Pi 1.3.0 with exact SDK development pins and wildcard host peers. The live mapped InteractiveMode opens the fast picker and restores its selector hook on shutdown.

Run bun run test:host for the offline real-host regression. Set PI1_HOST_PACKAGE to an installed Pi package directory and PI1_HOST_ENTRY=bundle to test its bundled CLI runtime.

Pi 0.99 compatibility (1.4.14)

Selector and shortcut patches now activate only in live TUI sessions, reinstall after session replacement, and compose safely with other picker wrappers. The native 0.99 selector/shortcut method contracts and actual loading were verified.

Tested with Pi 0.99.0. Host-provided Pi packages are wildcard peers, not bundled dependencies; development uses exact 0.99.0 versions.