pi-double-esc
v1.0.16
Published
Prevent accidental Escape from aborting the LLM — requires double-press to interrupt while streaming
Maintainers
Readme
⏏️ pi-double-esc
Prevent accidental Escape aborts in pi
Require a second Escape press within 500ms to confirm any abort action.
What It Does
When the LLM is streaming a response:
- First Escape press: Shows an
esc again to aborthint on the editor border — does not abort - Second Escape within the debounce window: Actually aborts the streaming response
- If the debounce window expires, the hint clears and escape resets
When the LLM is not streaming, Escape works normally (immediate) — no debounce applied. Autocomplete dismissal always works on a single Escape.
Installation
Option 1: Install via pi package (Recommended)
Install directly from GitHub as a pi package:
pi install https://github.com/monotykamary/pi-double-esc@mainOr add to your settings.json:
{
"packages": [
"https://github.com/monotykamary/pi-double-esc@main"
]
}Option 2: Global Installation
Copy the extension to pi's global extensions directory:
cp double-esc.ts ~/.pi/agent/extensions/Option 3: Project-Local Installation
Copy to your project's .pi/extensions/ directory:
mkdir -p .pi/extensions
cp double-esc.ts .pi/extensions/Option 4: Quick Test
pi -e ./double-esc.tsConfiguration
Set the PI_DOUBLE_ESC_MS environment variable to change the debounce timeout (default: 1500ms):
PI_DOUBLE_ESC_MS=2000 piHow It Works
The extension decorates pi's current editor instead of replacing it:
- On each
session_start, it reads the current editor factory withctx.ui.getEditorComponent(). - It creates that editor, or a
CustomEditorwhen no extension installed one earlier. - It decorates the editor's input and render methods with double-Escape behavior.
- While streaming, the first Escape shows a visual hint and starts a debounce timer.
- A second Escape within the window passes Escape to the current editor, which aborts the response.
- Any other keypress or timeout expiry dismisses the hint.
This design preserves behavior from editor extensions loaded before pi-double-esc. The debounce logic lives in src/double-esc-logic.ts as pure functions for testability.
Development
npm install # install dev dependencies
npm test # run tests
npm run typecheck # type check
npm run lint:dead # check for unused exportsLicense
MIT
Pi 1.0 compatibility (1.0.16)
Tested against Pi 1.0.0 with exact SDK development pins and wildcard host peers. Editor composition, autocomplete Escape, timer cleanup and shutdown restoration remain intact.
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.0.15)
Preserves single-Escape autocomplete dismissal, restores editor methods/factories and clears debounce timers on shutdown. Non-TUI sessions are untouched; cached render output is not mutated.
Tested with Pi 0.99.0. Host-provided Pi packages are wildcard peers, not bundled dependencies; development uses exact 0.99.0 versions.
