Repository navigation
fix(dashboard): remove duplicate default option from bot config select - #10542
Open
SweetenedSuzuka wants to merge 1 commit into
Open
SweetenedSuzuka wants to merge 1 commit into
SweetenedSuzuka wants to merge 1 commit into
Conversation
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.
Contributor
There was a problem hiding this comment.
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.
This branch has not been deployed
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.
改动
机器人 → 任意平台 → 会话配置 → 「此机器人的默认配置」下拉框出现两项,都指向同一个配置文件:一项显示为「系统默认配置(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)。改动:
defaultConfigOptions拼出选项列表时跳过id为default的配置文件,顶部下拉只剩一项「系统默认配置(default)」。判断用id不用name:id由后端生成uuid4并禁止改动(astrbot_config_mgr.py:231-232、:281-282),name用户可以改。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), andDEFAULT_CONFIG_CONF_INFOhas bothidandnameset to"default"(:25-29). The frontendPlatformEditor.vueprependsSYSTEM_DEFAULT_CONFIG, which stands for "system default", to that list (:491-497), and the select shows option text fromname(:132) with no separate handling fordefault, so the same configuration appeared twice. The code itself states that the two are the same configuration (:450).Changes:
defaultConfigOptionsbuilds the option list, it skips the configuration profile whoseidisdefault, so the top select keeps only "System default configuration (default)". The check usesid, notname: the backend generatesidas auuid4and rejects changes to it (astrbot_config_mgr.py:231-232,:281-282), while users can renamename.loadBotRoutes()reads a bot default route that points atdefault, it rewrites the value toSYSTEM_DEFAULT_CONFIG, so the selected item matches the options in the list and the label is consistent.Not changed:
configProfileskeeps the full list. The three routing selects (:211/:280/:342) andaddAdvancedRoute()(:799) must be able to select the saved valuedefault, and initializingpendingConfigIduses it as well (:644-649). The backendget_conf_list()is unchanged;ConfigPage.vue,AddNewPlatform.vueandConfigSelector.vuerely on it to list the default configuration profile.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 includesvue-tsc --noEmit) → pass,✓ built in 22.05s.cd dashboard && pnpm exec vue-tsc --noEmit→ pass.检查清单
docs/zh、docs/en。Checklist
docs/zhordocs/enupdate is needed.Fixes #10481
Summary by Sourcery
Bug Fixes: