Skip to content

feat(chatui): manage subagents from ChatUI settings - #11630

Open
liquidtoy001 wants to merge 2 commits into
AstrBotDevs:masterfrom
liquidtoy001:feat/chatui-subagent-settings
Open

liquidtoy001 wants to merge 2 commits into
AstrBotDevs:masterfrom
liquidtoy001:feat/chatui-subagent-settings

Conversation

@liquidtoy001

@liquidtoy001 liquidtoy001 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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 /subagent page 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.

    • It shows the profile name, the subagent switch and the specialized agent selector. The selector is the existing AgentConfigSelector with its Configure Specialized Agents dialog (AgentConfigManager), so creating, editing and deleting agents works as on the config page.
    • Labels and hints come from the existing config-metadata keys, so the wording matches Config → AI → Capabilities.
    • Changes go through the existing config profile API: read the profile, change agent.config.subagents, write it back. The rest of the profile is saved as read. No backend change.
    • Profiles whose agent runtime is not AstrBot's built-in AI show a note instead.
  • 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 (resolveRoutedConfigId in chatConfigBinding.ts). For a chat not created yet it uses the stored selection, which is what the new conversation will get. Chat.vue passes the conversation's origin to the dialog. ChatInput.vue is 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.

master This PR

After creating a specialized agent from Configure Specialized Agents and selecting it:

Verification (Windows 11, Chromium-based browser):

  • Manual, on the branch build, with the default profile:
    • Settings → Subagents shows the profile name and the switch.
    • Turning the switch on writes agent.config.subagents.enabled: true; max_concurrent_agents and task_timeout are kept.
    • Configure Specialized Agents opens the agent manager. A new agent created there appears in the selector, and selecting it writes it to config_ids.
  • Manual, with a conversation routed to a second profile ("Profile B"), stored selection still default, + menu never opened:
    • After a page reload on that conversation, Settings → Subagents shows Profile B.
    • Clicking the switch on, off, on in quick succession ends with enabled: true in Profile B. The default profile is unchanged, and max_concurrent_agents and task_timeout are kept.
    • The conversation's route is unchanged.
    • Switching to a conversation on the default profile while the page is open reloads it to the default profile.
  • On master: ChatUI settings has only General and Chat.
  • Dashboard checks, Windows 11: vue-tsc --noEmit passed, node --test "tests/*.test.mjs" 135 passed, npm run i18n:check passed, npm run build passed.
  • Dashboard checks, Linux (Docker, node:24.13.0-bookworm-slim, pnpm install --frozen-lockfile): the same four checks passed, 135 tests.
  • Backend tests were not run: the PR changes no backend file.

Not verified:

  • macOS: see the macOS check below for what was and was not run there.
  • A profile with a non-AstrBot runtime (the note).
  • A failed load or a failed save (only checked in code).
  • Two browser tabs editing at once. A change made elsewhere to the same profile between this page's read and write is still overwritten, because the API saves the whole profile.
  • The config page's test chat without the page (only checked in code).

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-preference emulated, and with reduce emulated 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.

  • Ran on macOS: the standard setup, dark theme, branch head c35a64a87, default profile.
  • Checked:
    • ChatUI settings has General, Chat and Subagents. The Subagents page shows the profile name ("默认配置文件") and the switch.
    • Turning the switch on writes agent.config.subagents.enabled: true; max_concurrent_agents (3) and task_timeout (600) are kept.
    • Three quick clicks in a row (off, on, off) end with enabled: false saved; one more click saves true.
    • With the switch on, the specialized agent selector and Configure Specialized Agents appear. The button opens the agent manager; an agent created there appears in the selector, and selecting it writes its id to config_ids.
    • No text is clipped in the dialog.
  • Script checks: on this Mac at c35a64a87, branch as is (not merged with master): backend pytest 5898 passed, 35 skipped; dashboard vue-tsc --noEmit, node --test 135/135, i18n:check and build all passed.
  • Not checked on macOS: a conversation routed to a second profile, and switching conversations while the page is open; a non-AstrBot runtime; failed loads and saves; two tabs; the config page's test chat; the light theme; Safari and the desktop app.
  • Differences from the Windows results above: none observed.

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 checked the affected WebUI instructions and screenshots in docs/zh and docs/en against 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 补充新入口,原入口保留。
  • 🤓 I have ensured that no new dependencies are introduced. / 我确保没有引入新依赖库。
  • 😮 My changes do not introduce malicious code. / 我的更改没有引入恶意代码。

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:

  • Add a ChatUI Settings → Subagents page to enable or disable subagents and select, create, edit, or delete specialized agents for the profile used by the current conversation.
  • Show a note instead of subagent controls when the selected profile uses a non-AstrBot runtime.

Bug Fixes:

  • Resolve the + menu’s config profile for the open conversation when ChatUI loads, so subagent settings and new conversations use the correct routed profile after reload.

Enhancements:

  • Keep the config page’s test chat bound to its existing profile by hiding the new Subagents page there.

Documentation:

  • Document the Subagents settings entry in the Chinese and English WebUI guides.

Chores:

  • Add bilingual unreleased changelog notes and translations for the new ChatUI settings entry.

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.

@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 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


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

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.
@mantoujun12 mantoujun12 added the feature:chatui The bug / feature is about astrbot's chatui, webchat label Dec 3, 2026

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

feature:chatui The bug / feature is about astrbot's chatui, webchat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants