Skip to content

Conversation

@1592363624
Copy link

@1592363624 1592363624 commented Oct 21, 2025

fixes #3117


Motivation / 动机

在WebUI界面添加 隐藏/显示 已禁用插件功能

Modifications / 改动点

image

Sourcery 总结

通过添加一个专门的切换控件、调整客户端过滤逻辑并扩展后端 API 以支持 hide_disabled 参数,实现在 WebUI 中隐藏禁用插件的功能。

新功能:

  • 在 WebUI 中添加一个切换按钮,用于隐藏或显示禁用插件
  • 在 ExtensionPage.vue 中基于 hideDisabled 状态引入前端过滤
  • 扩展插件检索 API,使其接受 hide_disabled 参数,并在请求时跳过禁用插件

改进:

  • 始终从后端获取所有插件,并在客户端应用过滤
  • 更新插件列表过滤逻辑,以结合保留插件和禁用插件的可见性设置
Original summary in English

Summary by Sourcery

Enable hiding of disabled plugins in the WebUI by adding a dedicated toggle control, adjusting the client-side filtering logic, and extending the backend API to support the hide_disabled parameter.

New Features:

  • Add a toggle button in the WebUI to hide or show disabled plugins
  • Introduce front-end filtering based on the hideDisabled state in ExtensionPage.vue
  • Extend the plugin retrieval API to accept a hide_disabled parameter and skip disabled plugins when requested

Enhancements:

  • Always fetch all plugins from the backend and apply filtering on the client side
  • Update the plugin list filtering logic to combine reserved and disabled plugin visibility settings

@auto-assign auto-assign bot requested review from Raven95676 and Soulter October 21, 2025 05:56
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.

你好 - 我已经审阅了你的修改,它们看起来很棒!

AI 代理提示
请处理此代码审查中的注释:

## 单独的评论

### 评论 1
<location> `astrbot/dashboard/routes/session_management.py:371-373` </location>
<code_context>
         """获取指定会话的插件配置信息"""
         try:
             session_id = request.args.get("session_id")
+            hide_disabled = request.args.get("hide_disabled", "false").lower() == "true"

             if not session_id:
</code_context>

<issue_to_address>
**建议:** 使用字符串比较解析布尔查询参数可能容易出错。

字符串比较可能无法处理客户端提供的所有可能的布尔表示。请使用专门的解析函数,以便更可靠地处理布尔查询参数。

```suggestion
        def parse_bool_query_param(param_value, default=False):
            if param_value is None:
                return default
            if isinstance(param_value, bool):
                return param_value
            value = str(param_value).strip().lower()
            return value in ("true", "1", "yes", "on")

        try:
            session_id = request.args.get("session_id")
            hide_disabled = parse_bool_query_param(request.args.get("hide_disabled"), default=False)
```
</issue_to_address>

Sourcery 对开源项目免费 - 如果您喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请在每个评论上点击 👍 或 👎,我将使用这些反馈来改进您的评论。
Original comment in English

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `astrbot/dashboard/routes/session_management.py:371-373` </location>
<code_context>
         """获取指定会话的插件配置信息"""
         try:
             session_id = request.args.get("session_id")
+            hide_disabled = request.args.get("hide_disabled", "false").lower() == "true"

             if not session_id:
</code_context>

<issue_to_address>
**suggestion:** Parsing boolean query parameters with string comparison can be error-prone.

String comparison may not handle all possible boolean representations from clients. Use a dedicated parsing function for more reliable handling of boolean query parameters.

```suggestion
        def parse_bool_query_param(param_value, default=False):
            if param_value is None:
                return default
            if isinstance(param_value, bool):
                return param_value
            value = str(param_value).strip().lower()
            return value in ("true", "1", "yes", "on")

        try:
            session_id = request.args.get("session_id")
            hide_disabled = parse_bool_query_param(request.args.get("hide_disabled"), default=False)
```
</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.

Comment on lines 372 to +373
try:
session_id = request.args.get("session_id")
hide_disabled = request.args.get("hide_disabled", "false").lower() == "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

建议: 使用字符串比较解析布尔查询参数可能容易出错。

字符串比较可能无法处理客户端提供的所有可能的布尔表示。请使用专门的解析函数,以便更可靠地处理布尔查询参数。

Suggested change
try:
session_id = request.args.get("session_id")
hide_disabled = request.args.get("hide_disabled", "false").lower() == "true"
def parse_bool_query_param(param_value, default=False):
if param_value is None:
return default
if isinstance(param_value, bool):
return param_value
value = str(param_value).strip().lower()
return value in ("true", "1", "yes", "on")
try:
session_id = request.args.get("session_id")
hide_disabled = parse_bool_query_param(request.args.get("hide_disabled"), default=False)
Original comment in English

suggestion: Parsing boolean query parameters with string comparison can be error-prone.

String comparison may not handle all possible boolean representations from clients. Use a dedicated parsing function for more reliable handling of boolean query parameters.

Suggested change
try:
session_id = request.args.get("session_id")
hide_disabled = request.args.get("hide_disabled", "false").lower() == "true"
def parse_bool_query_param(param_value, default=False):
if param_value is None:
return default
if isinstance(param_value, bool):
return param_value
value = str(param_value).strip().lower()
return value in ("true", "1", "yes", "on")
try:
session_id = request.args.get("session_id")
hide_disabled = parse_bool_query_param(request.args.get("hide_disabled"), default=False)

Copy link
Member

Choose a reason for hiding this comment

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

为什么要改这个文件?不是隐藏插件页的已禁用插件吗

Copy link
Author

Choose a reason for hiding this comment

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

是的呀,我搜索系统自带的 显示系统插件 这个按钮代码就是在这儿,难道改这里有问题吗
而且改完之后我测试了也没问题

@Soulter
Copy link
Member

Soulter commented Nov 1, 2025

这个 PR 存在的问题是前端修改的是 /api/plugin/get 路由,但是你却在后端改了 /session/update_plugin 路由。。。你真的测过吗

@Soulter
Copy link
Member

Soulter commented Nov 1, 2025

此外,如果你要在会话管理隐藏已禁用插件,就应该在会话管理的插件选择对话框中增加相关开关,而不是在插件页。。

@1592363624
Copy link
Author

这个 PR 存在的问题是前端修改的是 /api/plugin/get 路由,但是你却在后端改了 /session/update_plugin 路由。。。你真的测过吗

肯定测试过啊,你看那个截图,我自己用是正常的,难道是你理解错了功能吗。而且那个自带的按钮[显示系统插件]就是这样子写的,我是参考的那个显示系统插件功能写的

@LIghtJUNction LIghtJUNction requested a review from Copilot November 2, 2025 18:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to hide disabled plugins in both the dashboard frontend (Vue.js) and backend API. The feature allows users to toggle the visibility of disabled plugins in the extension management page.

Key changes:

  • Added a new "hide disabled plugins" toggle button in the extension page UI
  • Implemented frontend filtering logic to hide/show disabled plugins based on the toggle state
  • Added backend API support for filtering disabled plugins (though frontend filtering is used by default)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
dashboard/src/views/ExtensionPage.vue Added hideDisabled state, toggle function, filtering logic, and UI button for hiding disabled plugins
dashboard/src/i18n/locales/zh-CN/features/extension.json Added Chinese translations for "hide disabled plugins" and "show disabled plugins" buttons
astrbot/dashboard/routes/session_management.py Added hide_disabled query parameter support and filtering logic in get_session_plugins endpoint

result = result.filter(ext => !ext.reserved);
}
if (!hideDisabled.value) {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The logic is inverted. When hideDisabled is false (meaning 'show all plugins'), the code filters to only show activated plugins, which is incorrect. It should be if (hideDisabled.value) to filter out disabled plugins when the toggle is enabled.

Suggested change
if (!hideDisabled.value) {
if (hideDisabled.value) {

Copilot uses AI. Check for mistakes.
import { useI18n, useModuleI18n } from '@/i18n/composables';
import {pinyin} from 'pinyin-pro';
import {useCommonStore} from '@/stores/common';
import {useI18n, useModuleI18n} from '@/i18n/composables';
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Import formatting changes (removing spaces after braces) are inconsistent with typical JavaScript/Vue style conventions. Most style guides recommend spaces after opening braces in import statements, e.g., import { pinyin } from 'pinyin-pro'. This change appears to be unrelated to the feature being added.

Suggested change
import {useI18n, useModuleI18n} from '@/i18n/composables';
import { useI18n, useModuleI18n } from '@/i18n/composables';

Copilot uses AI. Check for mistakes.
import {useI18n, useModuleI18n} from '@/i18n/composables';
import { ref, computed, onMounted, reactive } from 'vue';
import {computed, onMounted, reactive, ref} from 'vue';
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The alphabetical reordering of Vue imports and removal of spaces is inconsistent with the typical JavaScript/Vue style conventions and appears unrelated to the feature being added. Consider keeping imports in their original order or applying consistent formatting across the entire file.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]希望加个隐藏禁用插件的选项

2 participants