Skip to content

fix(console): use toast for pip-install error display#8462

Open
xxynet wants to merge 2 commits into
AstrBotDevs:masterfrom
xxynet:fix/pip-install-toast-error
Open

fix(console): use toast for pip-install error display#8462
xxynet wants to merge 2 commits into
AstrBotDevs:masterfrom
xxynet:fix/pip-install-toast-error

Conversation

@xxynet
Copy link
Copy Markdown

@xxynet xxynet commented May 31, 2026

Fixes the issue where the pip-install dialog in ConsolePage displayed error messages as unstyled inline text instead of using the standard toast notification pattern.

Closes #8468

Modifications / 改动点

  • dashboard/src/views/ConsolePage.vue:

    • Imported useToast from @/utils/toast
    • Removed inline <small>{{ status }}</small> element and unused status data field
    • Rewrote pipInstall() to use toast.success() / toast.error() instead
    • Added res.data.status check to distinguish ok/error responses
  • This is NOT a breaking change. / 这不是一个破坏性变更。

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

Before: Error message "缺少参数 package 或不合法。" displayed as unstyled small text inside the dialog with no color differentiation.

After:

  • Empty package → red snackbar at the top: "缺少参数 package 或不合法。"
  • Valid package (e.g. requests) → green snackbar: "安装成功。", dialog auto-closes

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了"验证步骤"和"运行截图"

  • 🤓 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.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

The pip-install dialog displayed error messages as unstyled inline
<small> text with no color differentiation from success messages.
Replaced with useToast() to show errors as red snackbar, consistent
with the rest of the dashboard.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:webui The bug / feature is about webui(dashboard) of astrbot. labels May 31, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the pip installation feedback mechanism in ConsolePage.vue by replacing the inline status text with toast notifications using useToast. A critical issue was identified in the feedback where the code checks for res.data.status === 'ok', but the backend actually returns 'success' on successful operations. This mismatch would cause successful installations to incorrectly trigger an error toast.

this.status = res.data.message;
setTimeout(() => {
this.status = '';
if (res.data.status === 'ok') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The backend Response class (as seen in astrbot/dashboard/routes/update.py line 165) uses "success" as the status string for successful responses, rather than "ok". Checking for res.data.status === 'ok' will evaluate to false even on successful installations, causing the error toast to be shown instead.\n\nPlease update the check to use 'success' to match the backend response status.

          if (res.data.status === 'success') {

Copy link
Copy Markdown
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 - I've left some high level feedback:

  • The useToast import is added in the <script setup> block but used inside the options methods block, which has its own scope; you should import and initialize useToast in the same script block where pipInstall lives (or pass a toast handler in) to avoid a runtime/build-time reference error.
  • The fallback toast messages (e.g. '安装成功。', '安装失败。', '请求失败。') are hardcoded strings; consider sourcing these from the existing i18n (tm) namespace for consistency with the rest of the console.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `useToast` import is added in the `<script setup>` block but used inside the options `methods` block, which has its own scope; you should import and initialize `useToast` in the same script block where `pipInstall` lives (or pass a toast handler in) to avoid a runtime/build-time reference error.
- The fallback toast messages (e.g. `'安装成功。'`, `'安装失败。'`, `'请求失败。'`) are hardcoded strings; consider sourcing these from the existing `i18n` (`tm`) namespace for consistency with the rest of the console.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 缺少参数 package 或不合法提示样式问题

1 participant