Problem
When a Mac sleeps with Hermes Desktop open, the WebSocket connection drops. The TUI gateway parks the session but reaps it after only 20 seconds (HERMES_TUI_WS_ORPHAN_REAP_GRACE_S). On wake, Desktop holds a stale runtime session ID — any action (send message, interrupt) 404s with "session not found".
The Desktop frontend already has retry logic (use-prompt-actions.ts:667-686) that catches the 404, calls session.resume to re-register, and retries once. This means the team already knows this race exists — but the grace window is still far too short for real-world sleep durations (minutes to hours).
Steps to Reproduce
- Open Hermes Desktop with an active session
- Close the MacBook lid (sleep) for >20 seconds
- Wake the Mac
- Try to send a message in the existing session
- Observe "session not found" error (may recover via retry, may not)
Root Cause
tui_gateway/server.py:146-162:
_WS_ORPHAN_REAP_GRACE_S = 20.0 # default
This grace was designed to prevent leaked _SlashWorker processes from browser refreshes (#38591), not to handle sleep/wake. For sleep/wake, 20s is effectively instant.
Environment
- Hermes Desktop (Electron) on macOS
- Gateway: embedded TUI gateway
- Reproducible: every sleep/wake cycle >20s
Problem
When a Mac sleeps with Hermes Desktop open, the WebSocket connection drops. The TUI gateway parks the session but reaps it after only 20 seconds (
HERMES_TUI_WS_ORPHAN_REAP_GRACE_S). On wake, Desktop holds a stale runtime session ID — any action (send message, interrupt) 404s with "session not found".The Desktop frontend already has retry logic (
use-prompt-actions.ts:667-686) that catches the 404, callssession.resumeto re-register, and retries once. This means the team already knows this race exists — but the grace window is still far too short for real-world sleep durations (minutes to hours).Steps to Reproduce
Root Cause
tui_gateway/server.py:146-162:This grace was designed to prevent leaked
_SlashWorkerprocesses from browser refreshes (#38591), not to handle sleep/wake. For sleep/wake, 20s is effectively instant.Environment