@timmyjl12/pi-btw
v0.1.1
Published
Session-persistent isolated BTW chat with a split overlay and tabbed settings
Maintainers
Readme
@timmyjl12/pi-btw
An isolated, multi-turn BTW chat for Pi 1.0.1+. A split overlay puts this session's side-conversation history on the left, the current chat on the right, and Threads · Settings · Help in a keyboard-driven tab track.
The main agent keeps running. BTW has no tools and never automatically sends a message to the main agent.
Install / safe cutover
This replaces, rather than runs alongside, another /btw extension. In particular, disable @narumitw/pi-btw in your Pi package configuration before enabling this one. Installation does not migrate upstream memory-only threads, change global settings, or uninstall anything.
pi install npm:@timmyjl12/pi-btw
/reloadFor an isolated trial, use a fresh PI_CODING_AGENT_DIR, configure a test model, and load just this extension:
$env:PI_CODING_AGENT_DIR = "C:\temp\pi-btw-trial"
pi -e npm:@timmyjl12/pi-btwRun the trial in a separate terminal; do not overwrite your normal agent directory. Remove the temporary environment override when done. Non-TUI RPC/JSON/print invocation reports that interactive mode is required, without making a model call.
Usage
/btwopens or refocuses the workspace and resumes the selected thread./btw question…starts a new contextual thread and submits the first question.Ctrl+Shift+Bopens BTW from the main editor.Alt+/moves focus between the overlay and main editor. The overlay remains visible; the main editor and agent are usable underneath it./btwrefocuses the existing overlay, not a second instance.
Each contextual thread freezes a one-time bounded excerpt of the active main branch's user/assistant text. Later main activity does not update it. Create a new thread to capture newer context, or a contextless tangent to start fresh. This is Q&A, not a cloned coding agent: no tools, file access, tool results, images, system prompt, or private thinking are inherited.
Each send inherits the main model and thinking level at that moment. In-flight requests keep their original selection. Errors and cancelled partial answers remain visible; retries are manual. Empty final replies are retryable errors, not completed answers; they never enter completed follow-up context or last-answer handoff. A nonempty token-truncated reply remains completed with a visible warning. A busy send leaves the draft intact instead of creating hidden queued requests.
Keyboard
| Key | Action | | --- | --- | | Tab / Shift+Tab | Threads / Settings / Help | | Enter | Send; select thread; accept inline action; cycle preference | | Shift+Enter | Newline (native Pi editor bindings also apply) | | Alt+H | Toggle history/composer focus (also reaches history on narrow terminals) | | Up / Down in history | Select thread | | Ctrl+N / Ctrl+T | New contextual thread / contextless tangent | | Ctrl+F | Search thread titles | | Ctrl+E | Rename selected thread | | Ctrl+D | Archive with inline confirmation; no session-file deletion | | Ctrl+R | Retry most recent failed/cancelled question | | PgUp / PgDn | Scroll conversation | | Ctrl+Home / Ctrl+End | Beginning / end of conversation | | Ctrl+B / Ctrl+Shift+B | Stage last completed answer / retained transcript in main editor | | Alt+/ | Switch focus to main editor; use again to return | | Esc | Cancel active request; close when idle; cancel inline actions | | Ctrl+C | Close immediately and cancel work |
Handoff closes the overlay and stages a draft, preserving any existing main draft. Review before sending. It does not automatically inject, summarize, or start a main turn.
Settings are session-local: Markdown, timestamps, and initial focus. There is no independent model picker or global settings file. Narrow terminals switch to one pane, with history still keyboard-accessible; extremely small terminals show a clipped compact view and retain close/cancel controls.
History and privacy
Threads, frozen context excerpts, questions, answers and preferences persist as versioned custom entries in the parent Pi session JSONL. They survive reload/resume and remain browseable across branches of that session. They do not participate in Pi's main LLM context. Forking into a different session only carries entries Pi copies to that session.
Host persistence caveat: Pi defers writing a brand-new session until it contains a main user/assistant message. BTW-only activity before your first main prompt stays in memory; the overlay warns about this. --no-session sessions are also memory-only. Once Pi saves the parent conversation, it includes the earlier BTW custom entries. This extension does not force a save by injecting fake main messages or editing JSONL files.
Custom entries still advance the session leaf and are present in session files/backups/exports. Treat BTW content as sensitive session data, not a private ephemeral channel. Archiving adds a tombstone; it does not erase previous records. Rollback is disabling this extension and re-enabling your previous /btw owner; no session data needs deleting. Unknown future-version or malformed records are ignored. Interrupted pending turns recover as cancelled and can be retried. A failed save keeps the result in memory with an explicit warning; that unsaved result may be lost on close/restart.
Resource / lifecycle safeguards
- Registration-only entrypoint; UI/model modules load on first open. No eager history scan, filesystem settings, process, watcher or timer.
- One history array copy per open, cooperative reconstruction every 250 entries; never scan session files or rebuild history from render.
- Up to 50 recently created threads materialized; oldest entries remain on disk. Up to 40 exchanges and 64,000 text characters retained per thread. A limit notice discloses windowing.
- Frozen branch text: 12,000 characters, at most 500 entries / 60 text blocks inspected. Follow-ups include at most 20 completed exchanges within 24,000 text characters plus the frozen excerpt/current question.
- Question: 8,000 characters. Answer: 32,000 characters. Requested output ceiling: 4,096 tokens, or 32,768 when the model supports reasoning and inherited thinking is enabled, capped to a positive model maximum. Token-based Pi adapters may add their own thinking allowance (up to 16,384 by default in Pi 1.0.1), also under the model cap. Higher thinking may cost more; the extension inherits the thinking level, not custom main-session token budgets. Unknown/zero model limits use the bounded extension ceiling.
- One model request at a time; independent cancellation; a 120-second deadline; streaming repaints coalesced at 80 ms; settled-turn rendering is reused until layout/view/theme or turn content changes. No main-agent abort/idle wait, network auto-retry loop, terminal mouse capture, alternate-screen patching or clipboard subprocess.
- Close, tree navigation, reload, shutdown and session replacement abort work and suppress late writes/repaints. A process-wide worker budget, preserved across extension reloads, blocks additional calls if a custom provider ignores abort, rather than accumulating abandoned requests. The host/provider owns network teardown; this extension cannot forcibly terminate an uncooperative provider.
Bounds prevent extension-owned state/request/render growth; they are not a guarantee about all Pi/providers/terminals.
Development
npm install
npm run check
npm pack --dry-runPi loads TypeScript directly; there is no build/bundle step. Tests use Node's built-in runner. The runtime imports only Pi host peers and Node standard library. See CHANGELOG.md for release notes.
Inspiration
Informed by narumiruna/pi-btw, dbachelder/pi-btw, rpiv-btw, pi-better-btw-plus, and the overlay/tab grammar of @timmyjl12/pi-model-picker. This implementation deliberately stays tool-less and uses public Pi APIs rather than copying their coding-agent/terminal ownership internals.
