mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 18:10:45 +08:00
fix(webcrt): keep session across WS remount and fix blank terminal
Allow brief WebSocket re-attach after React StrictMode cleanup, ensure terminal pane has layout height, and show connect status in xterm. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
873f2bfe34
commit
183cb7eec9
5 changed files with 95 additions and 21 deletions
|
|
@ -15,6 +15,8 @@ from .db import get_db
|
|||
from .webcrt_service import (
|
||||
close_session,
|
||||
create_session,
|
||||
detach_session,
|
||||
get_session,
|
||||
list_sessions,
|
||||
mark_attached,
|
||||
)
|
||||
|
|
@ -151,6 +153,12 @@ async def websocket_session(websocket: WebSocket, session_id: str) -> None:
|
|||
sess.touch()
|
||||
await websocket.send_json({"type": "pong"})
|
||||
elif mtype == "close":
|
||||
stop.set()
|
||||
close_session(
|
||||
session_id,
|
||||
reason="client_close",
|
||||
client=_client_label(websocket=websocket),
|
||||
)
|
||||
break
|
||||
except WebSocketDisconnect:
|
||||
_log.info("webcrt ws disconnected session=%s", session_id)
|
||||
|
|
@ -163,8 +171,10 @@ async def websocket_session(websocket: WebSocket, session_id: str) -> None:
|
|||
await reader_task
|
||||
except Exception:
|
||||
pass
|
||||
close_session(
|
||||
session_id,
|
||||
reason="ws_disconnect",
|
||||
client=_client_label(websocket=websocket),
|
||||
)
|
||||
# Keep device session briefly so React remount / blip can re-attach.
|
||||
if get_session(session_id) is not None:
|
||||
detach_session(
|
||||
session_id,
|
||||
grace_sec=8.0,
|
||||
client=_client_label(websocket=websocket),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue