4 Commits
Author SHA1 Message Date
10e5c52b10 Release: broadcast terminal output to every viewer (#5836, @ai-ag2026) (#6340)
* feat(terminal): broadcast output to every viewer instead of one shared queue

TerminalSession.output was a single queue.Queue read destructively by the SSE
handler. Two tabs/windows viewing the SAME session each open their own
EventSource, so two _handle_terminal_output handlers competed on that one queue:
every PTY chunk was delivered to exactly one of them. Each tab saw a disjoint
half of the byte stream, and only one ever received terminal_closed.

Output now fans out, mirroring StreamChannel/SessionChannel: each SSE consumer
subscribe()s its own queue (seeded with a bounded backlog so a first/late attach
still replays the recent scrollback, preserving the old buffer-until-first-
consumer behaviour), and put_output broadcasts to all subscribers. A slow
viewer's queue drops its own oldest chunk (drop-oldest, isolated per subscriber)
so one lagging tab can't starve another. The handler unsubscribes in a finally
so the subscriber list can't grow.

Stacked on the terminal fd-leak fix (same file).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: cover terminal broadcast lifecycle

* fix: serialize terminal subscriber fanout

* test: cover terminal unsubscribe publication race

* restore timing-flaky pytest.skip on test_terminal_survives_short_lived_request_thread (keep API-updated body); changelog #5836

---------

Co-authored-by: ai-ag2026 <261867348+ai-ag2026@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: nesquena-hermes <agent@nesquena-hermes>
2026-07-19 22:08:29 +00:00
d6e5dc302d Release Batch D: terminal resource-leak fix + fsync atomic writers (#5835, #5843) (#5848)
Phase 2 backend reliability/data-integrity batch. Each byte-verified vs PR head,
Codex SAFE, 20 own + 355 regression tests pass, disjoint files.

- #5835 (ai-ag2026): stop leaking fd + reader thread + shell on client/shell exit (#4633 family)
- #5843 (ai-ag2026): fsync atomic JSON writers (oauth/passkeys/discoverability) + thread-safe temp

Co-authored-by: t <a@b>
Co-authored-by: ai-ag2026 <ai-ag2026@users.noreply.github.com>
2026-07-09 10:54:06 -07:00
nesquena-hermes a8e2279d73 stage-batch26: skip test_terminal_survives_short_lived_request_thread (timing flaky)
The 7 other tests in this file deterministically cover the supervisor invariants
(concurrent spawn, timeout-race reap, Popen-failure recovery, supervisor singleton).
This 1 test depends on bash prompt rendering + printf execution echoing through
the PTY within a 1s deadline, which is timing-flaky in non-tty CI.
2026-05-27 04:48:21 +00:00
Rehan Khan 0db8f5ded4 fix(terminal): harden supervisor lifecycle and eliminate timeout race conditions
- Split timeout state from spawn completion using timed_out flag
- Ensure request.done represents only spawn completion
- Add per-request locking to enforce atomic lifecycle resolution
- Prevent late Popen results from mutating timed-out requests
- Reap abandoned subprocesses before terminal registry assignment
- Strengthen supervisor stability under repeated failure and mixed workloads
- Add regression coverage for timeout + race + failure scenarios
2026-05-25 20:45:17 +05:00