{"slug": "i-stopped-spawning-a-second-pi-just-to-switch-sessions", "title": "I stopped spawning a second Pi just to switch sessions", "summary": "A developer created pisesh, a Node-based session picker for the Pi coding agent, to address the problem of managing many similar sessions. The tool adds favorites, search, custom names, and a current-project view. In version 0.3.0, the developer integrated it with Pi's ctx.switchSession() extension API, allowing the picker to switch sessions within the same Pi process instead of spawning a nested Pi process, fixing runtime lifecycle issues.", "body_md": "I use the Pi coding agent from several project folders. After a while, `pi --resume`\n\nbecame a long list of sessions with similar first prompts. I kept reopening the wrong one.\n\nI 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.\n\n`/sesh`\n\nimplementation\nThe first version took a direct route. It paused Pi's TUI, opened the pisesh picker, then started another Pi process for the selected session.\n\nThat was useful because leaving the child process returned me to the original session. It also meant the process tree looked like this:\n\n```\nPi session A\n  pisesh\n    Pi session B\n```\n\nThe 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.\n\nPi already exposes `ctx.switchSession()`\n\nto extensions. In pisesh 0.3.0, the picker no longer starts Pi when it was opened through `/sesh`\n\n.\n\nThe 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:\n\n```\nPi session A\n  /sesh picker\n  ctx.switchSession(sessionB)\nPi session B\n```\n\nStandalone `pisesh`\n\nstill starts `pi --session`\n\n, so the shell command keeps its old behavior. Only the extension path changed.\n\nThere were two details I did not want to lose. `Enter`\n\nstill resumes with the current default model and thinking level, while `o`\n\nrestores the values recorded in the selected session. Interrupted tool calls are also repaired before the handoff when Pi would otherwise load an incomplete transcript.\n\n```\npi install npm:pisesh\n```\n\nThen run `/sesh`\n\ninside Pi. The package is MIT licensed and works on Node 18 or newer.", "url": "https://wpnews.pro/news/i-stopped-spawning-a-second-pi-just-to-switch-sessions", "canonical_source": "https://dev.to/imper_7cde72b79d2529291ec/i-stopped-spawning-a-second-pi-just-to-switch-sessions-9cb", "published_at": "2026-08-23 14:23:00+00:00", "updated_at": "2026-08-23 14:44:03.539337+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Pi", "pisesh", "Blue-B", "Node"], "alternates": {"html": "https://wpnews.pro/news/i-stopped-spawning-a-second-pi-just-to-switch-sessions", "markdown": "https://wpnews.pro/news/i-stopped-spawning-a-second-pi-just-to-switch-sessions.md", "text": "https://wpnews.pro/news/i-stopped-spawning-a-second-pi-just-to-switch-sessions.txt", "jsonld": "https://wpnews.pro/news/i-stopped-spawning-a-second-pi-just-to-switch-sessions.jsonld"}}