# I stopped spawning a second Pi just to switch sessions

> Source: <https://dev.to/imper_7cde72b79d2529291ec/i-stopped-spawning-a-second-pi-just-to-switch-sessions-9cb>
> Published: 2026-08-23 14:23:00+00:00

I use the Pi coding agent from several project folders. After a while, `pi --resume`

became a long list of sessions with similar first prompts. I kept reopening the wrong one.

I made [pisesh](https://github.com/Blue-B/pisesh) to add the things I wanted in that list: favorites, search, custom names, a current-project view, and optional title generation. It is a single Node script with no runtime dependencies.

`/sesh`

implementation
The first version took a direct route. It paused Pi's TUI, opened the pisesh picker, then started another Pi process for the selected session.

That was useful because leaving the child process returned me to the original session. It also meant the process tree looked like this:

```
Pi session A
  pisesh
    Pi session B
```

The nested process eventually became the problem. Tools were running in session B, but anything watching the outer Pi process could still see session A as idle. The terminal looked right while the runtime lifecycle was wrong.

Pi already exposes `ctx.switchSession()`

to extensions. In pisesh 0.3.0, the picker no longer starts Pi when it was opened through `/sesh`

.

The picker writes one small JSON selection to a private file descriptor. It includes the absolute session path and the selected model behavior. The extension reads that result and asks Pi to switch the current runtime:

```
Pi session A
  /sesh picker
  ctx.switchSession(sessionB)
Pi session B
```

Standalone `pisesh`

still starts `pi --session`

, so the shell command keeps its old behavior. Only the extension path changed.

There were two details I did not want to lose. `Enter`

still resumes with the current default model and thinking level, while `o`

restores the values recorded in the selected session. Interrupted tool calls are also repaired before the handoff when Pi would otherwise load an incomplete transcript.

```
pi install npm:pisesh
```

Then run `/sesh`

inside Pi. The package is MIT licensed and works on Node 18 or newer.
