feat(web): resume live streaming when switching back to a session

This commit is contained in:
zhayujie
2026-06-08 17:32:27 +08:00
parent 7cf0f7d42d
commit ec9557e3d8
2 changed files with 126 additions and 82 deletions

View File

@@ -947,7 +947,12 @@ class WebChannel(ChatChannel):
post_done = True
post_deadline = time.time() + 2 # 2s post-attach tail
finally:
self.sse_queues.pop(request_id, None)
# Only drop the queue once the reply is actually complete. If the
# client disconnected early (e.g. switched sessions and will
# re-attach with the same request_id), keep the queue so the new
# connection can resume reading the remaining events.
if post_done or time.time() >= deadline:
self.sse_queues.pop(request_id, None)
def cancel_request(self):
"""