Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

refactor(port): simplify port occupancy detection logic and remove socket2 dependencies

hairyfb1cca8348cf6
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 2b233026..0cadb000 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -832,7 +832,6 @@ dependencies = [
"serde_json",
"serde_yaml",
"sha2",
- "socket2",
"tar",
"tauri",
"tauri-build",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index c9a86a1d..8ca09a91 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -62,11 +62,6 @@ tokio = { version = "1", features = [ "full" ] }
semver = "1"
dunce = "1.0.5"
-# macOS/BSD 的 TCP 端口释放存在短暂滞后(close 后立即重绑会误报 EADDRINUSE),
-# 端口探测需要 SO_REUSEADDR;Windows 上该选项会掩盖真实监听者,故仅 macOS 启用。
-[target.'cfg(target_os = "macos")'.dependencies]
-socket2 = "0.6"
-
[target.'cfg(windows)'.dependencies]
rfd = "0.16"
webview2-com = "0.38"
diff --git a/src-tauri/resources/preset-plugins.json b/src-tauri/resources/preset-plugins.json
index fd3a7276..918c608f 100644
--- a/src-tauri/resources/preset-plugins.json
+++ b/src-tauri/resources/preset-plugins.json
@@ -12,7 +12,7 @@
},
{
"id": "dsh-tauri",
- "spec": "[email protected]",
+ "spec": "[email protected]",
"name": "DSH Tauri",
"internal": true,
"description": "Message bridge for the DeepSeek Harness desktop shell",
@@ -21,7 +21,7 @@
},
{
"id": "dsh-tauri-ui",
- "spec": "[email protected]",
+ "spec": "[email protected]",
"internal": true,
"name": "DSH Tauri UI",
"description": "Customized Tauri UI plugin for the DeepSeek Harness desktop shell (skeleton): registers the shell.overlay seat for the future desktop chrome",
@@ -30,13 +30,31 @@
},
{
"id": "dsh-tauri-worktree",
- "spec": "[email protected]",
+ "spec": "[email protected]",
"internal": true,
"name": "DSH Tauri Worktree",
"description": "Per-session isolated Git Worktree for the desktop shell: switch a conversation to its own isolated worktree, then check changes back into a local dsh/ branch or discard them.",
"repoUrl": "https://github.com/dsh-tauri-desk/dsh-tauri-worktree",
"recommended": true
},
+ {
+ "id": "dsh-tauri-panel",
+ "spec": "[email protected]",
+ "internal": true,
+ "name": "DSH Tauri Panel",
+ "description": "Sidebar shell for the desktop: compact logo row (32px), a panel area holding the New Session item plus third-party panel items (sidebar.panel.action slot), and the panel.protocol service (open/render/close panel content) consumed by dsh-tauri-panel-extension.",
+ "repoUrl": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/tree/main/packages/dsh-tauri-panel",
+ "recommended": true
+ },
+ {
+ "id": "dsh-tauri-panel-extension",
+ "spec": "[email protected]",
+ "internal": true,
+ "name": "DSH Tauri Panel Extension",
+ "description": "Skills and MCP management in the DeepSeek Harness desktop extension panel.",
+ "repoUrl": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/tree/main/packages/dsh-tauri-panel-extension",
+ "recommended": true
+ },
{
"id": "dshmarket",
"spec": "dshmarket",
diff --git a/src-tauri/src/service/workflow/utils.rs b/src-tauri/src/service/workflow/utils.rs
index e54f19ba..5426d70b 100644
--- a/src-tauri/src/service/workflow/utils.rs
+++ b/src-tauri/src/service/workflow/utils.rs
@@ -1,7 +1,5 @@
use std::io::{BufRead, BufReader, Read, Write};
-use std::net::{IpAddr, Ipv4Addr, SocketAddr};
-#[cfg(not(target_os = "macos"))]
-use std::net::TcpListener;
+use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener};
use std::path::PathBuf;
use std::sync::{Mutex, OnceLock};
use std::thread;
@@ -85,42 +83,11 @@ pub async fn is_dsh_running(port: u16) -> bool {
check_status.await.unwrap_or(false)
}
-/// 检查指定端口是否被占用(通过尝试绑定来判断)
+/// 检查指定端口是否被占用(通过尝试连接来判断)
pub fn is_port_in_use(port: u16) -> bool {
// 以实际绑定结果判断,能够识别“已绑定但尚未 listen”的占用状态。
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port);
- bind_probe(addr).is_err()
-}
-
-/// 端口占用探测:能成功绑定即视为空闲。平台差异见下方 macOS 分支注释。
-#[cfg(not(target_os = "macos"))]
-fn bind_probe(addr: SocketAddr) -> std::io::Result<()> {
- TcpListener::bind(addr).map(|_| ())
-}
-
-/// macOS/BSD 上刚 close 的监听 socket 会留下一个极短的“端口暂不可复用”窗口:
-/// 不带 SO_REUSEADDR 时紧随其后的 bind 会误报 EADDRINUSE(典型表现为服务重启
-/// 偶发 “address already in use”)。本函数每次探测都是 bind→drop,探测自身也会
-/// 制造这个窗口——`wait_for_port_release` 轮询到“空闲”返回后立刻再探测就可能
-/// 踩中,导致占用的误判(CI 偶发的端口拉高/测试失败)。
-///
-/// 因此探测前先设 SO_REUSEADDR:
-/// - 真实占用(残留 dsh 等仍 listen 在同一端口)依然 bind 失败 → 判为占用;
-/// - 上一次探测留下的 linger 不再误判为占用。
-/// SO_REUSEADDR 只放宽 TIME_WAIT/linger 状态的复用,并不会允许两个 socket 同时
-/// listen 同一地址(那是 SO_REUSEPORT 的语义),因此不会掩盖真实监听者。
-/// Windows 上 SO_REUSEADDR 语义不同(可强制覆盖既有监听者),会掩盖真实占用,
-/// 故只对 macOS 启用。
-#[cfg(target_os = "macos")]
-fn bind_probe(addr: SocketAddr) -> std::io::Result<()> {
- let socket = socket2::Socket::new(
- socket2::Domain::IPV4,
- socket2::Type::STREAM,
- Some(socket2::Protocol::TCP),
- )?;
- socket.set_reuse_address(true)?;
- socket.bind(&socket2::SockAddr::from(addr))?;
- Ok(())
+ TcpListener::bind(addr).is_err()
}
/// 在独立线程中读取子进程的输出,同时写入日志文件