Introduction¶
The official connection controller in the DeepSeek Harness (DSH) Web client has a built-in backoff reconnection mechanism, but two blind spots exist in real-world use: first, it cannot automatically recover when the terminal disconnected state enters an infinite loop; second, network fluctuations can leave the WebSocket in the OPEN state while it is actually disconnected, creating a “zombie connection.” The dsh-auto-reconnect plugin listens to browser visibility and focus events to wake up and repair these two scenarios.
Plugin Overview¶
This is a client-only automatic reconnection plugin. It is zero-build and does not modify the official packages. It is provided by maintainer tqcq and licensed under the MIT License.
Core Features¶
The plugin subscribes to the connection state store and calls connection.reconnect() only when the state is not connected, avoiding interruption of healthy connections. Specific capabilities include:
- Event Wake-up: Listens to events such as
visibilitychange,focus,pointerdown,keydown, andpageshow(persisted). When browser visibility changes or the page is restored, if the connection state is abnormal, it reconnects immediately. - Repair Terminal Disconnection: Addresses the issue where the official controller sleeps when the terminal is in the
disconnectedstate by adding automatic retry logic. The default interval is 3 seconds, with up to 20 retries until the connection succeeds. - Repair Zombie Connections: Addresses the false
connectedstate caused by silent TCP dropouts by adding visibility and focus listeners, ensuring the connection state matches the actual network. - Logging: All triggered operations include the
[dsh-auto-reconnect]prefix, making it easier to troubleshoot issues in the DevTools console.
Installation and Activation¶
Installing the plugin requires restarting the dsh-web process. Refreshing the browser is not sufficient.
- Install:
Run the following command to install the plugin:
dsh plugin --profile web add github:tqcq/dsh-auto-reconnect
- Update:
To upgrade the plugin:
dsh plugin --profile web update dsh-auto-reconnect
- Remove:
To uninstall the plugin:
dsh plugin --profile web remove dsh-auto-reconnect
Typical Usage¶
After installation, you can adjust the reconnection strategy in localStorage in the browser without restarting the dsh-web process. Refresh the page to apply changes:
localStorage["dsh-auto-reconnect"] = JSON.stringify({
minIntervalMs: 3000, // 最小重连间隔
retryDelayMs: 3000, // 重连延迟
maxAutoRetries: 20, // 最大自动重试次数
log: true // 启用日志
});
Applicable Scenarios and Notes¶
- Compatible Versions: Verified to be compatible with
@deepseek-ai/dsh0.1.5-rc.2 and@deepseek-ai/dsh-client-connection0.1.2-rc.1. If the interface structure drifts, the plugin remains silent instead of causing the page to crash. - Limitations: It cannot detect NAT dropouts in background browser tabs (a heartbeat mechanism is required). Such issues must be handled by the host through heartbeats or dead connection scanning.
- Permissions: The plugin runs with the permissions of the current dsh process. It is recommended to review the source code and license before installation.
Conclusion¶
dsh-auto-reconnect is designed to improve connection stability for the DSH Web client in complex network environments. For more details and source code, see the: GitHub Repository.