A Pi/Senpi extension, version 0.1.0, that leaves the current session ID and a reusable resume command in the terminal when the host exits.
Session ID: 12345678-abcd-4567-8901-123456789abc
Resume: omo --session /absolute/path/to/session.jsonl
The command targets the host's absolute saved session path. If there is no saved file, the extension prints the session ID and This session was not saved; there is no conversation to resume. It never invents a working resume command for an unsaved session.
The extension makes no model calls, stores no sessions, and never resumes a session automatically. The host remains responsible for saving and restoring conversations.
Requires Node.js 22.19.0 or newer and a compatible Pi/Senpi extension host. Install the tagged release from GitHub with your host:
pi install git:github.com/nashgao/pi-session-exit@v0.1.0
senpi install git:github.com/nashgao/pi-session-exit@v0.1.0
omo install git:github.com/nashgao/pi-session-exit@v0.1.0Use only the command for the host you run. To remove it, replace install with remove using the same source. For local development, install the checkout:
omo install /absolute/path/to/pi-session-exitStart a new host process after installation. To remove it, use the same package path:
omo remove /absolute/path/to/pi-session-exitThis is an independently versioned package with a pi.extensions manifest. Source is published on GitHub under MIT. It is not published to npm; private: true prevents accidental npm publication and does not prevent Git-based installation.
Run /session-exit in the TUI to show the current session ID and resume information without exiting. This command remains available when automatic output is disabled.
| Flag | Default | Behavior |
|---|---|---|
--session-exit-mode on|off |
on |
Enables or disables automatic exit output and the extension's signal handlers. |
--session-exit-signals graceful|host |
graceful |
Requests graceful host shutdown for supported OS signals, or leaves signals to the host. |
--session-exit-command '<JSON argv>' |
Automatic | Sets the executable and any prefix arguments used in the printed resume command. |
The default command detects native Pi, Senpi, or OMO. When an OMO launcher sets a non-default OMO_PROFILE, it is preserved as a positional profile argument, for example omo claude --session .... This matches launchers that accept named profiles positionally. Unrecognized launchers fall back to pi; use an explicit command when your launcher's syntax differs:
omo --session-exit-command '["omo","claude"]'
omo --session-exit-mode off
omo --session-exit-signals hostThe override is a JSON argument array, not a shell command string. The extension appends --session and the saved path, then quotes each argument for POSIX-compatible shells such as sh, bash, and zsh. Windows command-shell quoting is not supported. An invalid configuration disables automatic reminders and shows a warning.
Automatic output runs only in terminal UI mode with both stdin and stdout attached to a terminal. It does not add output or signal handlers to print, JSON, or RPC modes. Reloading the extension, starting a new session, resuming, and forking clean up the old listeners so the final reminder belongs to the active session.
With graceful signals, an OS SIGINT requests shutdown only while the host's terminal input is in raw mode. The extension ignores SIGINT during non-raw input, suspension, or an external editor. SIGTERM requests graceful shutdown. Native Ctrl+C keyboard behavior remains the host's own behavior.
The host's original exit hints may also appear. This package neither monkeypatches stdout nor replaces private host methods. A forced kill such as SIGKILL, a host crash, or a dead terminal cannot be guaranteed to produce a reminder.
Compatibility is checked against concrete host releases. Public extension APIs allow separate package updates, but arbitrary future breaking API changes are not guaranteed to work.
| Host | Version | Verification |
|---|---|---|
| Pi | 0.86.0 | 9 terminal scenarios passed on macOS |
| Pi | 0.87.0 | 9 terminal scenarios passed on macOS |
| Senpi via OMO 5.0.0-0.beta.81 | 2026.9.21-2 | 9 terminal scenarios passed on macOS |
| Senpi | 2026.9.22 | 9 terminal scenarios passed on macOS |
Verified on 2026-09-22: Ctrl+C keys, OS SIGINT, SIGTERM, fresh startup, reload, new session, the slash command, disabled mode, and invalid configuration. Saved cases restore a synthetic conversation by its exact ID. The four hosts also pass a compile-time check against their public ExtensionAPI declarations. Unit tests cover shell quoting, listener replacement, non-terminal modes, and signal policies.
The installed omo claude profile additionally passed fresh startup, saved-session restoration with Ctrl+C exit, and SIGINT exit using normal package discovery. Its shared settings use an absolute package path so copied profile settings resolve the same package.
From the package directory:
pnpm install
bun test test
pnpm typecheck
pnpm lintWithout a global pnpm installation, use npx --yes pnpm@10.33.0 check to run the type, lint, and unit-test gates.
Run the terminal integration harness against explicit local host installations:
SESSION_EXIT_TEST_HOSTS='[{"name":"pi-local","command":["node","/absolute/host/dist/cli.js"],"sdk":"/absolute/host/dist/index.js","resumeCommand":["pi"]}]' bun run test:tuiEach entry names a host, its CLI argument array, its SDK module, and the expected resume-command prefix. Use absolute host paths. Fixtures use isolated test session data and never make model requests. Set SESSION_EXIT_TEST_REPORT_DIR to an output directory to retain terminal captures for review.
The GitHub Actions workflow tests pinned and latest Pi/Senpi releases on pushes to main, pull requests, manual runs, and a weekly schedule. The badge reports the latest workflow result. These checks do not run automatically when an unrelated global host installation updates.
Remove the obsolete standalone --new flag from the existing launcher invocation. The host starts a fresh session by default; use explicit --session /absolute/path/to/session.jsonl to restore one. This migration makes no broader launcher changes.