Skip to content

Session stuck in "online" state after CLI exits — "Archive Session" and "Stop Daemon" both fail with errors #725

@chy5301

Description

@chy5301

Describe the bug

When the CLI process on the target device exits unexpectedly (e.g., terminal closed abruptly or Ctrl-C pressed twice to exit), the session remains shown as online in both the app and web client. Attempts to manually clean up the session via the UI result in errors.

Steps to reproduce

  1. Start a session via the CLI on a target device and connect via the app or web client.
  2. On the target device, either:
    • Close the terminal window abruptly, or
    • Press Ctrl-C twice to exit the CLI process (first press interrupts the current task, second press exits the process)
  3. The session continues to appear as online in the app/web UI.
  4. Any messages sent receive no response.
  5. Open the session management panel (tap the session avatar in the session view).
  6. Tap "Archive Session" (described as "archive this session and stop it") → Error: RPC call failed
  7. Go back, tap "View Device", then attempt "Stop Daemon" in the sub-panel → Error: failed to stop daemon. it may not be running

Expected behavior

  • Either the session should automatically transition to offline/disconnected when the CLI process exits, or
  • The "Archive Session" / "Stop Daemon" actions should handle the case where the CLI is already gone — gracefully marking the session as offline rather than returning an error.

Actual behavior

  • Session is stuck in online state indefinitely.
  • "Archive Session" fails with: Error: RPC call failed
  • "Stop Daemon" fails with: failed to stop daemon. it may not be running
  • No way to clear the zombie session from the UI.

Root cause hypothesis

Both "Archive Session" and "Stop Daemon" appear to attempt an RPC call to the CLI process on the target device. Since the process is already dead, the RPC naturally fails — but the error is surfaced to the user rather than being handled gracefully. The UI should detect that the target is unreachable and fall back to a local/server-side cleanup (e.g., force-marking the session as offline/archived without requiring a live RPC response).

Environment

Item Version
happy CLI version 0.13.0
Claude Code version 2.1.50
OS Windows 11 Pro 25H2 (OS Build 26200.7840)
Client App & Web (both affected)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions