dsh-auto-reconnect
在终端中运行以下命令:
dsh plugin install tqcq/dsh-auto-reconnect
将以下提示词粘贴到 DeepSeek Harness 对话框中:
在 DeepSeek Harness 中,于 dsh-web 运行目录下执行 dsh plugin install tqcq/dsh-auto-reconnect 即可安装该插件,完整源码见 https://github.com/tqcq/dsh-auto-reconnect ,安装或卸载后需重启 dsh-web 方可生效。
插件介绍
The official DSH connection controller ships with exponential-backoff reconnect, but a source audit of dsh-client-connection 0.1.2-rc.1 uncovered two real-world blind spots. First, once backoff tops out the controller enters a terminal disconnected state and only wakes on the browser online event or a manual tap; phone sleep-and-wake keeps navigator.onLine true the whole time, so online never fires and the connection stays stuck until someone taps the page. Second, the client has no visibilitychange or focus listener and no heartbeat, so a silently dropped TCP link leaves the WebSocket in OPEN with the state still reporting connected — a zombie connection that looks alive but is not.
dsh-auto-reconnect is a narrowly scoped, client-only fix for exactly those two scenarios. It listens to visibilitychange(→visible), focus, pointerdown, keydown, pageshow(persisted), and subscribes to the connection state store, but calls connection.reconnect() only when the state is not already connected, so a healthy connection is never interrupted. A bfcache restore (persisted true) re-connects unconditionally because sockets are dead by definition. When the controller slides into terminal disconnected, the plugin schedules a delayed auto-retry (3 s default) with a budget of 20 consecutive attempts that resets on a successful connection — covering the awkward case where the page is already visible and focused and no browser event will ever fire again. Every trigger is logged with a [dsh-auto-reconnect] prefix, throttled to 3 s by default, for easy DevTools forensics. If the upstream API shape drifts (ctx.connection mismatch), the plugin logs a warning and stays idle rather than breaking the page.
It is aimed at anyone who uses the DSH web client on phones or tablets, switches between apps frequently, sleeps and wakes the screen regularly, or works in NAT environments where background tabs quietly lose their TCP link. Zero build, no official package is modified, and a single dsh-web restart after install or uninstall is all the ceremony required.
使用场景
- 手机锁屏唤醒后连接卡死在终态,需手动点击才能恢复
- 后台 Tab 被 NAT 静默断开 TCP,前端仍显示已连接但实际无法通信
- 硬刷新或 bfcache 恢复后 socket 已死,官方控制器不会主动重连
适合人员
- 手机或平板端日常使用 DSH Web 客户端的开发者
- 频繁锁屏唤醒、切换应用的移动端用户
- 处于 NAT 环境、后台 Tab 易被断连的网络场景