feat: browser stream waits through round gaps instead of disconnecting

Stale bridge state used to end the stream on the first stale read,
so every round gap and every worker restart killed the watch (the
2026-10-30 demo watch died this way when a 15:03 deploy restarted
the worker). Now a stale state switches to a waiting heartbeat
every 5s while the task is still alive (running/queued/paused/
interrupted), and frames resume when the next round's MCP starts
polling. The stream ends only on a terminal task state, a missing
task row, or 10 minutes of continuous staleness. The panel shows
a waiting status and keeps the last frame. Also force-close the
SSE connection on stream end: HTTP/1.1 keep-alive otherwise left
terminal streams hanging with no EOF.
This commit is contained in:
host committed 2026-10-30 15:14:37 +08:00
1 parent 671b4bedef
commit 962bb50a1c
4 files changed
+137 -22

No files matched your search

@@ -105,9 +105,23 @@ export default function BrowserPanel() {
holder?: string;
url?: string;
title?: string;
waiting?: boolean;
task_status?: string;
};
if (payload.image) {
if (payload.waiting) {
// Round gap / worker restart: the server keeps
// the stream open instead of dropping the watch.
// Keep the last frame on screen, just say so.
setStatus(
payload.task_status === "interrupted"
? "任务已中断,等待续跑…"
: payload.task_status === "paused"
? "任务已暂停…"
: "等待会话…",
);
} else if (payload.image) {
setImg("data:image/jpeg;base64," + payload.image);
setStatus("直播中");
}
const patch: BrowserState = {};
if (payload.holder) patch.holder = payload.holder;