Skip to content

The agent that grows with you

fix(pty): handle replay send failures cleanly

MKanso941d8b59a7db
diff --git a/hermes_cli/pty_session.py b/hermes_cli/pty_session.py
index 7a35bd1aec4..a1e5623f177 100644
--- a/hermes_cli/pty_session.py
+++ b/hermes_cli/pty_session.py
@@ -113,7 +113,7 @@ class PtySession:
await ws.send_bytes(snap)
except Exception:
self.detach(ws)
- raise
+ return False
if force_redraw:
return await self.write(ws, TUI_FORCE_REDRAW)
return True
diff --git a/tests/hermes_cli/test_pty_session.py b/tests/hermes_cli/test_pty_session.py
index ee69295db0d..2ad3f6c849e 100644
--- a/tests/hermes_cli/test_pty_session.py
+++ b/tests/hermes_cli/test_pty_session.py
@@ -95,9 +95,9 @@ async def test_failed_replay_detaches_session():
s = PtySession("k", FakeBridge([b""]), buffer_cap=1024, read_timeout=0.01)
s.buffer.append(b"replay")
+ ws = FailingWS()
- with pytest.raises(RuntimeError, match="socket closed"):
- await s.attach(FailingWS())
+ assert await s.attach(ws) is False
assert s.attached is False
assert s.last_detached_at is not None