Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): refresh capability catalog from the live default chain
zqchrisffc586b9458f
diff --git a/apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsx b/apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsxindex 4dae7a4969..10363490fd 100644--- a/apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsx+++ b/apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsx@@ -1,6 +1,11 @@-import { useCallback, useEffect, useRef, useState } from 'react';+import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';import { useBotTranslation } from './botPronounContext';-import type { BotCapabilities, BotProfile } from './botStore';+import {+ getEffectiveBotModelChain,+ subscribeBotGlobalModel,+ type BotCapabilities,+ type BotProfile,+} from './botStore';import * as sessionService from '@/lib/sessionService';import { onPatch } from '@/lib/sessionsBus';import type { Session } from '@/lib/ccAgent.types';@@ -35,7 +40,13 @@ export function BotCapabilitySettings({const [error, setError] = useState(false);const [query, setQuery] = useState('');const selected = { skill: skills, mcp: capabilities.mcpServers, toolset: capabilities.toolsets };- const modelChainKey = JSON.stringify(capabilities.modelChain);+ // Followed defaults can change when providers / available harnesses change, even+ // if the local profile still holds the previous modelChain snapshot.+ useSyncExternalStore(subscribeBotGlobalModel, () => JSON.stringify(getEffectiveBotModelChain()));+ const modelChain = capabilities.modelChainOverride === null+ ? getEffectiveBotModelChain()+ : capabilities.modelChain;+ const modelChainKey = JSON.stringify(modelChain);const catalogKey = JSON.stringify([bot.id, bot.canonicalSessionId, modelChainKey, revision, open]);// Invalidate during render as well as effect cleanup: stale checkboxes must never stay selectable.const entries = catalog.key === catalogKey ? catalog.entries : {};diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsxindex 6e51a40136..7ac9d82238 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx@@ -555,6 +555,9 @@ describe('Bot settings unified autosave', () => {describe('same-Bot capability updates while editing settings', () => {+ beforeEach(() => {+ mocks.defaultModelChain = capabilities().modelChain;+ });async function openCapabilities() {const details = screen.getByText('bots.capabilities.title').parentElement as HTMLDetailsElement;await act(async () => {@@ -668,18 +671,23 @@ describe('same-Bot capability updates while editing settings', () => {expect(mocks.listAgentSkills).toHaveBeenLastCalledWith('codex', expect.anything());});- it('refreshes when an external model-chain update arrives without reopening the panel', async () => {- const view = renderSettings();+ it('refreshes when the followed default model chain changes without reopening the panel', async () => {+ renderSettings();await openCapabilities();+ expect(mocks.listCustomMcpServers).toHaveBeenLastCalledWith(expect.objectContaining({+ modelChain: capabilities().modelChain,+ }));const chain = [{ ...capabilities().modelChain[0]!, harness: 'pi' as const, model: 'pi-x' }];- await act(async () => { view.rerender(<BotSettings bot={bot({ currentVersion: 2, capabilities: capabilities({ harness: 'pi', modelChain: chain }) })} onBack={view.onBack} onOpenSession={view.onOpenSession} />); });+ mocks.defaultModelChain = chain;+ await act(async () => { mocks.modelListeners.forEach((listener) => listener()); });expect(mocks.listCustomMcpServers).toHaveBeenLastCalledWith(expect.objectContaining({ modelChain: chain }));expect(mocks.listAgentSkills).toHaveBeenLastCalledWith('pi', expect.anything());});it.each(['claude', 'codex', 'pi'] as const)('uses the %s runtime catalog and keeps unavailable MCP references removable', async (harness) => {vi.useFakeTimers();- const profile = capabilities({ harness, modelChain: [{ ...capabilities().modelChain[0]!, harness }], mcpMode: 'allowlist' });+ const chain = [{ ...capabilities().modelChain[0]!, harness }];+ const profile = capabilities({ harness, modelChain: chain, modelChainOverride: chain, mcpMode: 'allowlist' });const view = renderSettings({ capabilities: profile });await openCapabilities();expect(mocks.listCustomMcpServers).toHaveBeenCalledWith({ agentKind: 'claude-code', botSessionId: 'bot-1-chat', modelChain: profile.modelChain });