DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(plugin): 以 cordis.patch.yml 作为唯一的插件禁用状态 (#1004)
Mao Mr4791c9964400
diff --git a/src-tauri/src/bridge/plugin.rs b/src-tauri/src/bridge/plugin.rsindex c2559d50..8ecdcd2a 100644--- a/src-tauri/src/bridge/plugin.rs+++ b/src-tauri/src/bridge/plugin.rs@@ -286,9 +286,9 @@ pub fn recover_plugin(app_handle: AppHandle, id: String) -> Result<(), String> {Ok(())}-/// 禁用单个已安装插件:从 profile 的 `dsh.profile.bundles` 移除(代码完全不加载),-/// 并写入 profile 的独立禁用清单。与卸载不同,禁用保留 node_modules 内的包体,-/// 启用时无需重新下载。+/// 禁用单个已安装插件:在 profile 的 `cordis.patch.yml` 写入 `disabled: true` 覆盖+/// (与官方 Plugins 页 / dshmarket 同一处状态)。与卸载不同,禁用保留 node_modules+/// 内的包体与 `dsh.profile.bundles` 选择,启用时无需重新下载。#[tauri::command]pub fn disable_dsh_plugin(app_handle: AppHandle, id: String) -> Result<(), String> {plugin::disable(&app_handle, &id)?;@@ -296,19 +296,13 @@ pub fn disable_dsh_plugin(app_handle: AppHandle, id: String) -> Result<(), StrinOk(())}-/// 启用单个已禁用的插件:加回 `dsh.profile.bundles` 并从独立禁用清单移除。+/// 启用单个已禁用的插件:摘除 patch 里该插件的禁用覆盖(其余配置保留)。///-/// 若插件同时被 profile 的 `cordis.patch.yml` 配置覆盖禁用(`disabled: true`,-/// 优先级高于桌面禁用清单),必须显式传 `clear_config_override=true`(前端-/// 弹窗确认后)才会移除该覆盖;否则返回 `ENABLE_CONFIG_OVERRIDE`,避免-/// 「声称启用成功、运行期却仍被配置禁用」的虚假成功(issue #399)。+/// 未能摘除时会返回 `ENABLE_NOT_DISABLED`,避免「声称启用成功、运行期却仍被禁用」+/// 的虚假成功(issue #399)。#[tauri::command]-pub fn enable_dsh_plugin(- app_handle: AppHandle,- id: String,- clear_config_override: Option<bool>,-) -> Result<(), String> {- plugin::enable(&app_handle, &id, clear_config_override.unwrap_or(false))?;+pub fn enable_dsh_plugin(app_handle: AppHandle, id: String) -> Result<(), String> {+ plugin::enable(&app_handle, &id)?;plugin::watch::force_emit(&app_handle);Ok(())}diff --git a/src-tauri/src/service/plugin/disable.rs b/src-tauri/src/service/plugin/disable.rsindex f7da93e6..a0fa2eae 100644--- a/src-tauri/src/service/plugin/disable.rs+++ b/src-tauri/src/service/plugin/disable.rs@@ -1,71 +1,32 @@-//! 插件禁用/启用:从 profile 的 `dsh.profile.bundles` 移除(代码完全不加载),-//! 并写入 profile 的独立禁用清单。与卸载不同,禁用保留 node_modules 内的包体,-//! 启用时无需重新下载。+//! 插件禁用/启用:改写 profile 的 `cordis.patch.yml` 顶层覆盖项的 `disabled` 字段。//!-//! 机制遵循 ADR-0001:禁用 = 从加载列表移除 + 记入独立禁用清单;启用 = 精确逆操作。+//! 与官方 Plugins 页 / dshmarket 共用同一处状态(patch 层),桌面壳不再维护第二份+//! 记录。禁用保留 node_modules 内的包体与 `dsh.profile.bundles` 选择,启用无需重新+//! 下载,也不动组合包开关。-use std::collections::{HashMap, HashSet};+use std::collections::HashSet;use std::fs;-use std::path::{Path, PathBuf};-use std::time::SystemTime;+use std::path::Path;-use serde::{Deserialize, Serialize};use tauri::AppHandle;use crate::service::fs_guard;use crate::service::plugin::installed::profile_dir;-use crate::service::plugin::recovery::{is_core_package, patch_entry_targets, remove_bundle};+use crate::service::plugin::recovery::{is_core_package, patch_entry_targets};use crate::service::plugin::{process, watch};-/// 单条禁用记录(序列化为 camelCase 给前端/磁盘)。-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-#[serde(rename_all = "camelCase")]-pub struct DisabledEntry {- /// 禁用时间(unix 秒级时间戳字符串)。- pub disabled_at: String,- /// 禁用来源:当前均为 "user"(用户主动操作)。- pub reason: String,-}--/// 禁用清单在 profile 目录下的路径。-fn disabled_path(profile: &Path) -> PathBuf {- profile.join("disabled-plugins.json")-}--/// 读取禁用清单(缺失/损坏按空处理)。-pub(crate) fn load_disabled(profile: &Path) -> HashMap<String, DisabledEntry> {- let Ok(content) = fs::read_to_string(disabled_path(profile)) else {- return HashMap::new();- };- serde_json::from_str(&content).unwrap_or_default()-}+/// profile 层的 patch 覆盖文件。+const PATCH_FILE: &str = "cordis.patch.yml";+/// 插件开关在覆盖项里的字段名(官方插件页/dshmarket 同款)。+const DISABLED_KEY: &str = "disabled";-/// 持久化禁用清单(pretty JSON + 尾部换行)。-pub(crate) fn save_disabled(- profile: &Path,- map: &HashMap<String, DisabledEntry>,-) -> Result<(), String> {- let path = disabled_path(profile);- if let Some(dir) = path.parent() {- fs::create_dir_all(dir).map_err(|e| format!("DISABLED_DIR_CREATE_FAILED: {e}"))?;- }- let json =- serde_json::to_string_pretty(map).map_err(|e| format!("DISABLED_RENDER_FAILED: {e}"))?;- fs::write(&path, format!("{json}\n")).map_err(|e| format!("DISABLED_WRITE_FAILED: {e}"))-}--/// 读取 profile 的 `cordis.patch.yml`,返回「配置层显式禁用」条目的目标集合。-///-/// 配置覆盖禁用 = 顶层数组条目带真值 `disabled` 字段(`disabled: true` 等)。-/// 与桌面禁用清单(`disabled-plugins.json`)独立:patch 覆盖优先级更高,-/// 运行期同样不加载该插件。匹配口径与 `recovery::uninstall::patch_entry_targets`-/// 一致——把条目的 `id` 与任意字符串键/值都收进集合,由调用方按「包名或-/// package.json name 命中」判断,兼容 loader 入口 id 与 npm 包名不一致的别名场景。+/// 返回 patch 中「显式禁用」条目的目标名集合。///-/// 文件缺失/无法解析为顶层数组时按空集处理(与 `load_disabled` 一致,-/// 不阻断插件列表解析)。+/// 匹配口径与 `recovery::patch_entry_targets` 一致:把条目的 `id` 与任意字符串键/值+/// 都收进集合,兼容 loader 入口 id 与 npm 包名不一致的别名场景。文件缺失或无法解析+/// 为顶层数组时按空集处理。pub(crate) fn load_patch_disabled(profile: &Path) -> HashSet<String> {- let Ok(content) = fs::read_to_string(profile.join("cordis.patch.yml")) else {+ let Ok(content) = fs::read_to_string(profile.join(PATCH_FILE)) else {return HashSet::new();};let Ok(doc) = serde_yaml::from_str::<serde_yaml::Value>(&content) else {@@ -94,11 +55,9 @@ pub(crate) fn load_patch_disabled(profile: &Path) -> HashSet<String> {targets}-/// patch 顶层条目是否带「禁用」语义(`disabled` 字段为真值)。-///-/// 兼容 YAML 常见真值写法:布尔 `true`、非零数字、字符串 true/1/yes/on。+/// 覆盖项是否带「禁用」语义:兼容布尔 `true`、非零数字、字符串 true/1/yes/on。fn patch_entry_disabled(map: &serde_yaml::Mapping) -> bool {- let Some(value) = map.get(serde_yaml::Value::String("disabled".to_string())) else {+ let Some(value) = map.get(serde_yaml::Value::String(DISABLED_KEY.to_string())) else {return false;};match value {@@ -115,8 +74,6 @@ fn patch_entry_disabled(map: &serde_yaml::Mapping) -> bool {}/// 目标插件的匹配候选名:npm 包名(依赖键)+ 包内 package.json 的 `name` 字段。-///-/// 覆盖「依赖键即展示名」与「loader 入口 id 用包内 name」两种形态。fn plugin_target_names(profile: &Path, id: &str) -> Vec<String> {let mut names = vec![id.to_string()];if let Ok(content) =@@ -131,7 +88,7 @@ fn plugin_target_names(profile: &Path, id: &str) -> Vec<String> {names}-/// 插件是否被 profile 的 `cordis.patch.yml` 配置覆盖禁用。+/// 插件是否被 profile 的 patch 覆盖禁用。pub(crate) fn has_patch_disable(profile: &Path, id: &str) -> bool {let names = plugin_target_names(profile, id);load_patch_disabled(profile)@@ -139,17 +96,65 @@ pub(crate) fn has_patch_disable(profile: &Path, id: &str) -> bool {.any(|target| names.iter().any(|n| n == target))}-/// 从 `cordis.patch.yml` 移除目标插件的显式禁用覆盖,其余配置原样保留。+/// 在 patch 里为目标插件写入 `disabled: true`。///-/// 精确语义(对应 issue #399「不删除无关配置」):-/// - 纯禁用条目(仅 `id` + `disabled`)→ 整条移除;-/// - 带其它配置的条目 → 仅摘除 `disabled` 键,其余键原样保留;-/// - 其它插件的条目一律不动。+/// 与官方插件开关同款语义:命中最后一条匹配条目就改它的 `disabled`(条目里其它配置+/// 原样保留),没有匹配条目则追加 `{id, disabled: true}`。已是禁用态时返回+/// `Ok(false)` 且不写盘。+pub(crate) fn add_patch_disable(profile: &Path, id: &str) -> Result<bool, String> {+ let path = profile.join(PATCH_FILE);+ let content = fs::read_to_string(&path).unwrap_or_default();+ let mut entries = match content.trim() {+ "" => Vec::new(),+ raw => match serde_yaml::from_str::<serde_yaml::Value>(raw)+ .map_err(|e| format!("DISABLE_PATCH_PARSE_FAILED: {e}"))?+ {+ serde_yaml::Value::Sequence(seq) => seq,+ _ => Vec::new(),+ },+ };+ let names = plugin_target_names(profile, id);+ let key = serde_yaml::Value::String(DISABLED_KEY.to_string());+ let mut hit: Option<&mut serde_yaml::Mapping> = None;+ for entry in entries.iter_mut().rev() {+ if !names.iter().any(|name| patch_entry_targets(entry, name)) {+ continue;+ }+ if let serde_yaml::Value::Mapping(map) = entry {+ hit = Some(map);+ break;+ }+ }+ match hit {+ Some(map) => {+ if patch_entry_disabled(map) {+ return Ok(false);+ }+ map.insert(key, serde_yaml::Value::Bool(true));+ }+ None => {+ let mut map = serde_yaml::Mapping::new();+ map.insert(+ serde_yaml::Value::String("id".to_string()),+ serde_yaml::Value::String(id.to_string()),+ );+ map.insert(key, serde_yaml::Value::Bool(true));+ entries.push(serde_yaml::Value::Mapping(map));+ }+ }+ let rendered = serde_yaml::to_string(&serde_yaml::Value::Sequence(entries))+ .map_err(|e| format!("DISABLE_PATCH_RENDER_FAILED: {e}"))?;+ fs::write(&path, rendered).map_err(|e| format!("DISABLE_PATCH_WRITE_FAILED: {e}"))?;+ log::info!("Disabled plugin {id} via cordis.patch.yml override");+ Ok(true)+}++/// 从 patch 移除目标插件的显式禁用覆盖,其余配置原样保留(issue #399):+/// 纯禁用条目(仅 `id` + `disabled`)整条移除,带其它配置的条目只摘 `disabled` 键。///-/// 幂等:无 patch 文件 / 无法解析 / 无目标禁用条目时返回 `Ok(false)` 且不写盘;-/// 实际修改时返回 `Ok(true)`。+/// 幂等:无 patch 文件 / 无法解析 / 无目标禁用条目时返回 `Ok(false)` 且不写盘。pub(crate) fn strip_patch_disable(profile: &Path, id: &str) -> Result<bool, String> {- let path = profile.join("cordis.patch.yml");+ let path = profile.join(PATCH_FILE);let Ok(content) = fs::read_to_string(&path) else {return Ok(false);};@@ -172,9 +177,7 @@ pub(crate) fn strip_patch_disable(profile: &Path, id: &str) -> Result<bool, Stricontinue;}changed = true;- map.remove(serde_yaml::Value::String("disabled".to_string()));- // 摘除 disabled 后仅剩 id(或为空)→ 纯禁用条目,整条丢弃;- // 还有其它键 → 保留该条目的其余配置。+ map.remove(serde_yaml::Value::String(DISABLED_KEY.to_string()));let keeps_other_config = map.iter().any(|(k, _)| k.as_str() != Some("id"));if keeps_other_config {kept.push(serde_yaml::Value::Mapping(map));@@ -190,24 +193,6 @@ pub(crate) fn strip_patch_disable(profile: &Path, id: &str) -> Result<bool, StriOk(true)}-/// 把插件加回 `dsh.profile.bundles`(若已存在则不重复添加)。-/// 返回是否实际新增了条目。-fn add_to_bundles(manifest: &mut serde_json::Value, id: &str) -> bool {- let Some(bundles) = manifest- .get_mut("dsh")- .and_then(|d| d.get_mut("profile"))- .and_then(|p| p.get_mut("bundles"))- .and_then(|b| b.as_array_mut())- else {- return false;- };- if bundles.iter().any(|b| b.as_str() == Some(id)) {- return false;- }- bundles.push(serde_json::Value::String(id.to_string()));- true-}-/// 检查插件是否已安装(dependencies 中存在)。fn is_in_dependencies(manifest: &serde_json::Value, id: &str) -> bool {manifest@@ -217,175 +202,50 @@ fn is_in_dependencies(manifest: &serde_json::Value, id: &str) -> bool {.unwrap_or(false)}-fn now_seconds_string() -> String {- SystemTime::now()- .duration_since(SystemTime::UNIX_EPOCH)- .map(|d| d.as_secs().to_string())- .unwrap_or_default()-}--pub(crate) fn preserve_disabled_bundles(profile: &Path) -> Result<(), String> {- let disabled = load_disabled(profile);- if disabled.is_empty() {- return Ok(());- }- let path = profile.join("package.json");- let raw = fs::read_to_string(&path).map_err(|e| format!("DISABLE_READ_MANIFEST: {e}"))?;- let mut manifest: serde_json::Value =- serde_json::from_str(&raw).map_err(|e| format!("DISABLE_PARSE_MANIFEST: {e}"))?;- let before = manifest.clone();- for id in disabled.keys() {- remove_bundle(&mut manifest, id);- }- if manifest != before {- let rendered = serde_json::to_string_pretty(&manifest)- .map_err(|e| format!("DISABLE_RENDER_MANIFEST: {e}"))?;- fs::write(&path, format!("{rendered}\n"))- .map_err(|e| format!("DISABLE_WRITE_MANIFEST: {e}"))?;- }- Ok(())-}--/// 回滚禁用清单到操作前的状态。-///-/// 当 manifest 写入失败时,把已加入禁用清单的条目移除,使两个持久化文件-/// 恢复一致(插件仍在 bundles 中,禁用清单无记录),避免留下-/// 「已从 bundles 移除但未记入禁用清单」的不可恢复状态。-fn rollback_disable(profile: &Path, id: &str) {- let mut map = load_disabled(profile);- map.remove(id);- // 回滚写入也失败时,只能静默——此时清单多一条目但插件仍在 bundles,- // 下次禁用会覆盖该条目,不会阻塞用户操作。- let _ = save_disabled(profile, &map);+/// 读取并解析 profile 的 package.json。+fn read_manifest(profile: &Path, prefix: &str) -> Result<serde_json::Value, String> {+ let content = fs::read_to_string(profile.join("package.json"))+ .map_err(|e| format!("{prefix}_READ_MANIFEST: {e}"))?;+ serde_json::from_str(&content).map_err(|e| format!("{prefix}_PARSE_MANIFEST: {e}"))}/// 禁用插件的纯逻辑(不依赖 AppHandle,便于单元测试)。///-/// 1. `fs_guard::validate_id(id)`(路径穿越防护)-/// 2. 拒绝官方/核心包-/// 3. 读取 profile package.json-/// 4. 校验插件已安装(dependencies 中存在)-/// 5. 先写入禁用清单(加入条目)-/// 6. 仅从 bundles 移除(不动 dependencies)并写回 manifest-///-/// 写入顺序保证:若步骤 6 失败,通过回滚步骤 5 使两文件恢复一致,-/// 避免插件从 bundles 移除却未记入禁用清单(否则启用会返回-/// `ENABLE_NOT_DISABLED`,用户无法通过正常流程恢复)。+/// 只写 patch 覆盖:不再改 `dsh.profile.bundles`(组合包开关归官方插件页),也不写任何+/// 桌面侧清单。pub(crate) fn disable_plugin_at(profile: &Path, id: &str) -> Result<(), String> {- // 先做官方/核心包语义校验(优先级高于字符集校验):官方包 id 含 `/`,- // 必须先于 validate_id 拦截,否则会被字符集校验误判为 INVALID_ID。+ // 官方/核心包 id 含 `/`,必须先于 validate_id 拦截,否则会被字符集校验误判。if is_core_package(id) {return Err(format!("DISABLE_INTERNAL_PLUGIN: refusing to disable internal/official plugin {id}"));}fs_guard::validate_id(id)?;- let manifest_path = profile.join("package.json");- let content =- fs::read_to_string(&manifest_path).map_err(|e| format!("DISABLE_READ_MANIFEST: {e}"))?;- let mut manifest: serde_json::Value =- serde_json::from_str(&content).map_err(|e| format!("DISABLE_PARSE_MANIFEST: {e}"))?;+ let manifest = read_manifest(profile, "DISABLE")?;if !is_in_dependencies(&manifest, id) {return Err(format!("DISABLE_NOT_INSTALLED: plugin {id} is not installed"));}- // 先写禁用清单,确保 manifest 写入失败时可回滚该条目。- let mut map = load_disabled(profile);- map.insert(- id.to_string(),- DisabledEntry {- disabled_at: now_seconds_string(),- reason: "user".to_string(),- },- );- save_disabled(profile, &map)?;- remove_bundle(&mut manifest, id);- let rendered = serde_json::to_string_pretty(&manifest)- .map_err(|e| format!("DISABLE_RENDER_MANIFEST: {e}"))?;- if let Err(e) = fs::write(&manifest_path, format!("{rendered}\n")) {- rollback_disable(profile, id);- return Err(format!("DISABLE_WRITE_MANIFEST: {e}"));- }+ add_patch_disable(profile, id)?;Ok(())}-/// 回滚启用前的禁用清单状态。-///-/// 当 manifest 写入失败时,把已移除的禁用条目加回,使两个持久化文件-/// 恢复一致(插件仍在禁用清单中,bundles 未记录),避免留下-/// 「已加回 bundles 但禁用清单仍缺条目」的不可恢复状态。-fn rollback_enable(profile: &Path, id: &str) {- let mut map = load_disabled(profile);- map.entry(id.to_string()).or_insert_with(|| DisabledEntry {- disabled_at: now_seconds_string(),- reason: "user".to_string(),- });- let _ = save_disabled(profile, &map);-}--/// 启用插件的纯逻辑(不依赖 AppHandle,便于单元测试)。-///-/// 1. `fs_guard::validate_id(id)`-/// 2. 读取 manifest-/// 3. 校验插件仍安装-/// 4. 校验插件处于禁用态:桌面禁用清单或 `cordis.patch.yml` 配置覆盖(二选一)-/// 5. 配置覆盖禁用时,**必须**显式传 `clear_config_override=true`(前端已确认)-/// 才会移除该覆盖;否则返回 `ENABLE_CONFIG_OVERRIDE`——避免「声称启用成功、-/// 运行期却仍被更高优先级配置覆盖禁用」的虚假成功(issue #399)-/// 6. 从桌面禁用清单移除条目-/// 7. 加回 bundles 并写回 manifest-///-/// 写入顺序保证:若最后一步失败,通过回滚使持久化文件恢复一致,-/// 避免插件加回 bundles 后禁用清单缺条目(否则再次启用会返回-/// `ENABLE_NOT_DISABLED`,用户无法通过正常流程恢复)。-pub(crate) fn enable_plugin_at(- profile: &Path,- id: &str,- clear_config_override: bool,-) -> Result<(), String> {+/// 启用插件的纯逻辑(不依赖 AppHandle,便于单元测试):仅摘除 patch 里的禁用覆盖。+pub(crate) fn enable_plugin_at(profile: &Path, id: &str) -> Result<(), String> {fs_guard::validate_id(id)?;- let manifest_path = profile.join("package.json");- let content =- fs::read_to_string(&manifest_path).map_err(|e| format!("ENABLE_READ_MANIFEST: {e}"))?;- let mut manifest: serde_json::Value =- serde_json::from_str(&content).map_err(|e| format!("ENABLE_PARSE_MANIFEST: {e}"))?;+ let manifest = read_manifest(profile, "ENABLE")?;if !is_in_dependencies(&manifest, id) {return Err(format!("ENABLE_NOT_INSTALLED: plugin {id} is not installed"));}- let mut map = load_disabled(profile);- let desktop_disabled = map.contains_key(id);- let config_disabled = has_patch_disable(profile, id);- if !desktop_disabled && !config_disabled {+ if !has_patch_disable(profile, id) {return Err(format!(- "ENABLE_NOT_DISABLED: plugin {id} is not in the disabled list"+ "ENABLE_NOT_DISABLED: plugin {id} has no disable override in cordis.patch.yml"));}- // 存在配置覆盖但未显式确认:拒绝并给出来源指引,让前端提示用户查看- // `cordis.patch.yml`;绝不静默绕过高优先级覆盖。- if config_disabled && !clear_config_override {- return Err(format!(- "ENABLE_CONFIG_OVERRIDE: plugin {id} is disabled by the cordis.patch.yml config override; confirm removing the override to enable"- ));- }- // 确认后先移除配置覆盖(幂等,只摘该插件的禁用条目,其余配置保留),- // 再清理桌面禁用清单,最后写回 manifest——任一步失败都保持可恢复状态。- if config_disabled {- strip_patch_disable(profile, id)?;- }- if desktop_disabled {- map.remove(id);- save_disabled(profile, &map)?;- }- add_to_bundles(&mut manifest, id);- let rendered = serde_json::to_string_pretty(&manifest)- .map_err(|e| format!("ENABLE_RENDER_MANIFEST: {e}"))?;- if let Err(e) = fs::write(&manifest_path, format!("{rendered}\n")) {- rollback_enable(profile, id);- return Err(format!("ENABLE_WRITE_MANIFEST: {e}"));- }+ strip_patch_disable(profile, id)?;Ok(())}@@ -400,13 +260,10 @@ pub fn disable(app_handle: &AppHandle, id: &str) -> Result<(), String> {}/// 启用插件(AppHandle 入口):获取 profile 目录 → 持有操作锁 → 执行纯逻辑 → 推送变更。-///-/// `clear_config_override`:插件被 `cordis.patch.yml` 配置覆盖禁用时,是否-/// 移除该覆盖(需用户在前端明确确认后才为 true)。-pub fn enable(app_handle: &AppHandle, id: &str, clear_config_override: bool) -> Result<(), String> {+pub fn enable(app_handle: &AppHandle, id: &str) -> Result<(), String> {let profile = profile_dir(app_handle);let _guard = tauri::async_runtime::block_on(process::acquire_operation_lock());- let result = enable_plugin_at(&profile, id, clear_config_override);+ let result = enable_plugin_at(&profile, id);drop(_guard);watch::force_emit(app_handle);result@@ -415,8 +272,9 @@ pub fn enable(app_handle: &AppHandle, id: &str, clear_config_override: bool) ->#[cfg(test)]mod tests {use super::*;+ use std::path::PathBuf;- /// 构造临时 profile 目录并写入 package.json 清单。+ /// 构造临时 profile 目录并写入 package.json 清单(不含 patch 文件)。fn build_profile(test_name: &str, id: &str) -> PathBuf {let dir = std::env::temp_dir().join(format!("dsh-disable-test-{}-{}-{}",@@ -444,200 +302,141 @@ mod tests {dir}- fn read_manifest(profile: &Path) -> serde_json::Value {- let content = fs::read_to_string(profile.join("package.json")).unwrap();- serde_json::from_str(&content).unwrap()+ fn read_patch(profile: &Path) -> String {+ fs::read_to_string(profile.join(PATCH_FILE)).unwrap_or_default()+ }++ fn write_patch(profile: &Path, content: &str) {+ fs::write(profile.join(PATCH_FILE), content).unwrap();}#[test]- fn preserve_disabled_bundles_keeps_builtin_disabled_after_install() {- let profile = build_profile("preserve-builtin", "builtin");- let mut manifest = read_manifest(&profile);- manifest["dependencies"]["dsh-tauri-pet"] = serde_json::json!("link:/bundled/pet");- manifest["dsh"]["profile"]["bundles"]- .as_array_mut()- .unwrap()- .push(serde_json::json!("dsh-tauri-pet"));- fs::write(- profile.join("package.json"),- serde_json::to_string(&manifest).unwrap(),- )- .unwrap();- disable_plugin_at(&profile, "dsh-tauri-pet").unwrap();- fs::write(- profile.join("package.json"),- serde_json::to_string(&manifest).unwrap(),- )- .unwrap();- preserve_disabled_bundles(&profile).unwrap();- let preserved = read_manifest(&profile);- assert_eq!(preserved["dependencies"], manifest["dependencies"]);+ fn disable_writes_patch_override_and_keeps_bundles() {+ let profile = build_profile("write-patch", "a");+ let before = fs::read_to_string(profile.join("package.json")).unwrap();+ disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();++ assert!(has_patch_disable(&profile, "dsh-better-sidebar"));+ assert!(read_patch(&profile).contains("disabled: true"));+ // 组合包选择与依赖一律不动assert_eq!(- preserved["dsh"]["profile"]["bundles"],- serde_json::json!(["dsh-better-sidebar", "dshmarket", "@deepseek-ai/dsh-base"])+ fs::read_to_string(profile.join("package.json")).unwrap(),+ before);- assert!(load_disabled(&profile).contains_key("dsh-tauri-pet"));- enable_plugin_at(&profile, "dsh-tauri-pet", false).unwrap();- assert!(!load_disabled(&profile).contains_key("dsh-tauri-pet"));- assert!(read_manifest(&profile)["dsh"]["profile"]["bundles"]- .as_array()- .unwrap()- .contains(&serde_json::json!("dsh-tauri-pet")));- fs::remove_dir_all(profile).unwrap();++ // 重复禁用:幂等,第二次不再写盘+ assert!(!add_patch_disable(&profile, "dsh-better-sidebar").unwrap());++ let _ = fs::remove_dir_all(&profile);}#[test]- fn disable_removes_from_bundles_only() {- let profile = build_profile("bundles-only", "a");- disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();+ fn disable_keeps_other_config_of_matching_entry() {+ let profile = build_profile("patch-update", "b");+ write_patch(+ &profile,+ "- id: dsh-better-sidebar\n disabled: false\n logLevel: debug\n",+ );+ assert!(add_patch_disable(&profile, "dsh-better-sidebar").unwrap());- let manifest = read_manifest(&profile);- // dependencies 不变- assert!(manifest["dependencies"]["dsh-better-sidebar"].is_string());- assert!(manifest["dependencies"]["dshmarket"].is_string());- // bundles 中已移除- let bundles = manifest["dsh"]["profile"]["bundles"].as_array().unwrap();- assert!(!bundles- .iter()- .any(|b| b.as_str() == Some("dsh-better-sidebar")));- assert!(bundles.iter().any(|b| b.as_str() == Some("dshmarket")));+ let content = read_patch(&profile);+ assert!(content.contains("logLevel: debug"));+ assert!(has_patch_disable(&profile, "dsh-better-sidebar"));+ // 命中条目而不是追加新条目+ assert_eq!(content.matches("dsh-better-sidebar").count(), 1);+ assert!(!content.contains("disabled: false"));let _ = fs::remove_dir_all(&profile);}#[test]- fn disable_writes_disabled_json() {- let profile = build_profile("disabled-json", "b");+ fn disable_appends_entry_after_unrelated_ones() {+ let profile = build_profile("patch-append", "c");+ write_patch(&profile, "- id: dshmarket\n foo: bar\n");disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- let map = load_disabled(&profile);- let entry = map- .get("dsh-better-sidebar")- .expect("disabled entry exists");- assert_eq!(entry.reason, "user");- assert!(!entry.disabled_at.is_empty());- // 时间戳是纯数字字符串- assert!(entry.disabled_at.parse::<u64>().is_ok());+ let content = read_patch(&profile);+ assert!(content.contains("dshmarket"));+ assert!(content.contains("foo: bar"));+ let targets = load_patch_disabled(&profile);+ assert!(targets.contains("dsh-better-sidebar"));+ assert!(!targets.contains("dshmarket"));let _ = fs::remove_dir_all(&profile);}#[test]- fn enable_restores_to_bundles() {- let profile = build_profile("enable-restore", "c");- disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- enable_plugin_at(&profile, "dsh-better-sidebar", false).unwrap();+ fn enable_strips_disable_and_keeps_other_config() {+ let profile = build_profile("patch-strip", "d");+ write_patch(+ &profile,+ "- id: dsh-better-sidebar\n disabled: true\n- id: dshmarket\n disabled: true\n- id: dsh-tauri-pet\n foo: bar\n",+ );+ enable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- let manifest = read_manifest(&profile);- let bundles = manifest["dsh"]["profile"]["bundles"].as_array().unwrap();- assert!(bundles- .iter()- .any(|b| b.as_str() == Some("dsh-better-sidebar")));+ let content = read_patch(&profile);+ assert!(!content.contains("dsh-better-sidebar"));+ assert!(content.contains("foo: bar"));+ let targets = load_patch_disabled(&profile);+ assert!(targets.contains("dshmarket"));+ assert!(!targets.contains("dsh-better-sidebar"));+ // 幂等+ let err = enable_plugin_at(&profile, "dsh-better-sidebar").unwrap_err();+ assert!(err.contains("ENABLE_NOT_DISABLED"));let _ = fs::remove_dir_all(&profile);}#[test]- fn enable_removes_from_disabled_json() {- let profile = build_profile("enable-rm-json", "d");+ fn disable_enable_round_trip_restores_original_patch() {+ let profile = build_profile("round-trip", "e");+ write_patch(&profile, "- id: dshmarket\n foo: bar\n");+ let before = read_patch(&profile);disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- enable_plugin_at(&profile, "dsh-better-sidebar", false).unwrap();+ assert!(has_patch_disable(&profile, "dsh-better-sidebar"));+ enable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- let map = load_disabled(&profile);- assert!(!map.contains_key("dsh-better-sidebar"));+ let doc: serde_yaml::Value = serde_yaml::from_str(&read_patch(&profile)).unwrap();+ let expected: serde_yaml::Value = serde_yaml::from_str(&before).unwrap();+ assert_eq!(doc, expected);let _ = fs::remove_dir_all(&profile);}#[test]fn disable_internal_plugin_is_rejected() {- let profile = build_profile("internal-reject", "e");+ let profile = build_profile("internal-reject", "f");let err = disable_plugin_at(&profile, "@deepseek-ai/dsh-base").unwrap_err();assert!(err.contains("DISABLE_INTERNAL_PLUGIN"));-- // manifest 未被修改- let manifest = read_manifest(&profile);- let bundles = manifest["dsh"]["profile"]["bundles"].as_array().unwrap();- assert_eq!(bundles.len(), 3);+ assert!(!profile.join(PATCH_FILE).exists());let _ = fs::remove_dir_all(&profile);}#[test]fn disable_not_installed_is_rejected() {- let profile = build_profile("not-installed", "f");+ let profile = build_profile("not-installed", "g");let err = disable_plugin_at(&profile, "dsh-not-exist").unwrap_err();assert!(err.contains("DISABLE_NOT_INSTALLED"));+ assert!(!profile.join(PATCH_FILE).exists());let _ = fs::remove_dir_all(&profile);}#[test]fn enable_not_disabled_is_rejected() {- let profile = build_profile("not-disabled", "g");- // 未禁用就启用 → 拒绝- let err = enable_plugin_at(&profile, "dsh-better-sidebar", false).unwrap_err();+ let profile = build_profile("not-disabled", "h");+ let err = enable_plugin_at(&profile, "dsh-better-sidebar").unwrap_err();assert!(err.contains("ENABLE_NOT_DISABLED"));let _ = fs::remove_dir_all(&profile);}- #[test]- fn round_trip_preserves_other_bundles() {- let profile = build_profile("round-trip", "h");- disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();- enable_plugin_at(&profile, "dsh-better-sidebar", false).unwrap();-- let manifest = read_manifest(&profile);- let bundles = manifest["dsh"]["profile"]["bundles"]- .as_array()- .unwrap()- .iter()- .filter_map(|b| b.as_str())- .collect::<Vec<_>>();- // 恢复原始顺序可能不同,但内容一致- assert_eq!(bundles.len(), 3);- assert!(bundles.contains(&"dsh-better-sidebar"));- assert!(bundles.contains(&"dshmarket"));- assert!(bundles.contains(&"@deepseek-ai/dsh-base"));- // dependencies 完全不变- assert!(manifest["dependencies"]["dsh-better-sidebar"].is_string());- assert!(manifest["dependencies"]["dshmarket"].is_string());- assert!(manifest["dependencies"]["@deepseek-ai/dsh-base"].is_string());-- let _ = fs::remove_dir_all(&profile);- }-- #[test]- fn disabled_list_persists_to_disk() {- let profile = build_profile("persist", "i");- disable_plugin_at(&profile, "dsh-better-sidebar").unwrap();-- // 重新从磁盘读取(不依赖内存)- let map = load_disabled(&profile);- assert!(map.contains_key("dsh-better-sidebar"));-- // 文件确实存在且可解析- let path = disabled_path(&profile);- assert!(path.exists());- let content = fs::read_to_string(&path).unwrap();- assert!(content.contains("dsh-better-sidebar"));- assert!(content.contains("\"disabledAt\""));- assert!(content.contains("\"reason\""));-- let _ = fs::remove_dir_all(&profile);- }-- /// 写入配置覆盖禁用条目的测试用 patch 文件。- fn write_patch(profile: &Path, content: &str) {- fs::write(profile.join("cordis.patch.yml"), content).unwrap();- }-/// `load_patch_disabled` 只收集带真值 `disabled` 字段的条目目标;/// `disabled: false`、无 disabled 字段、非映射条目都不算禁用。#[test]fn load_patch_disabled_collects_only_true_disables() {- let profile = build_profile("patch-collect", "j");+ let profile = build_profile("patch-collect", "i");write_patch(&profile,"- id: dshmarket\n disabled: true\n- id: dsh-better-sidebar\n disabled: false\n- id: dsh-tauri-pet\n config: 1\n- plain-string\n",@@ -647,9 +446,8 @@ mod tests {assert!(!targets.contains("dsh-better-sidebar"));assert!(!targets.contains("dsh-tauri-pet"));- // 缺文件/非法 YAML/非数组 → 空集assert!(load_patch_disabled(&std::env::temp_dir()).is_empty());- let broken = build_profile("patch-broken", "k");+ let broken = build_profile("patch-broken", "j");write_patch(&broken, "not: [valid");assert!(load_patch_disabled(&broken).is_empty());fs::remove_dir_all(&broken).ok();@@ -657,61 +455,15 @@ mod tests {fs::remove_dir_all(&profile).ok();}- /// 配置覆盖禁用但未显式确认 → ENABLE_CONFIG_OVERRIDE(绝不静默绕过)。- #[test]- fn enable_without_override_confirmation_is_rejected() {- let profile = build_profile("patch-reject", "l");- write_patch(&profile, "- id: dsh-better-sidebar\n disabled: true\n");- let err = enable_plugin_at(&profile, "dsh-better-sidebar", false).unwrap_err();- assert!(err.contains("ENABLE_CONFIG_OVERRIDE"));-- // 覆盖条目原样保留- let content = fs::read_to_string(profile.join("cordis.patch.yml")).unwrap();- assert!(content.contains("disabled: true"));-- fs::remove_dir_all(&profile).ok();- }-- /// 确认后启用:仅移除目标插件的禁用覆盖、清桌面记录、加回 bundles,- /// 其它插件的 patch 条目原样保留。- #[test]- fn enable_with_override_confirmation_strips_only_target() {- let profile = build_profile("patch-strip", "m");- write_patch(- &profile,- "- id: dsh-better-sidebar\n disabled: true\n- id: dshmarket\n disabled: true\n- id: dsh-tauri-pet\n foo: bar\n",- );- enable_plugin_at(&profile, "dsh-better-sidebar", true).unwrap();-- let content = fs::read_to_string(profile.join("cordis.patch.yml")).unwrap();- assert!(!content.contains("dsh-better-sidebar"));- assert!(content.contains("dshmarket"));- assert!(content.contains("dsh-tauri-pet"));- assert!(content.contains("foo: bar"));- // 其余禁用条目仍是禁用态- let targets = load_patch_disabled(&profile);- assert!(targets.contains("dshmarket"));- assert!(!targets.contains("dsh-better-sidebar"));-- // bundles 已加回- let manifest = read_manifest(&profile);- let bundles = manifest["dsh"]["profile"]["bundles"].as_array().unwrap();- assert!(bundles- .iter()- .any(|b| b.as_str() == Some("dsh-better-sidebar")));-- fs::remove_dir_all(&profile).ok();- }-#[test]fn strip_patch_disable_preserves_non_mapping_and_false_or_nested_targets() {- let profile = build_profile("patch-boundaries", "p");+ let profile = build_profile("patch-boundaries", "k");write_patch(&profile,"- dsh-better-sidebar\n- [dsh-better-sidebar]\n- id: other\n config: {id: dsh-better-sidebar}\n disabled: true\n- id: dsh-better-sidebar\n disabled: false\n- dsh-better-sidebar: alias\n disabled: true\n",);assert!(strip_patch_disable(&profile, "dsh-better-sidebar").unwrap());- let patch = profile.join("cordis.patch.yml");+ let patch = profile.join(PATCH_FILE);let content = fs::read_to_string(&patch).unwrap();let doc: serde_yaml::Value = serde_yaml::from_str(&content).unwrap();let expected: serde_yaml::Value = serde_yaml::from_str(@@ -724,29 +476,10 @@ mod tests {fs::remove_dir_all(&profile).unwrap();}- /// 带其它配置的禁用条目:只摘 `disabled` 键,其余配置保留(不删除无关配置)。- #[test]- fn strip_patch_disable_keeps_other_config_keys() {- let profile = build_profile("patch-keep", "n");- write_patch(- &profile,- "- id: dsh-better-sidebar\n disabled: true\n logLevel: debug\n",- );- enable_plugin_at(&profile, "dsh-better-sidebar", true).unwrap();-- let content = fs::read_to_string(profile.join("cordis.patch.yml")).unwrap();- assert!(!content.contains("disabled"));- assert!(content.contains("logLevel: debug"));- assert!(content.contains("dsh-better-sidebar"));-- fs::remove_dir_all(&profile).ok();- }-/// 别名匹配:patch 条目的 id 用包内 `name`(非依赖键)时同样命中。#[test]fn patch_disable_matches_package_json_name_alias() {- let profile = build_profile("patch-alias", "o");- // 依赖键 dsh-better-sidebar,但包内 name 为 better-sidebar(loader 别名形态)+ let profile = build_profile("patch-alias", "l");let pkg_dir = profile.join("node_modules").join("dsh-better-sidebar");fs::create_dir_all(&pkg_dir).unwrap();fs::write(@@ -757,11 +490,8 @@ mod tests {write_patch(&profile, "- id: better-sidebar\n disabled: true\n");assert!(has_patch_disable(&profile, "dsh-better-sidebar"));-- // 确认后启用:别名条目被移除- enable_plugin_at(&profile, "dsh-better-sidebar", true).unwrap();- let content = fs::read_to_string(profile.join("cordis.patch.yml")).unwrap();- assert!(!content.contains("better-sidebar"));+ enable_plugin_at(&profile, "dsh-better-sidebar").unwrap();+ assert!(!read_patch(&profile).contains("better-sidebar"));fs::remove_dir_all(&profile).ok();}diff --git a/src-tauri/src/service/plugin/install/mod.rs b/src-tauri/src/service/plugin/install/mod.rsindex afac776c..01f9c6e4 100644--- a/src-tauri/src/service/plugin/install/mod.rs+++ b/src-tauri/src/service/plugin/install/mod.rs@@ -609,8 +609,6 @@ async fn install_with_cancel());}- super::disable::preserve_disabled_bundles(&profile_dir(app_handle))?;-// 告知用户安装阶段结束;随后的服务重启由前端 continueAfterPreinstall 负责let _ = window.emit(PREINSTALL_LOG_EVENT,diff --git a/src-tauri/src/service/plugin/internal/mod.rs b/src-tauri/src/service/plugin/internal/mod.rsindex 04bcff95..26cce6c5 100644--- a/src-tauri/src/service/plugin/internal/mod.rs+++ b/src-tauri/src/service/plugin/internal/mod.rs@@ -291,9 +291,6 @@ fn ensure_fingerprint(app_handle: &AppHandle, internal: &[PreinstallPluginInfo])std::fs::read(profile.join("package.json")).unwrap_or_default().hash(&mut hasher);- std::fs::read(profile.join("disabled-plugins.json"))- .unwrap_or_default()- .hash(&mut hasher);std::fs::read(profile.join("cordis.yml")).unwrap_or_default().hash(&mut hasher);@@ -360,7 +357,6 @@ pub(crate) async fn ensure(app_handle: &AppHandle) -> Result<(), String> {"PROFILE_NOT_WRITABLE",)?;- super::disable::preserve_disabled_bundles(&profile_dir(app_handle))?;repair_loader_state(app_handle)?;let outcome =receive_current_or_next_flight(|| subscribe_or_start(app_handle, &internal)).await;@@ -692,9 +688,11 @@ async fn ensure_inner(// 本分支要「直接卸载」的孤儿内置插件(安装包名):其捆绑目录已不存在且仍以// `link:`/`file:` 本地依赖形式安装在 profile 里。见下方 bundle 缺失分支的说明。let mut orphans: Vec<String> = Vec::new();- let disabled = super::disable::load_disabled(&profile);for preset in internal {- if disabled.contains_key(&preset.id) || disabled.contains_key(installed_name(preset)) {+ let name = installed_name(preset);+ if super::disable::has_patch_disable(&profile, &preset.id)+ || super::disable::has_patch_disable(&profile, name)+ {continue;}let Some(bundled) = bundled_plugin_dir(app_handle, &preset.id) else {@@ -1042,7 +1040,6 @@ fn materialize_internal_links(});}materialize_links(profile, &links)?;- super::disable::preserve_disabled_bundles(profile)?;// pnpm 失败路径已为这些 id 记过安装错误;兜底成功后必须清掉,否则插件面板// 会继续显示「安装失败」而实际上插件已就绪(与 verify 的成功路径一致)。for (id, _, _) in need {diff --git a/src-tauri/src/service/plugin/recovery/mod.rs b/src-tauri/src/service/plugin/recovery/mod.rsindex 0fe64460..ac63f997 100644--- a/src-tauri/src/service/plugin/recovery/mod.rs+++ b/src-tauri/src/service/plugin/recovery/mod.rs@@ -24,7 +24,7 @@ use extract::{classify_reason, extract_duplicate_loader_entry, extract_plugin_refs, extract_slot_conflict,};use ownership::resolve_recovery_plugins;-pub(crate) use uninstall::{patch_entry_targets, remove_bundle};+pub(crate) use uninstall::patch_entry_targets;use uninstall::{remove_plugin_dir, remove_plugin_from_manifest, strip_cordis_patch_for};// plugin 兄弟模块的再导出:子模块经 `super::` 统一从这里取。diff --git a/src-tauri/src/service/plugin/watch.rs b/src-tauri/src/service/plugin/watch.rsindex 6a5dda4d..f7a1df57 100644--- a/src-tauri/src/service/plugin/watch.rs+++ b/src-tauri/src/service/plugin/watch.rs@@ -44,18 +44,10 @@ pub struct DshPlugin {pub repo_url: String,/// 是否在 `dsh.profile.bundles` 中(启动时自动加载)pub bundled: bool,- /// 是否在禁用清单(`disabled-plugins.json`)中。+ /// 是否在 profile 的 `cordis.patch.yml` 中被禁用(`disabled: true`)。///- /// 与 `bundled` 独立:已安装但不在 `bundles` 中的插件,仅当同时存在于- /// 禁用清单时才视为「已禁用」;否则为「未加载」(用户未主动禁用,- /// 启用操作会返回 `ENABLE_NOT_DISABLED`,前端不应展示启用入口)。- pub disabled: bool,- /// 是否在 profile 的 `cordis.patch.yml` 中被配置层禁用(`disabled: true`)。- ///- /// 与 `disabled`(桌面禁用清单)独立:patch 覆盖是用户/第三方直接写在- /// 配置文件里的更高优先级禁用,运行期同样不加载。桌面「启用」操作不会- /// 静默清除它——需用户确认后才会移除对应覆盖(见- /// `disable::strip_patch_disable`),避免「声称成功却仍被配置禁用」。+ /// 这是插件开关的唯一状态,与官方 Plugins 页 / dshmarket 共用:`bundled`+ /// 只表示是否在 `dsh.profile.bundles` 中被自动加载,不代表用户开关。pub patch_disabled: bool,/// 预设清单中的「推荐」标记(绿色 chip)pub recommended: bool,@@ -161,11 +153,8 @@ pub(crate) fn parse_plugins(profile: &Path, presets: &[PreinstallPluginInfo]) ->.map(|p| installed_name(p).to_string()).collect();- // 禁用清单:用于区分「已禁用」(用户主动禁用)与「未加载」(不在 bundles- // 但也不在禁用清单,启用会返回 ENABLE_NOT_DISABLED)。- let disabled_map = crate::service::plugin::disable::load_disabled(profile);- // 配置覆盖禁用集合(cordis.patch.yml 顶层 `disabled: true` 条目):命中的- // 插件按「配置覆盖禁用」展示,与桌面禁用清单区分(优先级更高)。+ // 插件开关的唯一状态:`cordis.patch.yml` 顶层 `disabled: true` 条目(与官方+ // Plugins 页 / dshmarket 共用)。let patch_disabled_set = crate::service::plugin::disable::load_patch_disabled(profile);let mut dep_ids: Vec<&String> = manifest.dependencies.keys().collect();@@ -207,7 +196,6 @@ pub(crate) fn parse_plugins(profile: &Path, presets: &[PreinstallPluginInfo]) ->.unwrap_or_default(),repo_url,bundled: bundled.contains(id.as_str()),- disabled: disabled_map.contains_key(id),patch_disabled: patch_disabled_set.contains(id.as_str()) || patch_disabled_by_name,recommended: preset.map(|p| p.recommended).unwrap_or(false),fix: preset.map(|p| p.fix).unwrap_or(false),@@ -264,12 +252,11 @@ pub fn force_emit(app_handle: &AppHandle) {}/// 变化指纹:profile package.json、各直接依赖插件 package.json,以及-/// `cordis.patch.yml` / `disabled-plugins.json` 的内容拼接。+/// `cordis.patch.yml` 的内容拼接。////// pnpm add/remove/install 会重写 profile 清单(依赖与 bundles)并落盘插件包,-/// 任一变化都会改变指纹;配置覆盖(patch)与桌面禁用清单被外部修改时也应-/// 触发插件列表刷新(issue #399:监听 patch/禁用清单变化)。profile 未初始化-/// (首次运行)时返回 None。+/// 任一变化都会改变指纹;插件开关写在 patch 里,被官方插件页 / 手工编辑改动时也要+/// 触发插件列表刷新(issue #399)。profile 未初始化(首次运行)时返回 None。fn fingerprint(app_handle: &AppHandle) -> Option<String> {let dir = profile_dir(app_handle);let manifest = std::fs::read_to_string(dir.join("package.json")).ok()?;@@ -283,12 +270,10 @@ fn fingerprint(app_handle: &AppHandle) -> Option<String> {parts.push(content);}}- // 配置覆盖与桌面禁用清单不在依赖文件里,但直接影响插件列表的展示态:- // 一并纳入指纹,外部直接编辑这些文件时也能实时刷新。- for extra in ["cordis.patch.yml", "disabled-plugins.json"] {- if let Ok(content) = std::fs::read_to_string(dir.join(extra)) {- parts.push(content);- }+ // patch 不在依赖文件里,但直接决定插件列表的开关状态:一并纳入指纹,+ // 外部直接编辑该文件时也能实时刷新。+ if let Ok(content) = std::fs::read_to_string(dir.join("cordis.patch.yml")) {+ parts.push(content);}Some(parts.join("\n---\n"))}@@ -531,7 +516,6 @@ mod tests {description: String::new(),repo_url: String::new(),bundled: true,- disabled: false,patch_disabled: false,recommended: false,fix: false,@@ -564,7 +548,6 @@ mod tests {description: String::new(),repo_url: String::new(),bundled: true,- disabled: false,patch_disabled: false,recommended: false,fix: false,@@ -611,10 +594,10 @@ mod tests {std::fs::remove_dir_all(&dir).ok();}- /// 覆盖 `disabled` 字段的状态组合:- /// - 在 bundles 且不在禁用清单 → bundled=true, disabled=false(正常加载)- /// - 不在 bundles 但在禁用清单 → bundled=false, disabled=true(已禁用,可启用)- /// - 不在 bundles 且不在禁用清单 → bundled=false, disabled=false(未加载,启用会失败)+ /// 三种状态由 `bundled`(是否在 `dsh.profile.bundles`)与 patch 禁用共同决定:+ /// - 在 bundles 且未被 patch 禁用 → bundled=true, patch_disabled=false(正常加载)+ /// - 不在 bundles 但被 patch 禁用 → bundled=false, patch_disabled=true(已禁用,可启用)+ /// - 不在 bundles 且未被 patch 禁用 → bundled=false, patch_disabled=false(未加载)#[test]fn parse_plugins_distinguishes_disabled_from_unloaded() {let dir = std::env::temp_dir().join(format!("dsh-watch-disabled-{}", std::process::id()));@@ -644,33 +627,28 @@ mod tests {).unwrap();}- // 仅 dsh-disabled 写入禁用清单。- let disabled = serde_json::json!({- "dsh-disabled": { "disabledAt": "1700000000", "reason": "user" }- });+ // 仅 dsh-disabled 在 patch 里被禁用。std::fs::write(- dir.join("disabled-plugins.json"),- serde_json::to_string_pretty(&disabled).unwrap(),+ dir.join("cordis.patch.yml"),+ "- id: dsh-disabled\n disabled: true\n",).unwrap();let plugins = parse_plugins(&dir, &[]);let loaded = plugins.iter().find(|p| p.id == "dsh-loaded").unwrap();assert!(loaded.bundled);- assert!(!loaded.disabled);+ assert!(!loaded.patch_disabled);let disabled_plugin = plugins.iter().find(|p| p.id == "dsh-disabled").unwrap();assert!(!disabled_plugin.bundled);- assert!(disabled_plugin.disabled);+ assert!(disabled_plugin.patch_disabled);let unloaded = plugins.iter().find(|p| p.id == "dsh-unloaded").unwrap();assert!(!unloaded.bundled);- assert!(!unloaded.disabled);+ assert!(!unloaded.patch_disabled);std::fs::remove_dir_all(&dir).ok();}- /// `cordis.patch.yml` 配置覆盖禁用(`disabled: true`)独立于桌面禁用清单:- /// 命中条目目标(依赖键或包内 name 别名)的插件标记 `patch_disabled`,- /// `disabled: false` 与未禁用的条目不标记。+ /// `cordis.patch.yml` 里 `disabled: false` 与未带 disabled 字段的条目不标记禁用。#[test]fn parse_plugins_marks_config_override_disabled() {let dir = build_profile(diff --git a/src-tauri/src/service/profile/migrate.rs b/src-tauri/src/service/profile/migrate.rsindex 1d2dfc9c..9ff2cb74 100644--- a/src-tauri/src/service/profile/migrate.rs+++ b/src-tauri/src/service/profile/migrate.rs@@ -20,9 +20,7 @@ use tauri::AppHandle;use crate::config;use crate::service::fs_guard;use crate::service::plugin::compat::{self, PluginInspect};-use crate::service::plugin::{- disable, inspect_specs, load_presets, packument, watch, ProfilePackageJson,-};+use crate::service::plugin::{inspect_specs, load_presets, packument, watch, ProfilePackageJson};/// 发布时长策略豁免键(与 `profile::profile_release_age_excludes` 同源)。const POLICY_KEY: &str = "minimumReleaseAgeExclude";@@ -30,7 +28,6 @@ const POLICY_KEY: &str = "minimumReleaseAgeExclude";/// 档案级数据的落盘文件名。const CREDENTIALS_FILE: &str = ".credentials.yaml";const PATCH_FILE: &str = "cordis.patch.yml";-const DISABLED_FILE: &str = "disabled-plugins.json";const POLICY_FILE: &str = "pnpm-workspace.yaml";/// 迁移条目的兼容性判定结果(判定基准 = 当前核心版本)。@@ -65,8 +62,6 @@ pub struct MigrationEntry {pub enum MigrationDataKind {/// 补丁层 `cordis.patch.yml`Patch,- /// 桌面禁用清单 `disabled-plugins.json`- Disabled,/// 发布时长策略豁免 `pnpm-workspace.yaml`Policy,/// 凭据 `.credentials.yaml`@@ -291,15 +286,6 @@ fn data_items(source: &Path, target: &Path) -> Vec<MigrationDataItem> {covered: patch_covered(&patch, target),});}- let disabled = disable::load_disabled(source);- if !disabled.is_empty() {- let existing = disable::load_disabled(target);- items.push(MigrationDataItem {- kind: MigrationDataKind::Disabled,- count: Some(disabled.len()),- covered: disabled.keys().all(|id| existing.contains_key(id)),- });- }let policy = release_age_excludes(source);if !policy.is_empty() {let existing = release_age_excludes(target);@@ -367,7 +353,6 @@ fn release_age_excludes(dir: &Path) -> Vec<String> {fn merge(kind: MigrationDataKind, source: &Path, target: &Path) -> Result<bool, String> {match kind {MigrationDataKind::Patch => merge_patch(source, target),- MigrationDataKind::Disabled => merge_disabled(source, target),MigrationDataKind::Policy => merge_policy(source, target),MigrationDataKind::Credentials => merge_credentials(source, target),}@@ -404,27 +389,6 @@ fn merge_patch(source: &Path, target: &Path) -> Result<bool, String> {Ok(true)}-/// 禁用清单按插件 id 求并集:目标已有的 id 保留目标记录(含禁用时间)。-fn merge_disabled(source: &Path, target: &Path) -> Result<bool, String> {- if !source.join(DISABLED_FILE).is_file() {- return Ok(false);- }- let incoming = disable::load_disabled(source);- if incoming.is_empty() {- return Ok(false);- }- let mut merged = disable::load_disabled(target);- let before = merged.len();- for (id, entry) in incoming {- merged.entry(id).or_insert(entry);- }- if merged.len() == before {- return Ok(false);- }- disable::save_disabled(target, &merged)?;- Ok(true)-}-/// 发布时长豁免并进目标档案(复用既有的档案级写入,含去重与落盘格式)。////// 按 `target` 路径写:调用开始时捕获的目标档案不能在半途被「当前档案」改道。@@ -582,32 +546,6 @@ mod tests {let _ = fs::remove_dir_all(&target);}- #[test]- fn merge_disabled_keeps_target_entries() {- let source = workspace("disabled-source");- let target = workspace("disabled-target");- fs::write(- source.join(DISABLED_FILE),- r#"{"a":{"disabledAt":"1","reason":"user"},"b":{"disabledAt":"2","reason":"user"}}"#,- )- .unwrap();- fs::write(- target.join(DISABLED_FILE),- r#"{"a":{"disabledAt":"9","reason":"user"}}"#,- )- .unwrap();-- assert!(merge_disabled(&source, &target).unwrap());-- let merged = disable::load_disabled(&target);- assert_eq!(merged.len(), 2);- assert_eq!(merged["a"].disabled_at, "9", "目标记录必须保留");- assert_eq!(merged["b"].disabled_at, "2");-- let _ = fs::remove_dir_all(&source);- let _ = fs::remove_dir_all(&target);- }-#[test]fn merge_credentials_never_overwrites_existing_target() {let source = workspace("credentials-source");diff --git a/src-tauri/src/service/profile/mod.rs b/src-tauri/src/service/profile/mod.rsindex afd7985c..7f458f79 100644--- a/src-tauri/src/service/profile/mod.rs+++ b/src-tauri/src/service/profile/mod.rs@@ -1699,19 +1699,13 @@ mod tests {let profiles_root = tmp.join("profiles");let sessions = tmp.join("sessions");- // 档案:模板初始化后再塞入用户数据(插件依赖、补丁层、桌面禁用清单)+ // 档案:模板初始化后再塞入用户数据(插件依赖)init_profile_dir(&profiles_root.join("web"), "web").unwrap();std::fs::write(profiles_root.join("web").join("package.json"),r#"{"name":"dsh-profile-web","dependencies":{"some-plugin":"1.2.3"}}"#,).unwrap();- std::fs::write(profiles_root.join("web").join("cordis.patch.yml"), "[]\n").unwrap();- std::fs::write(- profiles_root.join("web").join("disabled-plugins.json"),- r#"["some-plugin"]"#,- )- .unwrap();// 会话位于档案目录之外,重置不得触碰std::fs::create_dir_all(sessions.join("_no-cwd")).unwrap();std::fs::write(sessions.join("_no-cwd").join("s1.json"), "{}").unwrap();@@ -1729,10 +1723,6 @@ mod tests {manifest["dsh"]["profile"]["bundles"],serde_json::json!(["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app"]));- assert!(!profiles_root- .join("web")- .join("disabled-plugins.json")- .exists());// 会话数据完整保留assert!(sessions.join("_no-cwd").join("s1.json").is_file());diff --git a/src/hooks/use-plugins-manager.ts b/src/hooks/use-plugins-manager.tsindex d9721bb1..61446729 100644--- a/src/hooks/use-plugins-manager.ts+++ b/src/hooks/use-plugins-manager.ts@@ -36,10 +36,7 @@ export interface UseDshPluginsManagerResult {upgrade: (refs: PluginRef | PluginRef[]) => Promise<PluginProcessResult[]>uninstall: (refs: PluginRef | PluginRef[]) => Promise<PluginProcessResult[]>disable: (refs: PluginRef | PluginRef[]) => Promise<PluginProcessResult[]>- enable: (- refs: PluginRef | PluginRef[],- options?: { clearConfigOverride?: boolean },- ) => Promise<PluginProcessResult[]>+ enable: (refs: PluginRef | PluginRef[]) => Promise<PluginProcessResult[]>approve: (refs?: PluginRef | PluginRef[]) => Promise<PluginProcessResult[]>reject: (ref: PluginRef) => Promise<PluginProcessResult[]>cancel: () => Promise<void>@@ -65,12 +62,8 @@ export function useDshPluginsManager(options: UseDshPluginsManagerOptions = {}):async function run(type: 'install' | 'upgrade' | 'uninstall' | 'disable' | 'enable',refs: PluginRef | PluginRef[],- enableOptions?: { clearConfigOverride?: boolean },): Promise<PluginProcessResult[]> {- const results = await plugins.enqueue(type, refs, {- ...runtime,- clearConfigOverride: enableOptions?.clearConfigOverride ?? runtime.clearConfigOverride ?? false,- })+ const results = await plugins.enqueue(type, refs, { ...runtime })void queryClient.invalidateQueries({ queryKey: queryKeys.plugins })return results}@@ -114,7 +107,7 @@ export function useDshPluginsManager(options: UseDshPluginsManagerOptions = {}):upgrade: refs => run('upgrade', refs),uninstall: refs => run('uninstall', refs),disable: refs => run('disable', refs),- enable: (refs, enableOptions) => run('enable', refs, enableOptions),+ enable: refs => run('enable', refs),approve: refs => plugins.approve(refs),reject: ref => plugins.reject(ref),cancel: () => plugins.cancel(),diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex a36d70b9..e64e802e 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -265,7 +265,6 @@"profiles.migrate_verdict_downgrade": "↓Downgrade → {{version}}","profiles.migrate_verdict_unknown": "Compatibility unknown","profiles.migrate_data_patch": "Patch layer · {{count}}",- "profiles.migrate_data_disabled": "Disabled list · {{count}}","profiles.migrate_data_policy": "minimumReleaseAgeExclude · {{count}}","profiles.migrate_data_credentials": "Credentials","profiles.migrate_data_absent": "Not in the source profile",@@ -333,14 +332,10 @@"plugins.disable_builtin_confirm_desc": "Disabling the built-in plugin {{name}} may cause the desktop shell or related features to malfunction. Confirm disabling?","plugins.enable": "Enable","plugins.disabled_badge": "Disabled",- "plugins.patch_disabled_badge": "Disabled · Config Override","plugins.disable_toast": "Plugin {{name}} disabled","plugins.disable_failed": "Failed to disable {{name}}","plugins.enable_toast": "Plugin {{name}} enabled","plugins.enable_failed": "Failed to enable {{name}}",- "plugins.enable_override_confirm_title": "Enable via config override",- "plugins.enable_override_confirm_desc": "{{name}} is disabled in cordis.patch.yml. Enabling will remove only that disable override (other config entries are kept) and restart the service. Continue?",- "plugins.enable_override_confirm": "Remove override & enable","plugins.advanced_options": "Advanced options","plugins.snapshot": "Snapshot","plugins.snapshot_toast": "Plugin {{name}} snapshotted",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 72974afc..85c93929 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -265,7 +265,6 @@"profiles.migrate_verdict_downgrade": "↓降级 → {{version}}","profiles.migrate_verdict_unknown": "未知兼容","profiles.migrate_data_patch": "补丁层 · {{count}} 项",- "profiles.migrate_data_disabled": "禁用清单 · {{count}} 项","profiles.migrate_data_policy": "时间限制豁免 · {{count}} 项","profiles.migrate_data_credentials": "凭据","profiles.migrate_data_absent": "源档案没有此项",@@ -333,14 +332,10 @@"plugins.disable_builtin_confirm_desc": "禁用内置插件 {{name}} 可能导致桌面壳或相关功能异常。是否确认禁用?","plugins.enable": "启用","plugins.disabled_badge": "已禁用",- "plugins.patch_disabled_badge": "已禁用 · 配置覆盖","plugins.disable_toast": "插件 {{name}} 已禁用","plugins.disable_failed": "禁用插件 {{name}} 失败","plugins.enable_toast": "插件 {{name}} 已启用","plugins.enable_failed": "启用插件 {{name}} 失败",- "plugins.enable_override_confirm_title": "启用被配置覆盖禁用的插件",- "plugins.enable_override_confirm_desc": "插件 {{name}} 在 cordis.patch.yml 中被配置覆盖禁用。启用将仅移除该禁用覆盖(保留其它配置条目)并重启服务,确定吗?",- "plugins.enable_override_confirm": "移除覆盖并启用","plugins.advanced_options": "高级选项","plugins.snapshot": "快照","plugins.snapshot_toast": "插件 {{name}} 已创建快照",diff --git a/src/store/modules/plugins/store.ts b/src/store/modules/plugins/store.tsindex 4f15b40d..3b7ebc76 100644--- a/src/store/modules/plugins/store.ts+++ b/src/store/modules/plugins/store.ts@@ -281,9 +281,9 @@ export const plugins = defineStore({const installed = this.installedSource.find(item => item.id === process.name || item.name === process.name)if (!installed)return process.type === 'uninstall' ? 'already-absent' : 'not-installed'- if (process.type === 'disable' && installed.disabled)+ if (process.type === 'disable' && installed.patchDisabled)return 'already-absent'- if (process.type === 'enable' && !installed.disabled && !installed.patchDisabled)+ if (process.type === 'enable' && !installed.patchDisabled)return 'already-absent'return null},@@ -293,10 +293,7 @@ export const plugins = defineStore({if (group.type === 'disable' || group.type === 'enable') {const settled = await Promise.allSettled(targets.map(process =>- invoke<void>(COMMANDS[group.type], {- id: process.name,- ...(group.type === 'enable' ? { clearConfigOverride: group.options.clearConfigOverride ?? false } : {}),- }),+ invoke<void>(COMMANDS[group.type], { id: process.name }),),)const blocked: PluginProcess[] = []diff --git a/src/store/modules/plugins/types.ts b/src/store/modules/plugins/types.tsindex 1455b2e3..b7859a45 100644--- a/src/store/modules/plugins/types.ts+++ b/src/store/modules/plugins/types.ts@@ -17,7 +17,6 @@ export interface Plugin {description: stringrepoUrl: stringbundled: boolean- disabled: booleanpatchDisabled: booleanrecommended: booleanfix: boolean@@ -87,7 +86,6 @@ export interface PluginSearchResult {export interface PluginsManagerRuntime {toast: booleanrestartOnSettle: boolean- clearConfigOverride?: boolean}export interface PluginGroup {diff --git a/src/store/modules/plugins/utils.ts b/src/store/modules/plugins/utils.tsindex 4c9060a7..a9822550 100644--- a/src/store/modules/plugins/utils.ts+++ b/src/store/modules/plugins/utils.ts@@ -174,7 +174,6 @@ export function enrichInstalled(list: DshPlugin[]): Plugin[] {description: item.description,repoUrl: item.repo_url,bundled: item.bundled,- disabled: item.disabled,patchDisabled: item.patchDisabled,recommended: item.recommended,fix: item.fix,diff --git a/src/types/plugin.ts b/src/types/plugin.tsindex 9cc76962..c2ba2a29 100644--- a/src/types/plugin.ts+++ b/src/types/plugin.ts@@ -21,9 +21,7 @@ export interface DshPlugin {repo_url: string/** 是否在 dsh.profile.bundles 中(启动时自动加载) */bundled: boolean- /** 是否在禁用清单(disabled-plugins.json)中,独立于 bundled */- disabled: boolean- /** 是否在 cordis.patch.yml 中被配置覆盖禁用(disabled: true),优先级高于禁用清单 */+ /** 是否在 profile 的 cordis.patch.yml 中被禁用(disabled: true),插件开关的唯一状态 */patchDisabled: boolean/** 预设清单中的「推荐」标记 */recommended: boolean@@ -98,7 +96,7 @@ export interface MigrationEntry {}/** 档案级数据类别(Rust 侧 MigrationDataKind) */-export type MigrationDataKind = 'patch' | 'disabled' | 'policy' | 'credentials'+export type MigrationDataKind = 'patch' | 'policy' | 'credentials'/** Rust 侧 service::profile::migrate::MigrationDataItem 的序列化形态 */export interface MigrationDataItem {diff --git a/src/ui/config/plugin.test.tsx b/src/ui/config/plugin.test.tsxindex 908b5340..0747b7dd 100644--- a/src/ui/config/plugin.test.tsx+++ b/src/ui/config/plugin.test.tsx@@ -79,7 +79,6 @@ function plugin(overrides: Partial<Plugin> = {}): Plugin {id: 'dsh-tauri-pet',name: 'Desktop Pet',internal: true,- disabled: false,patchDisabled: false,version: '1.0.0',description: '',@@ -156,24 +155,15 @@ describe('built-in plugin toggles', () => {expect(manager.disable).not.toHaveBeenCalled()})- it('enables a desktop-disabled built-in without showing a disable action', async () => {- manager.installed = [plugin({ disabled: true })]+ it('enables a disabled built-in without showing a disable action', async () => {+ manager.installed = [plugin({ patchDisabled: true })]showBuiltIn()expect(screen.queryByRole('button', { name: 'plugins.disable' })).toBeNull()await act(async () => fireEvent.click(screen.getByRole('button', { name: 'plugins.enable' })))- expect(manager.enable).toHaveBeenCalledExactlyOnceWith('dsh-tauri-pet', { clearConfigOverride: false })+ expect(manager.enable).toHaveBeenCalledExactlyOnceWith('dsh-tauri-pet')expect(openDialog).not.toHaveBeenCalled()})- it('keeps explicit confirmation for enabling a config-disabled built-in', async () => {- manager.installed = [plugin({ patchDisabled: true })]- openDialog.mockResolvedValue(undefined)- showBuiltIn()- await act(async () => fireEvent.click(screen.getByRole('button', { name: 'plugins.enable' })))- expect(openDialog).toHaveBeenCalledWith(expect.objectContaining({ title: 'plugins.enable_override_confirm_title' }))- expect(manager.enable).toHaveBeenCalledExactlyOnceWith('dsh-tauri-pet', { clearConfigOverride: true })- })-it('keeps non-built-in disabling direct', async () => {manager.installed = [plugin({ internal: false })]render(<ConfigPlugin />)diff --git a/src/ui/config/plugin.tsx b/src/ui/config/plugin.tsxindex 633a1129..a6cb7930 100644--- a/src/ui/config/plugin.tsx+++ b/src/ui/config/plugin.tsx@@ -338,29 +338,10 @@ export function ConfigPlugin() {await runAction(id, 'disable', () => manager.disable(id))}- async function onEnable(id: string, clearConfigOverride = false) {+ async function onEnable(id: string) {if (rowBusy(id))return- if (clearConfigOverride) {- const name = plugins.find(p => p.id === id)?.name ?? id- try {- await openDialog({- status: 'warning',- title: t('plugins.enable_override_confirm_title'),- description: (- <p>- {t('plugins.enable_override_confirm_desc', { name })}- </p>- ),- confirmText: t('plugins.enable_override_confirm'),- })- }- catch (e) {- silence(e, 'plugin enable: config override dialog cancelled')- return- }- }- await runAction(id, 'enable', () => manager.enable(id, { clearConfigOverride }))+ await runAction(id, 'enable', () => manager.enable(id))}async function onSnapshot(id: string, name: string, hasSnapshot: boolean) {@@ -514,18 +495,13 @@ export function ConfigPlugin() {{t('plugins.preset')}</Chip></If>- <If cond={plugin.disabled}>+ {/* 禁用态:profile 的 cordis.patch.yml 中的 disabled 覆盖(内置插件同样标注,+ issue #399:Scheduler/Pet 行此前只有「内置」) */}+ <If cond={plugin.patchDisabled}><Chip size="sm" variant="soft" color="default">{t('plugins.disabled_badge')}</Chip></If>- {/* 配置覆盖禁用:展示在 cordis.patch.yml 中被显式禁用的真实状态- (内置插件同样标注,issue #399:Scheduler/Pet 行此前只有「内置」) */}- <If cond={plugin.patchDisabled}>- <Chip size="sm" variant="soft" color="warning">- {t('plugins.patch_disabled_badge')}- </Chip>- </If><If cond={plugin.internal}><code className="shrink-0 rounded bg-default px-1.5 py-0.5 font-mono text-[10px] text-muted">{t('plugins.builtin')}@@ -561,13 +537,13 @@ export function ConfigPlugin() {</span></Chip></If>- <If cond={plugin.patchDisabled || plugin.disabled}>+ <If cond={plugin.patchDisabled}><ChipclassName={actionChip({ busy: rowBusy(plugin.id) })}variant="primary"color="accent"size="sm"- onClick={() => onEnable(plugin.id, plugin.patchDisabled)}+ onClick={() => onEnable(plugin.id)}><span className="flex items-center gap-1"><If cond={busyWith(plugin.id, 'enable')} then={<Spinner size="sm" color="current" />} />@@ -575,7 +551,7 @@ export function ConfigPlugin() {</span></Chip></If>- <If cond={!plugin.patchDisabled && !plugin.disabled}>+ <If cond={!plugin.patchDisabled}><ChipclassName={actionChip({ busy: rowBusy(plugin.id) })}size="sm"diff --git a/src/ui/dialog/profile-migrate.tsx b/src/ui/dialog/profile-migrate.tsxindex 5757fba5..816cb53a 100644--- a/src/ui/dialog/profile-migrate.tsx+++ b/src/ui/dialog/profile-migrate.tsx@@ -23,18 +23,16 @@ const VERDICT_CHIPS: Record<MigrationVerdict, { key: string, color: 'default' |/** 档案级数据类别 → 源档案里的文件名 */const DATA_FILES: Record<MigrationDataKind, string> = {patch: 'cordis.patch.yml',- disabled: 'disabled-plugins.json',policy: 'pnpm-workspace.yaml',credentials: '.credentials.yaml',}/** 数据项的列出顺序:凭据固定最后 */-const DATA_ORDER: MigrationDataKind[] = ['patch', 'disabled', 'policy', 'credentials']+const DATA_ORDER: MigrationDataKind[] = ['patch', 'policy', 'credentials']/** 档案级数据类别 → 说明文案 key */const DATA_LABEL_KEYS: Record<MigrationDataKind, string> = {patch: 'profiles.migrate_data_patch',- disabled: 'profiles.migrate_data_disabled',policy: 'profiles.migrate_data_policy',credentials: 'profiles.migrate_data_credentials',}diff --git a/test/plugin-manager-api.test.ts b/test/plugin-manager-api.test.tsindex 055af40f..66bb330b 100644--- a/test/plugin-manager-api.test.ts+++ b/test/plugin-manager-api.test.ts@@ -109,7 +109,6 @@ describe('plugins manager idempotency', () => {description: '',repo_url: '',bundled: false,- disabled: false,patchDisabled: false,recommended: false,fix: false,@@ -136,7 +135,6 @@ describe('plugins manager idempotency', () => {description: '',repo_url: '',bundled: false,- disabled: false,patchDisabled: false,recommended: false,fix: false,@@ -164,7 +162,6 @@ describe('plugins manager idempotency', () => {description: '',repo_url: '',bundled: false,- disabled: false,patchDisabled: false,recommended: false,fix: false,@@ -195,8 +192,7 @@ describe('plugins manager idempotency', () => {description: '',repo_url: '',bundled: false,- disabled: true,- patchDisabled: false,+ patchDisabled: true,recommended: false,fix: false,internal: false,diff --git a/test/plugin-manager-queue.test.ts b/test/plugin-manager-queue.test.tsindex ecce8ed1..2417f505 100644--- a/test/plugin-manager-queue.test.ts+++ b/test/plugin-manager-queue.test.ts@@ -98,13 +98,13 @@ describe('plugins manager queue', () => {expect(results.every(result => result.ok)).toBe(true)})- it('runs an enable group through the per-plugin command with the override flag', async () => {+ it('runs an enable group through the per-plugin command', async () => {invoke.mockResolvedValue(undefined)- await plugins.enqueue('enable', ['a'], { ...RUNTIME, clearConfigOverride: true })+ await plugins.enqueue('enable', ['a'], RUNTIME)expect(invoke).toHaveBeenCalledTimes(1)- expect(invoke).toHaveBeenCalledWith('enable_dsh_plugin', { id: 'a', clearConfigOverride: true })+ expect(invoke).toHaveBeenCalledWith('enable_dsh_plugin', { id: 'a' })})it('keeps queue order when a later group is enqueued while an earlier one is settling', async () => {diff --git a/test/plugin-uninstall.test.ts b/test/plugin-uninstall.test.tsindex 056da2f4..dac29a13 100644--- a/test/plugin-uninstall.test.ts+++ b/test/plugin-uninstall.test.ts@@ -76,8 +76,8 @@ describe('configPlugin preset chip', () => {it('allows internal toggles while withholding uninstall/snapshot', () => {const source = readFileSync(new URL('../src/ui/config/plugin.tsx', import.meta.url), 'utf8')- expect(source, '禁用入口包含内置插件').toContain('cond={!plugin.patchDisabled && !plugin.disabled}')- expect(source, '启用入口包含内置插件的桌面禁用态').toContain('cond={plugin.patchDisabled || plugin.disabled}')+ expect(source, '禁用入口包含内置插件').toContain('cond={!plugin.patchDisabled}')+ expect(source, '启用入口包含内置插件的禁用态').toContain('cond={plugin.patchDisabled}')expect(source, '快照入口由 !plugin.internal 守卫').toContain('<If cond={!plugin.internal}>')})