Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## [Unreleased]

### Fixed

- Clarify prompt SSE fallback polling now preserves its owner session id, matching approval polling behavior so terminal events from another session cannot stop the active clarify fallback poller.

## [v0.51.152] — 2026-05-28 — Release DX (stage-batch34 — single-PR optional gateway-backed browser chat)

### Added
Expand Down
4 changes: 3 additions & 1 deletion static/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3147,7 +3147,8 @@ function startClarifyPolling(sid) {
});

_clarifyEventSource.onerror = function() {
stopClarifyPolling();
if (_clarifyEventSource) { try { _clarifyEventSource.close(); } catch(_){} _clarifyEventSource = null; }
if (_clarifyHealthTimer) { clearInterval(_clarifyHealthTimer); _clarifyHealthTimer = null; }
_startClarifyFallbackPoll(sid);
};

Expand Down Expand Up @@ -3177,6 +3178,7 @@ function startClarifyPolling(sid) {
}

function _startClarifyFallbackPoll(sid) {
_clarifyPollingSessionId = sid || null;
_clarifyFallbackTimer = setInterval(async () => {
if (!S.session || S.session.session_id !== sid) {
stopClarifyPolling(); _hideClarifyCardIfOwner(sid, true, 'session'); return;
Expand Down
15 changes: 15 additions & 0 deletions tests/test_session_runtime_ownership_invariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ def test_approval_and_clarify_pollers_are_stopped_by_owner_session(self):
"the active pane currently owns."
)

def test_clarify_sse_fallback_preserves_owner_session_id(self):
messages = read("static/messages.js")
start_clarify = _function_body(messages, "startClarifyPolling")
fallback = _function_body(messages, "_startClarifyFallbackPoll")

assert "_clarifyPollingSessionId = sid || null" in fallback, (
"Any clarify fallback poller should retain its owner session id."
)
onerror_idx = start_clarify.index("_clarifyEventSource.onerror")
onerror_body = start_clarify[onerror_idx:start_clarify.index("};", onerror_idx)]
assert "stopClarifyPolling();" not in onerror_body, (
"SSE fallback must not clear _clarifyPollingSessionId before starting the fallback poller."
)
assert "_startClarifyFallbackPoll(sid)" in onerror_body

def test_live_stream_transport_and_inflight_state_remain_session_keyed(self):
messages = read("static/messages.js")
close_live = _function_body(messages, "closeLiveStream")
Expand Down
Loading