Dashboard › opencode › Persistent PTY listener, ownership, and…
01a0a68c-ac72-7bad-93c5-d6a19778dc58For 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.