fix: reuse inflight session stream#1467
Conversation
|
Thanks for the surgical PR. The reuse-existing-stream invariant is the right shape, and pulling the A few things to consider before merge: 1. (typeof EventSource==='undefined'||existingLive.source.readyState!==EventSource.CLOSED)
2. Reuse skips The reuse path currently early-returns. If In the current call sites I think this can't happen —
3. Test: regex against close_pos = body.find("closeLiveStream(activeSid)")This will match Also: 4.
5. Worth pinning in a separate test: the case where Otherwise this looks like a clean first step in the #1466 sequence. The 21 passing tests + non-ASCII check is the right level of rigor for a small reliability fix. I'll let Nathan make the call on whether (1)–(5) are blocking or follow-up. |
|
Thanks for the detailed review. I pushed
Targeted local verification on the updated head:
|
|
Thanks —
23 passing + non-ASCII guard at 0 is the right rigor bar. Nothing else from me — leaving the merge call to Nathan. |
5650d11
…w-up - CHANGELOG.md: v0.50.267 entry detailing nesquena#1454/nesquena#1474/nesquena#1461/nesquena#1465/nesquena#1467/nesquena#1460/nesquena#1473 + Opus advisor SHOULD-FIX trailing-empty guard for _norm_model_id - ROADMAP.md: bump to v0.50.267, 3776 tests collected - TESTING.md: bump header + total to 3776 - api/config.py: trailing-empty fallback in _norm_model_id (parts[-1] or s) - static/ui.js: mirror trailing-empty fallback in _normalizeConfiguredModelKey - tests/test_norm_model_id_trailing_empty_guard.py: 5 regression tests
Thinking Path
attachLiveStream()is called again for the same active stream.What Changed
attachLiveStream()now checksLIVE_STREAMS[session_id]before closing an existing stream.streamIdand is not closed, the function reuses it instead of closing/reopening theEventSource.INFLIGHT[session_id]state is still initialized/updated before the reuse check so session switch-back can restore the active pane's running state.loadSession()reattach path.Why It Matters
SSE stream events are not a replay log. Tearing down and reopening the same running stream during sidebar navigation creates a small timing window where events can be consumed by the old transport but not reflected back into the current pane/cache.
This is the first small step in improving reliability for in-flight session switching. It follows the direction in #1466: keep the currently viewed pane separate from per-session runtime state.
Verification
Result:
Also checked the added diff for accidental non-ASCII text:
Risks / Follow-ups
EventSourceas closed, the old close/reopen path is still used.Model Used
OpenAI GPT-5.5 via Hermes Agent.
Refs #1466