Repository navigation
feat(chatui): manage subagents from ChatUI settings - #11630
Open
liquidtoy001 wants to merge 2 commits into
Open
liquidtoy001 wants to merge 2 commits into
liquidtoy001 wants to merge 2 commits into
Conversation
ChatUI had no way to reach the subagent settings, which AstrBotDevs#11053 moved into each configuration file (Config -> AI -> Capabilities -> Subagents). Settings gains a Subagents page for the configuration the current conversation uses: the subagent switch and the specialized agent selector, reusing AgentConfigSelector and its AgentConfigManager dialog for creating, editing and deleting agents. Changes are saved through the existing config profile API (read, change agent.config.subagents, write back), so no backend change. Configurations that do not use AstrBot's built-in AI show a note instead. The input's + menu is now eager in ChatUI so ConfigSelector resolves the open conversation's configuration on load; before, the stored value could still be the previous page's choice until the menu was opened. The config page's test chat keeps the menu lazy and hides the page, since that page already shows the setting and saving there would overwrite changes made here.
Contributor
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/src/components/chat/ChatInput.vue" line_range="205" />
<code_context>
offset="8"
location="top start"
:close-on-content-click="false"
+ :eager="!props.configId"
>
<template v-slot:activator="{ props: activatorProps }">
</code_context>
<issue_to_address>
**Conversation profile binding is overwritten**
When the eager selector initializes while the chat session ID is empty, `ConfigSelector` marks a sync as pending, then `syncSelectionForSession()` applies the previously stored profile when the existing session becomes available instead of resolving the session’s route. The conversation’s profile binding is overwritten.
Prevent the selector from syncing a stored selection to a session until that session’s route has been resolved.
</issue_to_address>
### Comment 2
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="356" />
<code_context>
+ ...config.agent.config.subagents,
+ ...subagents.value,
+ };
+ const res = await configProfileApi.update(subagentConfigId.value, config);
+ if (res.data.status !== "ok") throw new Error(res.data.message || "");
+ } catch (err: any) {
</code_context>
<issue_to_address>
**Pending save writes to another profile**
When a save for profile A is awaiting its read while the user switches to profile B and the settings load updates `subagentConfigId`, the save reads one profile but uses the mutable `subagentConfigId` again for the update; after the user switches profiles, it can write the first profile's full configuration into the second profile.
Capture the profile ID once at the start of `saveSubagents` and use that captured ID for both requests.
</issue_to_address>
### Comment 3
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="315" />
<code_context>
+ if (!shown) return;
+ subagentError.value = "";
+ // ConfigSelector stores the configuration resolved for the current conversation.
+ const configId = getStoredSelectedChatConfigId();
+ try {
+ const [profile, profiles] = await Promise.all([
</code_context>
<issue_to_address>
**Settings load for the wrong profile**
When subagents opens before `ConfigSelector` finishes resolving the current conversation’s route, `getStoredSelectedChatConfigId()` returns the previous stored profile ID, so the settings watcher loads that profile and later saves changes to it; the selector’s later update does not refresh the open settings page. The user sees and changes the wrong profile’s settings.
Wait for the current conversation’s route resolution and use its resolved profile ID before loading Subagents settings.
Also at `dashboard/src/components/chat/ChatSettingsDialog.vue:337`, `dashboard/src/components/chat/ChatInput.vue:205`.
</issue_to_address>
### Comment 4
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="303" />
<code_context>
+const { tm: tmMeta } = useModuleI18n("features/config-metadata");
+const { tm: tmConfig } = useModuleI18n("features/config");
+const subagentKey = "ai_group.subagents.agent.config.subagents";
+const subagentConfigId = ref("default");
+const subagentConfigName = ref("");
+const subagentRuntime = ref("astrbot");
</code_context>
<issue_to_address>
**Early edits save to the default profile**
When a user changes a control while the conversation’s profile is still loading or its load fails, `subagentConfigId` remains `default` and the controls remain usable, so `saveSubagents()` updates the default profile instead of the conversation’s profile.
Disable the controls until the conversation’s profile has loaded successfully, and keep them disabled if loading fails.
Also at `dashboard/src/components/chat/ChatSettingsDialog.vue:194-201`, `dashboard/src/components/chat/ChatSettingsDialog.vue:323`, `dashboard/src/components/chat/ChatSettingsDialog.vue:348`.
</issue_to_address>
### Comment 5
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="315" />
<code_context>
+ if (!shown) return;
+ subagentError.value = "";
+ // ConfigSelector stores the configuration resolved for the current conversation.
+ const configId = getStoredSelectedChatConfigId();
+ try {
+ const [profile, profiles] = await Promise.all([
</code_context>
<issue_to_address>
**Another tab's profile is edited**
When two tabs have conversations bound to different profiles and the other tab writes its resolved profile ID last, `getStoredSelectedChatConfigId` reads a shared global preference, so this tab loads and saves the profile most recently written by another tab rather than the profile bound to its own conversation.
Resolve the profile from this tab's current conversation state, rather than using a shared global preference.
</issue_to_address>
### Comment 6
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="347" />
<code_context>
+ subagents.value = { ...previous, ...change };
+ subagentError.value = "";
+ try {
+ // Read the latest content so the rest of the configuration is saved unchanged.
+ const profile = await configProfileApi.get(subagentConfigId.value);
+ const config = (profile.data.data as any).config || {};
</code_context>
<issue_to_address>
**Overlapping saves lose the latest settings**
When the user changes subagent settings again while an earlier save is still in flight, `saveSubagents()` starts independent read-modify-write operations, so an earlier full-profile update can finish last and replace newer settings. Its catch handler can also restore an older `previous` snapshot after a later save succeeds, leaving the controls stale.
Serialize subagent saves and prevent an older save’s failure handler from restoring state after a newer save.
Also at `dashboard/src/components/chat/ChatSettingsDialog.vue:348-359`.
</issue_to_address>
### Comment 7
<location path="dashboard/src/components/chat/ChatSettingsDialog.vue" line_range="356" />
<code_context>
+ ...config.agent.config.subagents,
+ ...subagents.value,
+ };
+ const res = await configProfileApi.update(subagentConfigId.value, config);
+ if (res.data.status !== "ok") throw new Error(res.data.message || "");
+ } catch (err: any) {
</code_context>
<issue_to_address>
**Concurrent profile edits are overwritten**
When another editor updates the same profile after `saveSubagents()` reads it but before its update completes, `saveSubagents()` writes the full profile from its earlier read, replacing the other editor’s newer changes with a stale copy.
Update only the subagent settings without replacing the rest of the profile from a stale read.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 7 findings to address first, and a mistaken save can persist the wrong subagent enablement or agent selection in the conversation’s configuration profile, changing which subagents are available. Reverting the UI change would not restore that profile value, but it can be corrected in the configuration settings.
Blocking findings: dashboard/src/components/chat/ChatInput.vue:205, dashboard/src/components/chat/ChatSettingsDialog.vue:356, dashboard/src/components/chat/ChatSettingsDialog.vue:315, dashboard/src/components/chat/ChatSettingsDialog.vue:303, dashboard/src/components/chat/ChatSettingsDialog.vue:315, and 2 more
The Subagents page read the stored selection, which is only right after ConfigSelector has resolved the open conversation. Making the + menu eager to force that could apply the stored selection to an existing conversation. - The + menu is lazy again (ChatInput.vue back to master). - The page resolves the configuration from the conversation's route itself; a chat not created yet uses the stored selection, as newSession does. - Controls stay hidden until the configuration has loaded. - Saves run one at a time against the configuration shown when they were made, and write only the changed keys onto a fresh read.
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.
Motivation / 动机
Since #11053, subagents are set per configuration file under Config → AI → Capabilities → Subagents. ChatUI has no way to reach that setting. To turn subagents on, or pick a specialized agent for the profile a conversation uses, users have to leave the chat, find that conversation's profile and open the right tab. The
/subagentpage manages the agent library, but it does not turn subagents on for a profile or select agents for it.Relation to #11381 (open): it opens navigation pages such as Config in a dialog over the chat on desktop. That removes the "leave the chat" step, but the setting is still four levels down inside the dialog, and the user still has to know which profile the conversation uses. This PR adds a direct entry scoped to the current conversation. The two work independently and share no files except the changelog.
Modifications / 改动点
ChatSettingsDialog.vue: a new Subagents page in ChatUI settings, for the profile the current conversation uses.AgentConfigSelectorwith its Configure Specialized Agents dialog (AgentConfigManager), so creating, editing and deleting agents works as on the config page.config-metadatakeys, so the wording matches Config → AI → Capabilities.agent.config.subagents, write it back. The rest of the profile is saved as read. No backend change.The page finds the configuration itself. For an open conversation it reads the config routes and matches the conversation's origin, by the same wildcard rule as
ConfigSelector(resolveRoutedConfigIdinchatConfigBinding.ts). For a chat not created yet it uses the stored selection, which is what the new conversation will get.Chat.vuepasses the conversation's origin to the dialog.ChatInput.vueis not changed.The switch and selector appear only after that configuration has loaded. If loading fails, only the error is shown.
Saves run one at a time. Each one keeps the configuration ID it started with, reads the latest content and writes only the keys the user changed.
StandaloneChat.vue: the config page's test chat hides the new page. That page already shows the setting, and saving from both places could overwrite each other.i18n for all four locales,
docs/{zh,en}/use/webui.md(new entry), and a bilingual changelog entry with the new entry point. The existing entry stays.This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
All screenshots come from a throwaway instance with a test account and made-up data.
After creating a specialized agent from Configure Specialized Agents and selecting it:
Verification (Windows 11, Chromium-based browser):
agent.config.subagents.enabled: true;max_concurrent_agentsandtask_timeoutare kept.config_ids.default, + menu never opened:enabled: truein Profile B. The default profile is unchanged, andmax_concurrent_agentsandtask_timeoutare kept.master: ChatUI settings has only General and Chat.vue-tsc --noEmitpassed,node --test "tests/*.test.mjs"135 passed,npm run i18n:checkpassed,npm run buildpassed.node:24.13.0-bookworm-slim,pnpm install --frozen-lockfile): the same four checks passed, 135 tests.Not verified:
macOS check (2026-12-03)
Standard setup: macOS 27.0 (arm64), Microsoft Edge 158.0.4370.45 in headless mode, driven over the DevTools protocol at 1440×900 (device scale factor 2) unless stated otherwise; a WebUI build of the branch head, a new temporary instance on 127.0.0.1 with a generated test account and made-up data. Mouse and keyboard input was dispatched through DevTools input commands, not a physical mouse or keyboard. The Mac has the system "Reduce motion" setting on, so motion was checked with
prefers-reduced-motion: no-preferenceemulated, and withreduceemulated where stated. Model replies came from a local fake OpenAI-compatible endpoint; no real provider was used. Only what is listed under Checked was redone on macOS.c35a64a87, default profile.agent.config.subagents.enabled: true;max_concurrent_agents(3) andtask_timeout(600) are kept.enabled: falsesaved; one more click savestrue.config_ids.c35a64a87, branch as is (not merged withmaster): backendpytest5898 passed, 35 skipped; dashboardvue-tsc --noEmit,node --test135/135,i18n:checkand build all passed.Checklist / 检查清单
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). / 已在docs/{zh,en}/use/webui.md补充新入口,原入口保留。Models used: Claude Fable 5.2, Claude Opus 5.5 (Claude Code), GPT-6.2 Astra (Codex).
Summary by Sourcery
Manage subagents for the current conversation’s profile directly from ChatUI settings.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Chores: