feat:Support hot reload after plugin load failure#5043
Merged
Soulter merged 4 commits intoAstrBotDevs:masterfrom Feb 13, 2026
Merged
feat:Support hot reload after plugin load failure#5043Soulter merged 4 commits intoAstrBotDevs:masterfrom
Soulter merged 4 commits intoAstrBotDevs:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体反馈:
- 在
handleReloadAllFailed中,loading_.value在检查dirNames.length之前就被设置为true,但如果没有失败的插件,会在没有重置它的情况下提前return,这样就有可能导致 loading 状态被卡住;可以把loading_.value = true移到提前返回检查之后,或者在返回之前确保它被重置。 - 模板中调用的是
@click="handleReloadAllFailed(isActive)",但handleReloadAllFailed的定义没有参数,也没有使用isActive,所以要么在模板中移除这个参数,要么修改函数签名以接收并使用它。
给 AI Agent 的提示
请根据以下代码评审意见进行修改:
## 整体评论
- 在 `handleReloadAllFailed` 中,`loading_.value` 在检查 `dirNames.length` 之前就被设置为 `true`,但如果没有失败的插件,会在没有重置它的情况下提前 `return`,这样就有可能导致 loading 状态被卡住;可以把 `loading_.value = true` 移到提前返回检查之后,或者在返回之前确保它被重置。
- 模板中调用的是 `@click="handleReloadAllFailed(isActive)"`,但 `handleReloadAllFailed` 的定义没有参数,也没有使用 `isActive`,所以要么在模板中移除这个参数,要么修改函数签名以接收并使用它。
## 单独评论
### 评论 1
<location> `dashboard/src/views/ExtensionPage.vue:1300-1302` </location>
<code_context>
+ color="error"
+ variant="tonal"
+ prepend-icon="mdi-refresh"
+ @click="handleReloadAllFailed(isActive)"
+ >
+ 尝试一键重载修复
</code_context>
<issue_to_address>
**suggestion:** 点击事件处理函数接收了 `isActive`,但 `handleReloadAllFailed` 没有接收或使用任何参数。
由于 `handleReloadAllFailed` 不接收任何参数,这里传入 `isActive` 实际上不会产生任何效果,还可能造成误导。根据预期行为,要么在模板中移除这个参数,要么更新函数签名以使用它。
```suggestion
prepend-icon="mdi-refresh"
@click="handleReloadAllFailed"
>
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- In
handleReloadAllFailed,loading_.valueis set totruebefore checkingdirNames.length, but if there are no failed plugins youreturnearly without resetting it, so the loading state can get stuck; move theloading_.value = trueafter the early-return check or ensure it is reset before returning. - The template calls
@click="handleReloadAllFailed(isActive)"buthandleReloadAllFailedis defined without parameters and does not useisActive, so either remove the argument from the template or update the function signature to accept and use it.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `handleReloadAllFailed`, `loading_.value` is set to `true` before checking `dirNames.length`, but if there are no failed plugins you `return` early without resetting it, so the loading state can get stuck; move the `loading_.value = true` after the early-return check or ensure it is reset before returning.
- The template calls `@click="handleReloadAllFailed(isActive)"` but `handleReloadAllFailed` is defined without parameters and does not use `isActive`, so either remove the argument from the template or update the function signature to accept and use it.
## Individual Comments
### Comment 1
<location> `dashboard/src/views/ExtensionPage.vue:1300-1302` </location>
<code_context>
+ color="error"
+ variant="tonal"
+ prepend-icon="mdi-refresh"
+ @click="handleReloadAllFailed(isActive)"
+ >
+ 尝试一键重载修复
</code_context>
<issue_to_address>
**suggestion:** The click handler is passed `isActive` but `handleReloadAllFailed` does not accept or use any parameters.
Since `handleReloadAllFailed` doesn’t take any parameters, passing `isActive` here has no effect and can be misleading. Either remove the argument in the template or update the function signature to use it, depending on the intended behavior.
```suggestion
prepend-icon="mdi-refresh"
@click="handleReloadAllFailed"
>
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Contributor
Author
|
@sourcery-ai review |
Contributor
There was a problem hiding this comment.
Hey - 我在这里留下了一些整体反馈:
- 在
StarManager.load中,failed_plugin_dict只会在加载失败时追加条目,但在每次加载开始时都不会被清空,这会导致在之后加载成功时仍然保留过期的失败记录;建议在重新尝试加载之前/之时清空它(或按插件移除对应条目),以便状态能够准确反映当前的失败情况。 - 新增的
/plugin/source/get-failed-plugins接口直接返回了plugin_manager.failed_plugin_dict;返回一个浅拷贝会更好,可以避免外部调用方无意中修改管理器的内部状态。 - 在前端中,
getExtensions目前会按顺序发起两个 HTTP 请求(先/plugin/get再/plugin/source/get-failed-plugins);可以使用Promise.all并行请求两者,从而降低扩展页面的感知延迟。
给 AI 智能体的提示
Please address the comments from this code review:
## Overall Comments
- In `StarManager.load`, `failed_plugin_dict` is only appended to on failures and never cleared at the beginning of a load pass, which can leave stale failure entries after a later successful load; consider clearing it (or removing entries per plugin) before/when re-attempting loads so the state accurately reflects current failures.
- The new `/plugin/source/get-failed-plugins` endpoint returns `plugin_manager.failed_plugin_dict` directly; returning a shallow copy instead would prevent accidental external mutation of internal manager state.
- On the frontend, `getExtensions` performs two sequential HTTP requests (`/plugin/get` then `/plugin/source/get-failed-plugins`); these can be requested in parallel with `Promise.all` to reduce perceived latency of the extensions page.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English
Hey - I've left some high level feedback:
- In
StarManager.load,failed_plugin_dictis only appended to on failures and never cleared at the beginning of a load pass, which can leave stale failure entries after a later successful load; consider clearing it (or removing entries per plugin) before/when re-attempting loads so the state accurately reflects current failures. - The new
/plugin/source/get-failed-pluginsendpoint returnsplugin_manager.failed_plugin_dictdirectly; returning a shallow copy instead would prevent accidental external mutation of internal manager state. - On the frontend,
getExtensionsperforms two sequential HTTP requests (/plugin/getthen/plugin/source/get-failed-plugins); these can be requested in parallel withPromise.allto reduce perceived latency of the extensions page.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `StarManager.load`, `failed_plugin_dict` is only appended to on failures and never cleared at the beginning of a load pass, which can leave stale failure entries after a later successful load; consider clearing it (or removing entries per plugin) before/when re-attempting loads so the state accurately reflects current failures.
- The new `/plugin/source/get-failed-plugins` endpoint returns `plugin_manager.failed_plugin_dict` directly; returning a shallow copy instead would prevent accidental external mutation of internal manager state.
- On the frontend, `getExtensions` performs two sequential HTTP requests (`/plugin/get` then `/plugin/source/get-failed-plugins`); these can be requested in parallel with `Promise.all` to reduce perceived latency of the extensions page.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Soulter
approved these changes
Feb 12, 2026
Member
|
或者是否可以做到载入失败的插件也显示在插件页,但是有相应载入失败的提示,也可以重新载入。这样是否自由度会高一些 |
Contributor
Author
这个逻辑没改,载入失败的插件会在插件页显示红色感叹号,点进去就是详细信息和重载提示 |
0f7c480 to
ca15230
Compare
Contributor
Author
很奇怪,报错的ruff文件我在这个pr里完全没动过,而且本地的ruff跑出来也没问题。 |
astrbot-doc-agent bot
pushed a commit
to AstrBotDevs/AstrBot-docs
that referenced
this pull request
Feb 13, 2026
|
Generated docs update PR (pending manual review): AI change summary:
Experimental bot notice:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modifications / 改动点
Relate to #5041
一:
astrbot/core/star/star_manager.py初始化时增加字典
self.failed_plugin_dict = {},方便后续热重载增加方法
reload_failed_plugin( self , dir_name ),通过调用load(self, specified_module_path=None, specified_dir_name=None)重载加载失败的插件 。在方法
load(self, specified_module_path=None, specified_dir_name=None)加载插件失败时,将相关信息写入self.failed_plugin_dict,记录相关插件信息。二:
astrbot/dashboard/routes/plugin.py增加请求路径
/plugin/reload-failed(POST),用于重载加载失败的插件,并且绑定reload_failed_plugins(self)方法。增加请求路径
/plugin/source/get-failed-plugins(GET),用于获取重载失败插件字典,并且绑定get_failed_plugins(self)方法。三:
dashboard/src/views/ExtensionPage.vue增加
handleReloadAllFailed函数,用于处理重载加载失败插件。调整
getExtensions函数,使其可以获得加载失败插件字典。更改前端组件,使其显示重载按钮。
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
添加支持识别和热重载加载失败的插件,并通过 API 和仪表板 UI 对外提供这一能力。
新功能:
改进:
Original summary in English
Summary by Sourcery
Add support for identifying and hot reloading plugins that failed to load, exposing this capability via API and the dashboard UI.
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
添加支持识别和热重载加载失败的插件,并通过 API 和仪表板 UI 对外提供这一能力。
新功能:
改进:
Original summary in English
Summary by Sourcery
Add support for identifying and hot reloading plugins that failed to load, exposing this capability via API and the dashboard UI.
New Features:
Enhancements: