* fix(#3668): snapshot live turn before stream teardown on session switch
The 'stays gone' variant: switching away from a streaming session during a quiet
window (mid tool-exec / silent thinking, between content SSE events) left a
stale/absent live-turn snapshot, so restoreLiveTurnHtmlForSession() failed on
switch-back and loadSession()'s fallback rebuilt with an empty appendThinking(),
permanently losing streamed thinking/tool content (only the elapsed clock
survived). closeLiveStream() now snapshots the live-turn DOM via
snapshotLiveTurnHtmlForSession(sessionId) BEFORE closing the source + tearing
down LIVE_STREAMS, so switch-back always restores the exact state shown at
switch-away. + regression test asserting snapshot precedes teardown.
* docs(changelog): v0.51.291 — Release JG (stage-s2, #3668)
---------
Co-authored-by: nesquena-hermes <[email protected]>
Regression test for #3668. The reporter observed clarify/approval cards
appearing to vanish when switching away from a blocked session and back,
making the agent look stuck. The teardown half they cited (sessions.js
hides the cards on switch) is real, but the re-show half ships in the same
loadSession(): per-session in-memory pending caches + _renderPendingPrompts
ForActiveSession() + polling re-arm + SSE 'initial' re-fetch. Verified
already-working live (shipped v0.51.19 / #1829); this test locks the
invariant so it cannot silently regress.
A node-driver runs the real extracted JS functions through the
switch-away -> switch-back sequence (RED/GREEN-validated against a
simulated over-broad teardown that clears the cache).
Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com>