Skip to content

Conversation

@clown145
Copy link
Contributor

@clown145 clown145 commented Jan 5, 2026

feat: optimize plugin update changelog feature, refactor to reuse ReadmeDialog and support independent view entry

为插件系统添加了更新日志展示功能,让用户在更新插件后能及时了解改动内容。

Modifications / 改动点

  • 后端 (Backend):

    • plugin.py 中实现了 /api/plugin/changelog 接口,支持从插件根目录读取本地 CHANGELOG.md (及其变体文件名)。
  • 前端 (Frontend):

    • 组件复用: 重构了 ReadmeDialog.vue,通过新增的 mode 属性支持 readmechangelog 两种展示模式,减少冗余代码。
    • 交互流程优化:
      • 插件更新成功后自动弹出更新日志窗口。
      • 插件首次安装完成后保持原有的 README 弹出逻辑。
    • 独立查看入口: 在 ExtensionCard.vue 的更多操作菜单中新增了“查看更新日志”选项,支持随时查看。
  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

chrome_7Mp2nMN90s chrome_qBH35N88Je
  • 经手动测试,插件更新成功后能正确对应弹出本地 CHANGELOG.md 内容。
  • 菜单中的“查看更新日志”功能正常工作。
  • 首次安装流程仍能正常触发 README 展示。

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

为扩展系统添加插件更新日志支持,并重构 Readme 对话框,以便在 README 和更新日志视图之间复用。

新功能:

  • 使用新的后端端点读取本地 CHANGELOG 文件,在仪表盘中显示插件更新日志。
  • 允许用户从扩展卡片的操作菜单中打开插件更新日志,并在插件更新后自动显示。

增强改进:

  • 重构 Readme 对话框组件,使其支持多种模式(README 和更新日志),并共享渲染逻辑和状态处理。
  • 在扩展页面及相关组件中应用一致的代码风格,并进行细微的用户体验优化。
Original summary in English

Summary by Sourcery

Add plugin changelog support to the extension system and refactor the Readme dialog for reuse across README and changelog views.

New Features:

  • Display plugin update changelogs in the dashboard using a new backend endpoint to read local CHANGELOG files.
  • Allow users to open a plugin changelog from the extension card’s actions menu and automatically show it after plugin updates.

Enhancements:

  • Refactor the Readme dialog component to support multiple modes (README and changelog) with shared rendering and status handling.
  • Apply consistent code style and minor UX polish across the extensions page and related components.

…dmeDialog and support independent view entry
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 5, 2026
@auto-assign auto-assign bot requested review from Raven95676 and Soulter January 5, 2026 15:14
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些整体性的反馈:

  • 在 ReadmeDialog 中,error 分支现在渲染的是通用的「空状态」文案,而不是实际的错误信息,这会让调试真实故障(网络/服务器错误)变得更困难;建议保留并单独展示后端/异常信息,与「无内容」的空状态区分开来。
  • 新增的 /api/plugin/changelog 接口在没有 changelog 文件时会返回错误,UI 会把它当作通用失败来处理;可能更清晰的做法是返回 ok,但内容为空或带上一个明确的标记,以便前端可以渲染专门的「暂无更新日志」状态,而不是错误。
  • ExtensionCard 中的「查看更新日志」/viewChangelog 项目前对所有已安装插件都显示,而不管是否真的存在 changelog;你可能需要根据条件展示这一操作(例如仅在 has_update 为 true 或探测成功之后)以避免用户每次点开都只看到一个「缺少更新日志」的状态。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- In ReadmeDialog, the `error` branch now renders the generic empty-state copy instead of the actual error message, which makes debugging real failures (network/server errors) harder; consider preserving and displaying the backend/exception message separately from the “no content” empty state.
- The new `/api/plugin/changelog` endpoint returns an error when no changelog file exists, which the UI treats as a generic failure; it may be clearer to return `ok` with empty content or a specific flag so the frontend can render a dedicated “no changelog available” state instead of an error.
- The “查看更新日志”/`viewChangelog` entry in ExtensionCard is shown for all installed plugins regardless of whether a changelog actually exists; you might want to conditionally show this action (e.g. only when `has_update` is true or after a successful probe) to avoid users opening a dialog that always shows a missing-changelog state.

## Individual Comments

### Comment 1
<location> `dashboard/src/components/shared/ReadmeDialog.vue:170-179` </location>
<code_context>
           <!-- 最多一行 -->
-          <div class="text-caption"
-            style="color: gray; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 84px;">
+          <div
+            class="text-caption"
+            style="
</code_context>

<issue_to_address>
**issue (bug_risk):** Error state no longer surfaces the backend error message and is indistinguishable from the empty state.

In the `v-else-if="error"` branch, the `error` string is ignored and we always show `modeConfig.emptyTitle` / `modeConfig.emptySubtitle` with a warning icon. This hides useful failure details (e.g. network or permission errors) and makes the view nearly identical to the empty state. Please either surface `error` as the main message with mode-specific copy as secondary context, or give the error state a clearly distinct visual treatment from the empty state.
</issue_to_address>

Sourcery 对开源项目免费 —— 如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In ReadmeDialog, the error branch now renders the generic empty-state copy instead of the actual error message, which makes debugging real failures (network/server errors) harder; consider preserving and displaying the backend/exception message separately from the “no content” empty state.
  • The new /api/plugin/changelog endpoint returns an error when no changelog file exists, which the UI treats as a generic failure; it may be clearer to return ok with empty content or a specific flag so the frontend can render a dedicated “no changelog available” state instead of an error.
  • The “查看更新日志”/viewChangelog entry in ExtensionCard is shown for all installed plugins regardless of whether a changelog actually exists; you might want to conditionally show this action (e.g. only when has_update is true or after a successful probe) to avoid users opening a dialog that always shows a missing-changelog state.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In ReadmeDialog, the `error` branch now renders the generic empty-state copy instead of the actual error message, which makes debugging real failures (network/server errors) harder; consider preserving and displaying the backend/exception message separately from the “no content” empty state.
- The new `/api/plugin/changelog` endpoint returns an error when no changelog file exists, which the UI treats as a generic failure; it may be clearer to return `ok` with empty content or a specific flag so the frontend can render a dedicated “no changelog available” state instead of an error.
- The “查看更新日志”/`viewChangelog` entry in ExtensionCard is shown for all installed plugins regardless of whether a changelog actually exists; you might want to conditionally show this action (e.g. only when `has_update` is true or after a successful probe) to avoid users opening a dialog that always shows a missing-changelog state.

## Individual Comments

### Comment 1
<location> `dashboard/src/components/shared/ReadmeDialog.vue:170-179` </location>
<code_context>
           <!-- 最多一行 -->
-          <div class="text-caption"
-            style="color: gray; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 84px;">
+          <div
+            class="text-caption"
+            style="
</code_context>

<issue_to_address>
**issue (bug_risk):** Error state no longer surfaces the backend error message and is indistinguishable from the empty state.

In the `v-else-if="error"` branch, the `error` string is ignored and we always show `modeConfig.emptyTitle` / `modeConfig.emptySubtitle` with a warning icon. This hides useful failure details (e.g. network or permission errors) and makes the view nearly identical to the empty state. Please either surface `error` as the main message with mode-specific copy as secondary context, or give the error state a clearly distinct visual treatment from the empty state.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the feature:plugin The bug / feature is about AstrBot plugin system. label Jan 5, 2026
@clown145
Copy link
Contributor Author

clown145 commented Jan 5, 2026

建议在插件开发规范中推荐 CHANGELOG.md 的折叠布局逻辑

优化建议:由于 Dashboard 的更新日志弹窗空间有限,为了让用户在更新完成后能迅速获取“当前版本”的关键变化,建议在插件编写规范中加入如下建议:

  1. 最新版本置顶:始终将最新的 Release Notes 放置在文件最上方,不进行折叠。
  2. 历史记录折叠:利用 HTML 的 <details><summary> 标签将旧版本的更新日志包裹起来。

这种做法可以极大提升弹窗展示的直观性,避免用户在历史数据中盲目滚动。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 6, 2026
@Soulter Soulter merged commit 9322218 into AstrBotDevs:master Jan 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:plugin The bug / feature is about AstrBot plugin system. lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants