Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

2.4 KB
Raw Blame

The Web App catches up on its own when a live stream dies silently

  • Date: 2026-10-13
  • Type: fix
  • Scope: server, web, docs

中文版

Ported from upstream PenguinHarness (#1026, commit 99dacb54).

A Session stream or the user event stream whose connection died without an error (a half-open connection, a stuck proxy or NAT, a laptop that slept or changed networks) left the page frozen until it was reloaded, while the Agent kept running on the server. The page now notices the silence and resumes the stream from the last event it received, and the server cuts off a stream whose peer stopped reading.

Details

  • The server's heartbeat is now a named ping event (data: {}, no id: line), sent right after a stream's initial events and every 20 seconds after, instead of a comment line the page could not see. It moves neither the client's Last-Event-ID nor the replay position.
  • Once a stream has sent a ping, the Web App treats 50 seconds without any event as a dead connection: it closes the stream and opens a new one from the last event id it saw, which the server replays from, or answers with resync_required when that id has left its buffer. Showing the tab checks at once.
  • A stream from a server that never pings, such as a machine still on an older version, and a stream the browser gave up on are left as they were before.
  • GET /api/sessions/:id/stream and GET /api/events accept the last event id as the lastEventId query parameter when no Last-Event-ID header is sent, since a page cannot set headers on an EventSource it opens itself. The header wins when both are present.
  • An event stream whose socket sends nothing for 40 seconds (up to 80 while a write is pending) has its connection closed, so a client that is still there reconnects and resumes.
  • The server API reference (/docs/server-api, § Streaming (SSE)) documents the ping event, the lastEventId parameter, the idle timeout and the client's liveness check.

Compatibility

  • Old server, new page. The watchdog arms on a stream's first ping only. A server that never pings — a machine on an older version behind the proxy — gets a plain EventSource exactly as before.
  • New server, old page. The old page has no listener for the named ping, and the id-less frame leaves its Last-Event-ID alone.
  • Nothing on disk changes, so there is no backward-compatibility step.