DashboardopencodePersistent PTY listener, ownership, and…

Persistent PTY listener, ownership, and exit-delivery invariants

Category: gotcha
Confidence: 1.00
ID: 01a0a68c-ac72-7bad-93c5-d6a19778dc58
Project ID: c0425955-02bc-4c17-9af2-b114c00077e7
Cross-project: No
Recalled in other projects: 0
Source session: 07PmcXIbo6QNZwYRV
Created: 2026-09-08 02:32:48
Updated: 2026-09-15 19:30:32

Content

For persistent PTYs, register data, error, close, and exit listeners synchronously immediately after new Terminal() and before awaiting spawn; bun-pty 0.4.10 begins reading via queueMicrotask, so yielding can lose immediate output or fast exits. On close, resolve termination and derive final output immediately; track bounded synthetic-notification delivery separately so it cannot block closure. Send plugin-generated <pty_exited> notices through session.synthetic, not session.prompt, and await delivery or retain admission until durable. Every PTY belongs to its parentSessionID: require it to match context.sessionID for lookup, read, write, and kill, and list only caller-owned PTYs unless explicit cross-session administration exists.

Move to: