Skip to content

fix(dashboard): remove duplicate default option from bot config select - #10542

Open
SweetenedSuzuka wants to merge 1 commit into
AstrBotDevs:masterfrom
SweetenedSuzuka:fix/10481-duplicate-default-config-option
Open

SweetenedSuzuka wants to merge 1 commit into
AstrBotDevs:masterfrom
SweetenedSuzuka:fix/10481-duplicate-default-config-option

Conversation

@SweetenedSuzuka

@SweetenedSuzuka SweetenedSuzuka commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

改动

机器人 → 任意平台 → 会话配置 → 「此机器人的默认配置」下拉框出现两项,都指向同一个配置文件:一项显示为「系统默认配置(default)」,另一项显示为 default。

原因:后端 AstrBotConfigManager.get_conf_list() 每次都把内置的默认配置文件追加到列表末尾(astrbot/core/astrbot_config_mgr.py:188),而 DEFAULT_CONFIG_CONF_INFO 的 id 和 name 都写成了 "default"(:25-29)。前端 PlatformEditor.vue 又把表示「系统默认」的 SYSTEM_DEFAULT_CONFIG 加在这个列表前面(:491-497),下拉框按 name 显示选项文字(:132),没有对 default 单独处理,于是同一个配置出现两项。代码里也写明两者是同一个配置(:450)。

改动:

  1. defaultConfigOptions 拼出选项列表时跳过 id 为 default 的配置文件,顶部下拉只剩一项「系统默认配置(default)」。判断用 id 不用 name:id 由后端生成 uuid4 并禁止改动(astrbot_config_mgr.py:231-232、:281-282),name 用户可以改。
  2. loadBotRoutes() 读到指向 default 的机器人默认路由时,把值改写为 SYSTEM_DEFAULT_CONFIG,使下拉框的选中项与列表里的选项一致,显示文字也统一。

不改的部分:configProfiles 保留完整列表。三个路由选择器(:211/:280/:342)和 addAdvancedRoute()(:799)都要能选中 default 这个已保存的值,初始化 pendingConfigId 时也用它(:644-649)。后端 get_conf_list() 不改,ConfigPage.vue、AddNewPlatform.vue、ConfigSelector.vue 都靠它列出默认配置文件。

  • 这不是一个破坏性变更。

运行截图或测试结果

CI 会执行的检查,本地都已通过:

  • cd dashboard && pnpm run i18n:check → 通过。四份语言文件(zh-CN、en-US、ru-RU、ja-JP)的 key 集合完全一致,各 4130 个,没有缺失。
  • cd dashboard && pnpm run build(其中包含 vue-tsc --noEmit)→ 通过,✓ built in 22.05s。
  • cd dashboard && pnpm exec vue-tsc --noEmit → 通过。

Modifications

Under Bots → any platform → Session config → "Default configuration for this bot", the select listed two entries that both point at the same configuration profile: one shown as "System default configuration (default)" and one shown as default.

Cause: the backend AstrBotConfigManager.get_conf_list() appends the built-in default configuration profile to the end of the list every time (astrbot/core/astrbot_config_mgr.py:188), and DEFAULT_CONFIG_CONF_INFO has both id and name set to "default" (:25-29). The frontend PlatformEditor.vue prepends SYSTEM_DEFAULT_CONFIG, which stands for "system default", to that list (:491-497), and the select shows option text from name (:132) with no separate handling for default, so the same configuration appeared twice. The code itself states that the two are the same configuration (:450).

Changes:

  1. When defaultConfigOptions builds the option list, it skips the configuration profile whose id is default, so the top select keeps only "System default configuration (default)". The check uses id, not name: the backend generates id as a uuid4 and rejects changes to it (astrbot_config_mgr.py:231-232, :281-282), while users can rename name.
  2. When loadBotRoutes() reads a bot default route that points at default, it rewrites the value to SYSTEM_DEFAULT_CONFIG, so the selected item matches the options in the list and the label is consistent.

Not changed: configProfiles keeps the full list. The three routing selects (:211/:280/:342) and addAdvancedRoute() (:799) must be able to select the saved value default, and initializing pendingConfigId uses it as well (:644-649). The backend get_conf_list() is unchanged; ConfigPage.vue, AddNewPlatform.vue and ConfigSelector.vue rely on it to list the default configuration profile.

  • This is NOT a breaking change.

Screenshots or Test Results

Checks that CI runs, all passing locally:

  • cd dashboard && pnpm run i18n:check → pass. The four locale files (zh-CN, en-US, ru-RU, ja-JP) hold exactly the same key set, 4130 keys each, with none missing.
  • cd dashboard && pnpm run build (which includes vue-tsc --noEmit) → pass, ✓ built in 22.05s.
  • cd dashboard && pnpm exec vue-tsc --noEmit → pass.

检查清单

  • 这是一处缺陷修复,没有新增功能,不需要事先讨论。
  • 改动经过检查,验证步骤与结果已写在上方。
  • 没有改动 WebUI 的入口、页面结构或界面术语,不需要更新 docs/zh、docs/en。
  • 没有引入新依赖。
  • 没有引入恶意代码。

Checklist

  • This is a bug fix with no new feature, so no prior discussion is needed.
  • The change is checked, with the verification steps and results above.
  • No WebUI entry, page structure or interface term changed, so no docs/zh or docs/en update is needed.
  • No new dependencies introduced.
  • No malicious code introduced.

Fixes #10481

Summary by Sourcery

Bug Fixes:

  • Remove the duplicate built-in default profile from the bot’s default configuration selector and normalize saved default routes to the system-default option.

The "Default config for this bot" select listed the same configuration
twice: the localized "System default configuration (default)" sentinel,
plus the raw "default" profile that the backend always appends to
GET /config-profiles.

get_conf_list() appends DEFAULT_CONFIG_CONF_INFO unconditionally
(astrbot/core/astrbot_config_mgr.py:188), whose id and name are both the
literal "default" (:25-29). PlatformEditor concatenated that list with
its own sentinel (:491-497) and rendered item-title="name" (:132) with
no special case, so the two entries were indistinguishable. The
component already treats them as equivalent (:450).

Filter the real id === "default" profile out of the top selector only.
Filter by id, not name: id is generated with uuid4 and is protected by
the backend (:231-232, :281-282), whereas name can be changed through
the API. The three routing selects (:211/:280/:342) and
addAdvancedRoute() (:799) keep the full list, because they need
"default" as a persisted value, as does the pendingConfigId fallback
(:644-649).

Also normalize a historical fallback route pointing at the real
"default" profile to the sentinel in loadBotRoutes(), so the selection
matches the options actually offered and the label stays localized.
Vuetify renders a value missing from items as its own raw text rather
than blanking the field (vuetify/lib/composables/list-items.mjs:72), so
this is about consistency, not about avoiding an empty field.

The backend is unchanged: ConfigPage, AddNewPlatform and ConfigSelector
rely on the real default profile being listed.

Verified: pnpm run i18n:check and pnpm run build (vue-tsc --noEmit)
both pass.

@sourcery-ai sourcery-ai Bot left a comment

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.

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

Sourcery assessment

Needs a human reviewer. If the sentinel does not resolve to the same configuration as the built-in default profile, loading a saved fallback this way could show the wrong selection and persist that choice when the route is saved. The affected route configuration is bounded and can be corrected, but may outlive a revert.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
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.

平台默认配置下拉框出现重复的 default 选项

1 participant