Skip to content

fix(plugins): preserve projectPath and prevent duplicate React row keys - #9963

Merged
farion1231 merged 1 commit into
farion1231:mainfrom
jimpablo:fix/plugins-duplicate-scope-keys
Nov 26, 2026
Merged

farion1231 merged 1 commit into
farion1231:mainfrom
jimpablo:fix/plugins-duplicate-scope-keys

Conversation

@jimpablo

Copy link
Copy Markdown
Contributor

Human Note / 本人说明

我在 Claude Code 插件页删除多个项目的 local 范围插件后,发现界面还残留了一条 context7 的 local 记录消不掉,同时也看不出每条 local/project 插件具体属于哪个项目。这个 PR 修复了重复 React key 导致的幽灵行残留问题,并把 projectPath 传到前端展示和搜索,顺便隔离了只读行的转圈状态。

Summary / 概述

  1. 后端保留 projectPath(Rust)
    • PluginEntry(src-tauri/src/services/plugin_manager/mod.rs)新增 pub project_path: Option<String>(序列化为 projectPath),parse_claude_listing 保留非 user 范围条目的 projectPath。
    • catalog_from_listing 与 parse_codex_entry 显式置 project_path: None;补齐 agy.rs、grok.rs、mcode.rs、openclaw.rs 中显式构造的 project_path: None。
  2. 修复重复 React key 与条目身份匹配(前端)
    • 在 src/components/plugins/PluginsPage.tsx 新增并导出 pluginRowKeys,按 (id, scope, projectPath) 生成稳定唯一的 key(不把会随安装/更新变化的 installPath 纳入 key),并对升级前缺少 projectPath 的旧 localStorage 缓存重复项按出现次序追加 #N 去重,防止列表缩减、搜索、切页签或切应用时残留幽灵 DOM 行。
    • 在 src/hooks/usePlugins.ts 新增并导出 projectPathOf 与 samePluginEntry(按 id、scope、projectPath 识别),统一供 pluginPatches 与 PluginsPage.tsx 卸载回滚逻辑复用,并在 installedFromCatalog 显式置 projectPath: null。
  3. 展示/搜索项目路径并隔离只读行转圈(前端)
    • 非 user 范围且带有 projectPath 的插件行展示所属项目目录(截断等宽次级行,title 提供完整路径,无需新增 i18n 文案),并纳入 filterPlugins 搜索范围。
    • busyAction 对只读已安装行(entry.installed && !entry.manageable)传 undefined,避免操作同名 user 行时把转圈泄漏到 local / project 行,同时保持 Claude「发现」页条目(installed: false, manageable: false)的安装转圈正常。
  4. 测试覆盖
    • 后端(src-tauri/src/services/plugin_manager/mod.rs):新增多项目 projectPath 解析/序列化测试并扩展目录字段重置测试。
    • 前端(tests/components/PluginsPage.test.tsx):新增 filterPlugins / samePluginEntry / pluginRowKeys 单元测试,以及旧缓存重复 local 行刷新清除、多项目展示/搜索/切页/切应用、只读行转圈隔离回归测试。

Related Issue / 关联 Issue

Fixes #9962

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件 (no user-facing i18n strings changed)

@github-actions github-actions Bot added frontend Frontend (React/TypeScript) backend Backend (Rust/Tauri) labels Nov 25, 2026

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,感谢您的贡献!

@farion1231
farion1231 merged commit 005f893 into farion1231:main Nov 26, 2026
12 checks passed
@farion1231

Copy link
Copy Markdown
Owner

已合并,感谢您的贡献!同名的 local / project 插件跨项目不再撞 React key、出现幽灵行,补上 projectPath 的展示和搜索也让多项目场景清楚了很多,修复了 #9962。

@jimpablo
jimpablo deleted the fix/plugins-duplicate-scope-keys branch November 26, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend (Rust/Tauri) frontend Frontend (React/TypeScript)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Plugins page leaves ghost rows and omits projectPath for multi-project local/project Claude plugins

2 participants