Skip to content

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

fix(startup): preserve installer errors and reject incomplete plugin recovery (#992)

SkanderBot44122be58403
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b30e4f70..61fc9896 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -288,11 +288,13 @@ jobs:
# 与下面的「Check startup regression stability」同形:`for` 必须以 `done` 收尾,
# 且必须显式声明 working-directory —— 否则 cargo 会在仓库根目录执行、
# 找不到 workspace(Cargo.toml 在 src-tauri/ 下)。
- - name: Check plugin update cache stability
+ - name: Check plugin recovery and update cache stability
shell: bash
run: |
for iteration in 1 2 3 4 5; do
cargo test --all-features --locked service::plugin::update::tests:: -- --test-threads=1 || exit 1
+ cargo test --all-features --locked service::plugin::internal:: -- --test-threads=1 || exit 1
+ cargo test --all-features --locked service::plugin::install::diagnose:: -- --test-threads=1 || exit 1
done
working-directory: src-tauri
diff --git a/src-tauri/src/service/plugin/install/diagnose.rs b/src-tauri/src/service/plugin/install/diagnose.rs
index d86e0af3..c0ebdaec 100644
--- a/src-tauri/src/service/plugin/install/diagnose.rs
+++ b/src-tauri/src/service/plugin/install/diagnose.rs
@@ -49,7 +49,22 @@ pub(super) fn pick_error_message(output: &str, hint: Option<&str>) -> String {
let trimmed = trimmed.trim();
(!trimmed.is_empty()).then(|| trimmed.to_string())
})
- .filter(|line| ERROR_MARKERS.iter().any(|marker| line.contains(marker)))
+ .filter(|line| {
+ ERROR_MARKERS.iter().any(|marker| line.contains(marker))
+ || line.split_whitespace().any(|word| {
+ let code = word
+ .strip_prefix('[')
+ .and_then(|word| word.strip_suffix(']'))
+ .or_else(|| word.strip_suffix(':'));
+ code.is_some_and(|code| {
+ code.len() > 1
+ && code.starts_with('E')
+ && code.bytes().all(|byte| {
+ byte.is_ascii_uppercase() || byte.is_ascii_digit() || byte == b'_'
+ })
+ })
+ })
+ })
.take(8)
.collect();
let base = if cleaned.is_empty() {
@@ -370,6 +385,34 @@ fn contains_error_code(output: &str, code: &str) -> bool {
mod tests {
use super::*;
+ #[test]
+ fn pick_error_message_preserves_filesystem_cause_before_cli_summary() {
+ for cause in [
+ "[EISDIR] EISDIR: illegal operation on a directory, readlink 'F:/apps/.dsh/profiles/tauri/node_modules/dsh-tauri'",
+ "EPERM: operation not permitted, unlink 'C:/apps/plugin/package.json'",
+ "[ENOTEMPTY] ENOTEMPTY: directory not empty, rmdir 'C:/apps/plugin'",
+ "EACCES: permission denied, open '/tmp/profile/package.json'",
+ "ENOSPC: no space left on device, write",
+ ] {
+ let output = format!(
+ "Progress: resolved 1, reused 0\n\u{1b}[31m{cause}\u{1b}[0m\ndsh: plugin command failed; diagnostics: C:/profile/.plugin-manager/logs/operation-test/pnpm.log\n"
+ );
+ assert_eq!(
+ pick_error_message(&output, None),
+ format!("{cause}\ndsh: plugin command failed; diagnostics: C:/profile/.plugin-manager/logs/operation-test/pnpm.log")
+ );
+ }
+ }
+
+ #[test]
+ fn pick_error_message_does_not_promote_errno_in_progress_paths() {
+ let output = "Progress: unpacking C:/EISDIR/cache\nResolved [email protected]\ndsh: plugin command failed; diagnostics: C:/profile/pnpm.log\n";
+ assert_eq!(
+ pick_error_message(output, None),
+ "dsh: plugin command failed; diagnostics: C:/profile/pnpm.log"
+ );
+ }
+
#[test]
fn diagnostic_suffix_preserves_non_allowbuilds_failure() {
assert_eq!(diagnostic_suffix(""), "");
diff --git a/src-tauri/src/service/plugin/internal/mod.rs b/src-tauri/src/service/plugin/internal/mod.rs
index 9fd2f2db..04bcff95 100644
--- a/src-tauri/src/service/plugin/internal/mod.rs
+++ b/src-tauri/src/service/plugin/internal/mod.rs
@@ -900,12 +900,11 @@ async fn ensure_inner(
// 收尾回读清单,缺项就用同一套物化路径写回(幂等)——否则 `bundle_ok` 每轮判
// 需重装、每轮又被打回原形。
if let Some(missing) = presets_missing_from_manifest(&profile, &need) {
- match materialize_internal_links(app_handle, &profile, &need) {
- Ok(()) => log::warn!(
- "INTERNAL_PLUGIN_MANIFEST_RECOVERED: re-registered internal plugins dropped by install: {missing:?}"
- ),
- Err(error) => log::error!("INTERNAL_PLUGIN_MANIFEST_RECOVER_FAILED: {error}"),
- }
+ materialize_internal_links(app_handle, &profile, &need)
+ .map_err(|error| format!("INTERNAL_PLUGIN_MANIFEST_RECOVER_FAILED: {error}"))?;
+ log::warn!(
+ "INTERNAL_PLUGIN_MANIFEST_RECOVERED: re-registered internal plugins dropped by install: {missing:?}"
+ );
}
Ok(())
@@ -917,11 +916,15 @@ fn presets_missing_from_manifest(
profile: &Path,
need: &[(String, String, PathBuf)],
) -> Option<Vec<String>> {
- let raw = std::fs::read_to_string(profile.join("package.json")).ok()?;
- let manifest: serde_json::Value = serde_json::from_str(&raw).ok()?;
- let dependencies = manifest.get("dependencies");
+ let manifest = std::fs::read_to_string(profile.join("package.json"))
+ .ok()
+ .and_then(|raw| serde_json::from_str::<serde_json::Value>(&raw).ok());
+ let dependencies = manifest
+ .as_ref()
+ .and_then(|value| value.get("dependencies"));
let bundles = manifest
- .pointer("/dsh/profile/bundles")
+ .as_ref()
+ .and_then(|value| value.pointer("/dsh/profile/bundles"))
.and_then(|value| value.as_array());
let missing: Vec<String> = need
.iter()
@@ -1145,6 +1148,54 @@ fn is_legacy_profile_fallback_target(target: &Path) -> bool {
mod tests {
use super::*;
+ #[test]
+ fn post_install_manifest_check_rejects_missing_or_unreadable_manifest() {
+ let root = tempfile::tempdir().unwrap();
+ let need = need_entries(&["dsh-tauri", "dsh-tauri-ui"]);
+ let expected = Some(vec!["dsh-tauri".to_string(), "dsh-tauri-ui".to_string()]);
+ assert_eq!(presets_missing_from_manifest(root.path(), &need), expected);
+ std::fs::create_dir(root.path().join("package.json")).unwrap();
+ assert_eq!(presets_missing_from_manifest(root.path(), &need), expected);
+ }
+
+ #[test]
+ fn post_install_manifest_check_rejects_truncated_manifest() {
+ let root = tempfile::tempdir().unwrap();
+ std::fs::write(
+ root.path().join("package.json"),
+ br#"{"dependencies":{"dsh-tauri":"#,
+ )
+ .unwrap();
+ assert_eq!(
+ presets_missing_from_manifest(root.path(), &need_entries(&["dsh-tauri"])),
+ Some(vec!["dsh-tauri".to_string()])
+ );
+ }
+
+ #[test]
+ fn post_install_manifest_check_requires_dependency_and_bundle_registration() {
+ let root = tempfile::tempdir().unwrap();
+ std::fs::write(root.path().join("package.json"), serde_json::json!({
+ "dependencies": {"dsh-tauri": "link:/resources/dsh-tauri", "dsh-tauri-ui": "link:/resources/dsh-tauri-ui"},
+ "dsh": {"profile": {"bundles": ["dsh-tauri", "dsh-tauri-pet", "community-plugin"]}}
+ }).to_string()).unwrap();
+ assert_eq!(
+ presets_missing_from_manifest(
+ root.path(),
+ &need_entries(&["dsh-tauri", "dsh-tauri-ui", "dsh-tauri-pet"])
+ ),
+ Some(vec![
+ "dsh-tauri-ui".to_string(),
+ "dsh-tauri-pet".to_string()
+ ])
+ );
+ assert_eq!(
+ presets_missing_from_manifest(root.path(), &need_entries(&["dsh-tauri"])),
+ None
+ );
+ assert_eq!(presets_missing_from_manifest(root.path(), &[]), None);
+ }
+
/// 构造本轮待装列表 `(id, 包名, 入口)`:入口与 `ensure_inner` 一致地落在
/// `<profile>/node_modules/<包名>`,用报告里的真实 profile 路径。
fn need_entries(names: &[&str]) -> Vec<(String, String, PathBuf)> {