feat(plugins): reload linked plugins when their files change (#7888)

Plugins linked with openidea-plugin link are read in place, but edits showed only after Reload. Each linked folder is now watched (.git, target, node_modules and editor temp files ignored); a change wakes the plugin event pump, which reloads the plugin under the lifecycle lock. Installed and project plugins are not watched. A reloaded plugin that provides the selected theme restyles in place: the theme setting is reconciled after the contribution swap instead of in between, so the IDE no longer drops to the built-in theme.

Co-authored-by: Bruno0416 <[email protected]>
Цей коміт міститься в:
Bruno Valladares authored and GitHub committed 2026-12-04 09:10:21 +08:00
1 джерело ab08c3d245
коміт 5bfdaf679d
12 files changed
+490 -21

No files matched your search

+6 -3
Переглянути файл
@@ -133,9 +133,12 @@ There is no build step: the package is the folder.
To iterate without reinstalling, link the folder with `openidea-plugin link` (it is read in
place), or put or symlink it in `<project>/.openidea/plugins/<name>/` of a trusted project.
Then press **Reload** on the plugin, or run the **Reload Plugins** action, to pick up your
edits. If a file or value is invalid, **Settings › Plugins** shows the load error with the
file and line.
A linked plugin reloads by itself shortly after any file in its folder changes, so a theme
file rewritten by a script (a wallpaper colour generator, say) restyles the IDE straight away,
including when it is the theme in use. A project plugin does not: press **Reload** on it, or run
the **Reload Plugins** action. **Reload** also works for linked plugins. If a file or value is
invalid, **Settings › Plugins** shows the load error with the file and line; the next valid
save loads it again.
To share a theme, publish it like any plugin; see [Packaging](/en/plugins/publishing/packaging).
+1 -1
Переглянути файл
@@ -173,7 +173,7 @@ The [`settings-controls` fixture](https://github.com/l0ng-ai/openidea/tree/main/
## Reload, update and roll back
- **Reload while developing:** select the plugin in **Settings › Plugins** and click **Reload from disk**, or run the **Reload Plugins** action. Linked plugins are read from their folder, so a rebuild plus reload picks up new code and manifest changes.
- **Reload while developing:** select the plugin in **Settings › Plugins** and click **Reload from disk**, or run the **Reload Plugins** action. Linked plugins are read from their folder, so a rebuild plus reload picks up new code and manifest changes. Linked plugins also reload by themselves shortly after any file in their folder changes (a rebuilt `dist/plugin.wasm`, a regenerated theme), ignoring `.git`, `target`, `node_modules` and editor temp files. If the plugin no longer loads, **Settings › Plugins** shows the error and the next valid save loads it again. Installed and project plugins are not watched; reload those by hand.
- **Updates:** the IDE checks the marketplace daily. When it finds newer versions of installed plugins it says so once, with **Update All**; the gear menu has **Update All Plugins** too. An update that asks for nothing new keeps the existing grants.
- **Versions on disk:** installed plugins live in `<app-data>/plugins/<id>/<version>/` with an `active` pointer that is switched only once the new version is in place. If an update's code fails to start the first time, the IDE rolls back to the previous version automatically and tells you why. **Roll Back to `<version>`** in the plugin's details does it by hand.
- **Disable and uninstall:** disabling stops the code and withdraws its contributions; storage stays. Uninstalling removes the plugin, its storage and its private directory.
+3 -2
Переглянути файл
@@ -117,8 +117,9 @@ editor-scheme = "themes/harbor-night.scheme.json" # 可选
</Steps>
想不重新安装就反复修改,可以用 `openidea-plugin link` 链接文件夹(直接从原处读取),或者把它放进(或软链接到)受信任项目的
`<project>/.openidea/plugins/<name>/`。之后在插件上点 **重新加载**,或执行 **重新加载插件** 动作,即可加载修改。
文件或取值无效时,**设置 › 插件** 会显示加载错误以及所在文件和行号。
`<project>/.openidea/plugins/<name>/`。链接的插件会在其文件夹中的任何文件变化后不久自动重新加载,所以脚本(例如根据壁纸生成配色的工具)重写主题文件后,IDE
会立即换色,正在使用的主题也一样。项目插件不会自动重新加载:在插件上点 **重新加载**,或执行 **重新加载插件** 动作。链接的插件也可以手动 **重新加载**。
文件或取值无效时,**设置 › 插件** 会显示加载错误以及所在文件和行号;下一次有效保存后会重新加载。
分享主题的方式与其他插件相同,见 [打包](/zh/plugins/publishing/packaging)。
+1 -1
Переглянути файл
@@ -173,7 +173,7 @@ API 1.3 增加了多页设置(`[[contributes.settings.pages]]`)、分组、
## 重新加载、更新与回滚
- **开发时重新加载:** 在 **设置 › 插件** 中选中插件并点击 **从磁盘重新加载**,或运行 **重新加载插件** 操作。链接的插件从其文件夹读取,所以重新构建后再加载就能用上新的代码和清单。
- **开发时重新加载:** 在 **设置 › 插件** 中选中插件并点击 **从磁盘重新加载**,或运行 **重新加载插件** 操作。链接的插件从其文件夹读取,所以重新构建后再加载就能用上新的代码和清单。链接的插件还会在其文件夹中的任何文件变化后不久自动重新加载(重新构建的 `dist/plugin.wasm`、重新生成的主题),`.git`、`target`、`node_modules` 和编辑器临时文件除外。插件无法加载时,**设置 › 插件** 会显示错误,下一次有效保存后会重新加载。已安装的插件和项目插件不会被监视,需要手动重新加载。
- **更新:** IDE 每天检查一次插件市场。发现已安装插件有新版本时会提示一次,并提供 **全部更新**;齿轮菜单里也有 **更新全部插件**。不要求新能力的更新沿用已有授权。
- **磁盘上的版本:** 已安装的插件位于 `<app-data>/plugins/<id>/<version>/`,有一个 `active` 指针,只有新版本完全就位后才会切换。更新后的代码第一次启动就失败时,IDE 会自动回滚到之前的版本并告诉你原因。插件详情中的 **回滚到 `<version>`** 可以手动回滚。
- **禁用与卸载:** 禁用会停止代码并撤回其贡献,存储保留。卸载会删除插件、它的存储和私有目录。