perf: 小优化组 + 恢复浏览器页签

1. MCP 空闲睡眠 50ms -> 10ms:#187 后单轮 drain 约 0.3ms,
   100 次/s 空闲迭代约 3% 单核,请求与远控输入拾取延迟
   从平均 25ms 降到 5ms。
2. stream 轮询 50ms -> 20ms。
3. stream payload 加 url/title;面板 stream 处理合并 url/
   title,5 秒 state 轮询只在未观看时跑(观看时 stream 已
   全量覆盖,轮询纯冗余;不观看时保留轮询,避免会话开始
   后页眉 stale)。
4. 恢复浏览器页签:#176(ccb5a86)改写 TaskDetailPanel
   页签时顺带删了 BrowserPanel 的挂载,导致线上控制台
   自 #176 起就没有浏览器页签(面板文件一直在,只是不
   被 import,构建产物因此不变)。本次把 import、页签
   与 Card 原样挂回;构建产物含“开始观看”标记可证。
console.html 由 npm run build:console 重打(342484 字节)。
console-redesign/ 为构建脚本审阅产物,不进仓库。
This commit is contained in:
host committed 2026-10-30 14:09:02 +08:00
1 parent 5e562d8413
commit cbf5e65a7a
7 files changed
+79 -40

No files matched your search

+10 -5
View File
@@ -5318,11 +5318,14 @@ class CloudControlPlaneHandler(BaseHTTPRequestHandler):
def _browser_stream(self, user_id, task_id):
"""GET /tasks/{id}/browser/stream: SSE from bridge files.
Polls the frame file every 50ms and emits a data line
Polls the frame file every 20ms and emits a data line
whenever its bytes change (plus a heartbeat with the
current holder at least every 5s). Ends the stream when
the state file goes stale, so a dead session reads as a
disconnect, not a frozen picture.
current holder at least every 5s). The payload also
carries the session url/title, so the console panel can
track the header from the stream alone instead of
polling the state endpoint while watching. Ends the
stream when the state file goes stale, so a dead
session reads as a disconnect, not a frozen picture.
"""
import time
from cloud.playwright_remote import (
@@ -5360,11 +5363,13 @@ class CloudControlPlaneHandler(BaseHTTPRequestHandler):
payload = json.dumps(
{"image": frame,
"holder": effective_holder(worktree, state),
"url": state.get("url", ""),
"title": state.get("title", ""),
"ts": int(now)}, ensure_ascii=False)
self.wfile.write(
("data: %s\n\n" % payload).encode("utf-8"))
self.wfile.flush()
time.sleep(0.05)
time.sleep(0.02)
except (BrokenPipeError, ConnectionResetError, OSError):
pass