fix: Browser tab in Chrome mode keeps reconnecting when its chat is open in two windows (#34133)

* fix: Browser tab in Chrome mode keeps reconnecting when its chat is open in two windows

With the same chat open in two windows, the terminal hands the Chrome tab to the newer window, but the older window only saw a lost connection. It reconnected and took the tab back, so both windows kept flipping to "Reconnecting…" and the "Browser opened in another viewer." message never showed. The terminal's reason for ending the tab's connection now reaches the page, as it already does for the shell. The window that lost the tab shows that message and stops, and the other window keeps the page.

Fixes #34095

* fix: Browser tab in Chrome mode keeps reconnecting when its chat is open in two windows

Narrows the change to passing the terminal's close reason on to the page. The relay's existing handling of a broken connection stays as it was.
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-12 22:00:12 +09:00
1 parent 7429093191
commit 408e89d7e8
1 file changed
+2
+2
View File
@@ -198,6 +198,8 @@ async def relay_to_browser(ws, upstream):
await ws.send_bytes(msg.data)
else:
return
code = upstream.close_code or 1011
await ws.close(code=1011 if code in (1005, 1006, 1015) else code)
async def watch_access(server_id, sid, browser_token, request):