feat: 支持关闭插件搜索栏推送#520
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new feature allowing users to toggle search bar push notifications ('main push') for individual plugins. It implements the UI toggle in the plugin detail toolbar, adds IPC handlers and backend APIs to persist this setting, and updates the command store to filter out commands from disabled main push plugins. Additionally, it ensures that plugin settings (including the new main push configuration) are cleaned up upon uninstallation. The review feedback highlights two performance optimization opportunities: avoiding redundant array normalization in commandDataStore.ts inside a loop, and preventing duplicate normalization calls within PluginsAPI.removePluginNameConfigs by directly filtering the already normalized list.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const isMainPush = | ||
| !!feature.mainPush && | ||
| isMainPushPluginEnabled(plugin.name, disabledMainPushPluginNames.value) |
There was a problem hiding this comment.
性能优化建议
disabledMainPushPluginNames.value 已经是经过 normalizeConfigList 规范化后的 string[] 数组。在 buildPluginCommandItems 的循环中,对每个插件的每个 feature 都调用 isMainPushPluginEnabled 会导致重复调用 normalizeConfigList,从而产生不必要的数组分配和过滤操作(垃圾回收压力)。
建议直接使用 !disabledMainPushPluginNames.value.includes(plugin.name) 进行判断,避免重复规范化。
| const isMainPush = | |
| !!feature.mainPush && | |
| isMainPushPluginEnabled(plugin.name, disabledMainPushPluginNames.value) | |
| const isMainPush = | |
| !!feature.mainPush && | |
| !disabledMainPushPluginNames.value.includes(plugin.name) |
| private removePluginNameConfigs(keys: string[], pluginName: string): void { | ||
| for (const key of keys) { | ||
| const current = databaseAPI.dbGet(key) | ||
| const normalized = normalizeConfigList(current) | ||
| const next = removePluginNameFromSettingList(current, pluginName) | ||
| if (next.length !== normalized.length) { | ||
| databaseAPI.dbPut(key, next) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
代码简化与性能优化建议
在 removePluginNameConfigs 中,normalizeConfigList(current) 已经被调用了一次。接着调用 removePluginNameFromSettingList(current, pluginName) 会在内部再次调用 normalizeConfigList(current),造成了重复解析。
可以直接使用 normalized.filter 来生成 next 数组,这样既简化了代码,又避免了重复的规范化计算。此外,如果应用此优化,文件顶部的 removePluginNameFromSettingList 导入也可以一并移除。
| private removePluginNameConfigs(keys: string[], pluginName: string): void { | |
| for (const key of keys) { | |
| const current = databaseAPI.dbGet(key) | |
| const normalized = normalizeConfigList(current) | |
| const next = removePluginNameFromSettingList(current, pluginName) | |
| if (next.length !== normalized.length) { | |
| databaseAPI.dbPut(key, next) | |
| } | |
| } | |
| } | |
| private removePluginNameConfigs(keys: string[], pluginName: string): void { | |
| for (const key of keys) { | |
| const current = databaseAPI.dbGet(key) | |
| const normalized = normalizeConfigList(current) | |
| const next = normalized.filter((name) => name !== pluginName) | |
| if (next.length !== normalized.length) { | |
| databaseAPI.dbPut(key, next) | |
| } | |
| } | |
| } |
b1835e8 to
3497c6e
Compare
3497c6e to
14b767f
Compare
变更内容
disabledMainPushPlugin字段动机
很多插件自带 main push 功能,目前无法自主关闭。当插件很多时,搜索栏信息会过多。
应该支持关闭单个插件 main push 的选项,
截图