Split session daemon from web server

This commit is contained in:
Federico Jaramillo Martinez
2026-05-07 13:12:48 +02:00
parent fa55723246
commit 2ffff85313
9 changed files with 272 additions and 93 deletions
+16 -5
View File
@@ -8,7 +8,7 @@ Small web wrapper around `@mariozechner/pi-coding-agent`.
- Discover workspaces from `git worktree list --porcelain`.
- For non-git projects, show the project folder as the only workspace.
- List Pi sessions for a workspace using Pi's default session storage.
- Start Pi sessions, chat over WebSocket events, and close active runtimes.
- Start Pi sessions, chat over WebSocket events, and stop individual session runtimes.
## State
@@ -17,7 +17,7 @@ This POC intentionally keeps state minimal:
- Projects: `~/.pi-web/projects.json`
- Workspaces: discovered from git, not stored
- Sessions/chat history: Pi default JSONL session storage
- Active sessions/WebSockets: memory only
- Active session runtimes/WebSockets: memory only in `pi-web-sessiond`
## Run
@@ -28,19 +28,30 @@ npm run dev
Open the Vite URL, usually <http://localhost:5173>.
For a single-process/proxied deployment:
The session runtime owner is split into a tiny long-lived daemon. To iterate on only the web/API/UI process while keeping active Pi sessions alive, run these in separate terminals:
```bash
npm run dev:sessiond
npm run dev:web
npm run dev:client
```
Then restart `dev:web` or `dev:client` freely; active Pi sessions continue in `dev:sessiond`.
For deployment:
```bash
npm run build
npm run start:sessiond
PI_WEB_PORT=3000 npm start
```
Then proxy Traefik to `http://127.0.0.1:3000`.
The server defaults to `127.0.0.1:3000`. Use `PI_WEB_HOST=0.0.0.0` only if you want to bind directly on all interfaces.
The web server defaults to `127.0.0.1:3000`. Use `PI_WEB_HOST=0.0.0.0` only if you want to bind directly on all interfaces. The session daemon defaults to a private Unix socket at `~/.pi-web/sessiond.sock`; override with `PI_WEB_SESSIOND_SOCKET` or use TCP with `PI_WEB_SESSIOND_PORT` plus `PI_WEB_SESSIOND_URL` for the web process.
## Notes
- The backend uses your normal Pi auth/model settings from `~/.pi/agent`.
- Slash commands that belong to Pi's interactive TUI, such as `/model`, are not implemented in this POC UI yet. Plain prompts and extension/prompt-template handling go through the SDK path.
- `Close` currently only disposes the in-memory runtime. It does not hide or delete sessions.
- Browser disconnects and web-server restarts do not stop active Pi sessions. Only the explicit `Stop session` action aborts/disposes that one session runtime.