anomalyco / anomalyco/opencode

Event stream (SSE) doesn't resume after tab is backgrounded and restored — requires manual page refresh

Open
#47,258 3 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Sep 4, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

In packages/app/src/context/server-sdk.tsx, pagehide always calls stop() on the event stream (lines ~325-328), but pageshow only calls start() again if event.persisted === true (resumeStreamAfterPageShow, lines 162-165).

Since the event stream itself is an open streaming fetch() connection, it is a known bfcache blocker in most browsers — meaning the page is often not bfcache-eligible, so persisted comes back false on pageshow, and start() is never called.

Result: After backgrounding/returning to the tab (switching apps, locking screen, etc.), the live event stream stays dead and the UI stops reflecting session updates until a full manual page refresh remounts the app.

Confirmed as web-UI-specific: OpenChamber (a third-party client using the same server API/event stream) does not exhibit this issue — server side is fine.

Relevant code:

// lines 162-165
export function resumeStreamAfterPageShow(event: PageTransitionEvent, start: () => unknown) {
  if (!event.persisted) return
  start()
}

// lines 325-328 (onMount)
makeEventListener(window, "pagehide", stop)
makeEventListener(window, "pageshow", (event) => resumeStreamAfterPageShow(event, start))

### Plugins

_No response_

### OpenCode version

_No response_

### Steps to reproduce

_No response_

### Screenshot and/or share link

_No response_

### Operating System

_No response_

### Terminal

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.