Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

fix(sessions): enter directories when revealing them on Windows and Linux

Jasonfb2a55a39189
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ca51b66ce..aac49813e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -98,6 +98,7 @@ jobs:
- "src-tauri/src/commands/tool_*.rs"
- "src-tauri/src/commands/tool_discovery/**"
- "src-tauri/src/commands/workbuddy_account.rs"
+ - "src-tauri/src/host_open.rs"
- "src-tauri/src/lib.rs"
- "src-tauri/src/lightweight.rs"
- "src-tauri/src/macos_tray_window.rs"
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 665d326b2..c3c13d9a6 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -782,6 +782,7 @@ dependencies = [
"bytes",
"chrono",
"dirs 5.0.1",
+ "dunce",
"flate2",
"futures",
"gtk",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 1d5f10c7e..3dfcd7082 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -45,6 +45,7 @@ tauri-plugin-store = "2"
tauri-plugin-deep-link = "2"
tauri-plugin-window-state = "2"
dirs = "5.0"
+dunce = "1"
toml = "0.8"
toml_edit = "0.22"
reqwest = { version = "0.12", features = ["rustls-tls", "json", "stream", "socks"] }
diff --git a/src-tauri/src/commands/import_export.rs b/src-tauri/src/commands/import_export.rs
index e2a0ecd78..ed1b28967 100644
--- a/src-tauri/src/commands/import_export.rs
+++ b/src-tauri/src/commands/import_export.rs
@@ -239,9 +239,9 @@ pub async fn delete_backup_location(id: String) -> Result<u64, String> {
/// 在文件管理器中显示一类备份所在的目录
#[tauri::command]
-pub async fn reveal_backup_location(id: String) -> Result<bool, String> {
+pub async fn reveal_backup_location(handle: tauri::AppHandle, id: String) -> Result<bool, String> {
let dir = crate::services::backup_storage::location_dir(&id)?;
- tauri_plugin_opener::reveal_item_in_dir(&dir).map_err(|e| format!("打开文件夹失败: {e}"))?;
+ crate::host_open::reveal_path(&handle, &dir).map_err(|e| format!("打开文件夹失败: {e}"))?;
Ok(true)
}
diff --git a/src-tauri/src/commands/session_manager.rs b/src-tauri/src/commands/session_manager.rs
index 958263fc7..92c7771ac 100644
--- a/src-tauri/src/commands/session_manager.rs
+++ b/src-tauri/src/commands/session_manager.rs
@@ -170,10 +170,10 @@ pub async fn get_session_image(
/// 在文件管理器中显示某个已存在的文件或目录(决策 D3);不提供「用默认程序打开」。
#[tauri::command]
-pub async fn reveal_session_path(path: String) -> Result<bool, String> {
+pub async fn reveal_session_path(handle: tauri::AppHandle, path: String) -> Result<bool, String> {
tauri::async_runtime::spawn_blocking(move || {
let path = content::resolve_reveal_path(&path)?;
- tauri_plugin_opener::reveal_item_in_dir(&path)
+ crate::host_open::reveal_path(&handle, &path)
.map_err(|_| "无法在文件管理器中显示该路径".to_string())?;
Ok(true)
})
diff --git a/src-tauri/src/host_open.rs b/src-tauri/src/host_open.rs
index e08fdaa3d..8ada690d4 100644
--- a/src-tauri/src/host_open.rs
+++ b/src-tauri/src/host_open.rs
@@ -45,6 +45,23 @@ pub fn open_path(app: &AppHandle, path: &Path) -> Result<(), String> {
.map_err(|e| e.to_string())
}
+/// 在文件管理器中显示一个已存在的文件或目录。
+///
+/// 文件:打开所在目录并选中它。目录:Windows / Linux 直接进入目录本身
+/// (#10290;`reveal_item_in_dir` 对目录会停在上一级),macOS 仍在 Finder
+/// 里选中它——`.app` 等包本身也是目录,交给 `open` 会直接启动应用。
+pub fn reveal_path(app: &AppHandle, path: &Path) -> Result<(), String> {
+ #[cfg(not(target_os = "macos"))]
+ if path.is_dir() {
+ // canonicalize 在 Windows 上给的是 `\\?\C:\...`,还原成普通路径再交给资源管理器
+ return open_path(app, dunce::simplified(path));
+ }
+ #[cfg(target_os = "macos")]
+ let _ = app;
+
+ tauri_plugin_opener::reveal_item_in_dir(path).map_err(|e| e.to_string())
+}
+
/// 只在 Linux + AppImage 下生效的部分。
#[cfg(target_os = "linux")]
mod appimage {