Skip to content

[BUG] SSE connection becomes stale after laptop sleep/wake — no detection or recovery #21716

@aokuwa-lila

Description

@aokuwa-lila

Problem

After a laptop sleeps and wakes, the SSE connection between the OpenCode plugin and the OpenCode server becomes stale. The connection appears open but no longer receives events. The UI may show a loading state indefinitely or fail silently.

Steps to Reproduce

  1. Start an OpenCode session with the plugin active
  2. Put laptop to sleep (close lid or system sleep)
  3. Wake laptop after 30+ seconds
  4. Attempt to continue the session
  5. Observe: SSE connection is stale, no events received, UI may be stuck

Expected Behavior

The plugin should detect stale SSE connections and either:

  • Automatically reconnect
  • Surface an error to the user
  • Provide a manual reconnect action

Actual Behavior

Connection remains "open" but unresponsive. No detection, no recovery, no user-facing signal.

Environment

  • OpenCode version: [to be filled]
  • Plugin version: [to be filled]
  • OS: macOS (likely affects all platforms)
  • Sleep duration: 30+ seconds

Additional Context

Related to idle session handling (#21524) and session recovery (#21525), but this is a distinct failure mode specific to SSE connection health after system sleep/wake.

Proposed Solution

Implement SSE connection health checking:

  • Heartbeat mechanism with timeout
  • Exponential backoff reconnection
  • User-facing connection status indicator

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions