Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(models): use selected execution catalog in teammate settings

xuzini-xzn504bb6ef10c4
diff --git a/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx b/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx
index 77955b3ca3..f8f9ae64cb 100644
--- a/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx
+++ b/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx
@@ -13,14 +13,23 @@ const model = { id: 'available-model', name: 'Gemini with a very long model disp
const provider: ProviderView = { ...BUNDLED_CATALOG.providers.find(p => p.id === 'openai')!,
connected: true, agents: ['codex'], access: { kind: 'subscription' }, models: { codex: [model] } };
const unknown: BotModelRoute = { harness: 'codex', model: 'google/gemini-4-argon', providerId: 'openai', effort: '', fastMode: false };
+const sharedModels = [
+ { ...model, id: unknown.model, name: 'Shared Gemini' },
+ { ...model, id: 'gpt-6.1-terra', name: 'Shared Terra' },
+];
+const sharedProvider: ProviderView = { ...provider, remoteInvocationEnabled: true,
+ agents: ['codex', 'pi'], models: { codex: sharedModels, pi: sharedModels } };
+const isSharedCase = ctx.case.startsWith('shared-');
function Fixture() {
const { t } = useTranslation();
- const primary = ctx.case === 'available' ? { ...unknown, model: model.id, effort: 'high' } : unknown;
+ const primary = isSharedCase ? { ...unknown, agentDeviceId: 'share:fixture', effort: 'high' }
+ : ctx.case === 'available' ? { ...unknown, model: model.id, effort: 'high' } : unknown;
const [routes, setRoutes] = useState<BotModelRoute[]>([primary,
- ...Array.from({ length: ctx.case === 'four-backups' ? 4 : 1 }, (_, i) => ({ ...unknown,
- model: i ? `vendor/very-long-unbroken-model-identifier-${i}-abcdefghijklmnopqrstuvwxyz` : 'google/gemini-4-argon-backup' }))]);
- const [task, setTask] = useState<BotModelRoute | null>(ctx.case === 'inherited' ? null : { ...unknown, harness: 'pi' });
+ ...Array.from({ length: ctx.case === 'four-backups' ? 4 : 1 }, (_, i) => ({ ...(isSharedCase ? primary : unknown),
+ model: isSharedCase ? sharedModels[1]!.id
+ : i ? `vendor/very-long-unbroken-model-identifier-${i}-abcdefghijklmnopqrstuvwxyz` : 'google/gemini-4-argon-backup' }))]);
+ const [task, setTask] = useState<BotModelRoute | null>(ctx.case === 'inherited' ? null : { ...(isSharedCase ? primary : unknown), harness: 'pi' });
return <main className="min-h-screen bg-[var(--surface)] p-4 text-[var(--text-primary)]">
<div className="mx-auto w-full max-w-[448px]" data-model-settings-fixture>
<BotModelChainEditor value={routes} onChange={setRoutes} label={t('bots.model.primary')}
@@ -34,15 +43,25 @@ function Fixture() {
void mountPage({
host: () => {
const owner = getDataOwnerGeneration();
+ const localProvider = ctx.case === 'shared-same-id' ? { ...provider,
+ models: { codex: sharedModels.map(entry => ({ ...entry, name: `Local ${entry.name}`, efforts: ['low'], defaultEffort: 'low' })) } } : provider;
commitProvidersSnapshot(beginProvidersRefresh(), { dataOwnerId: owner.dataOwnerId,
- ownerGeneration: owner.generation, providers: [provider], providerOrder: ['openai'] });
+ ownerGeneration: owner.generation, providers: [localProvider], providerOrder: ['openai'] });
+ const capabilities = (shared: boolean) => ({
+ hasFastMode: false,
+ availableModels: (shared ? sharedModels : [model]).map(entry => ({ ...entry, displayName: entry.name })),
+ effortLevels: [], permissionModes: [{ id: 'auto', displayName: 'Auto' }],
+ turnPermissionPolicy: { supported: { supported: true }, unsupportedPermissionModes: [] },
+ });
return { maker: {
listAvailableAgents: async () => ['claude-code', 'codex', 'pi'],
- getCapabilities: async () => ({ availableModels: [{ ...model, displayName: model.name }],
- effortLevels: [], permissionModes: [{ id: 'auto', displayName: 'Auto' }],
- turnPermissionPolicy: { supported: { supported: true }, unsupportedPermissionModes: [] } }),
+ getCapabilities: async () => capabilities(false),
onProvidersChanged: subscription('providers'),
- } };
+ }, deviceLink: { invoke: async (_deviceId: string, channel: string) => {
+ if (channel === 'maker:provider:list') return { providers: [sharedProvider] };
+ if (channel === 'maker:get-capabilities') return capabilities(true);
+ throw new Error(`Unsupported fixture channel: ${channel}`);
+ } } };
},
render: () => <Fixture />,
});
diff --git a/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs b/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs
index f3a40be0cb..eaeccc3a3f 100644
--- a/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs
@@ -7,7 +7,10 @@ export default {
real: 'BotModelChainEditor, BotTaskModelEditor, ModelRouteSelector, ModelSelector, themes and all translations',
notCovered: 'Live catalog discovery, remote devices, persistence and model execution; fixture supplies providers and local component state',
stubs: {
- 'src/renderer/hooks/useModelRouteDevices': 'export const useModelRouteDevices = () => ({ devices: undefined });',
+ 'src/renderer/hooks/useModelRouteDevices': `export const useModelRouteDevices = ({ leadAgentDeviceId }) => ({
+ devices: leadAgentDeviceId ? [{ deviceId: leadAgentDeviceId, name: 'Shared models' }] : undefined,
+ leadAgentDeviceId: leadAgentDeviceId ?? null,
+ });`,
},
cases: {
default: { about: 'Unavailable primary, backup and task model; status belongs to the model' },
@@ -15,9 +18,16 @@ export default {
'four-backups': { about: 'Four visible backups with unbroken IDs and working reorder/remove controls' },
inherited: { about: 'Task inherits primary, using the same complete-name presentation' },
'global-settings': { about: 'Global settings row uses the same wrapped picker' },
+ 'shared-only': { about: 'Shared-only Gemini/Terra labels resolve in primary, backup and task triggers' },
+ 'shared-same-id': { about: 'Shared labels and effort never fall back to a same-ID local model' },
},
async ready(page) {
await page.locator('[data-model-settings-fixture]').waitFor();
+ if (page.url().includes('shared-')) {
+ await page.locator('[data-model-settings-fixture] button[aria-haspopup="listbox"]').first()
+ .getByText('Shared Gemini', { exact: true }).waitFor();
+ await page.waitForFunction(() => !document.querySelector('[data-model-settings-fixture] button .animate-spinner'));
+ }
},
async check(page, ui) {
const pickers = page.locator('[data-model-settings-fixture] button[aria-haspopup="listbox"]');
@@ -29,7 +39,15 @@ export default {
assert.deepEqual(clipped, [], 'Model text must fit without ellipsis or clipping');
assert.equal(await pickers.count(), expected, 'Backups are immediately visible');
const status = await ui.t('settings.auxiliaryModels.unavailable');
- if (ui.case === 'available') {
+ if (ui.case.startsWith('shared-')) {
+ for (let index = 0; index < 3; index++) {
+ const picker = pickers.nth(index);
+ assert.equal(await picker.getByText(status, { exact: true }).count(), 0);
+ assert.equal(await picker.locator('svg.lucide-circle-alert').count(), 0, 'Shared catalog capabilities load successfully');
+ assert.ok(await picker.getByText(index === 1 ? 'Shared Terra' : 'Shared Gemini', { exact: true }).isVisible());
+ assert.ok(!(await picker.textContent()).includes('Local Shared'));
+ }
+ } else if (ui.case === 'available') {
assert.equal(await pickers.first().getByText(status, { exact: true }).count(), 0);
assert.ok(await pickers.first().getByText('Gemini with a very long model display name', { exact: true }).isVisible());
} else {
diff --git a/apps/desktop/scripts/fixtures/nightly-learning/nightly-learning-fixture.tsx b/apps/desktop/scripts/fixtures/nightly-learning/nightly-learning-fixture.tsx
index ee188461f3..ea80b88202 100644
--- a/apps/desktop/scripts/fixtures/nightly-learning/nightly-learning-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/nightly-learning/nightly-learning-fixture.tsx
@@ -50,6 +50,7 @@ function viewFor(caseName: string): NightlyLearningView {
}
mountPage({
+ route: '/',
host: (ctx) => {
let view = viewFor(ctx.case);
const routines = [
diff --git a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
index 908cd5a577..06cf551fc9 100644
--- a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
@@ -65,7 +65,10 @@ vi.mock('react-i18next', async (importOriginal) => ({
vi.mock('@/lib/scrollbarAutoHide', () => ({ flashScrollbar: vi.fn() }));
vi.mock('@/hooks/useModelRouteDevices', () => ({
- useModelRouteDevices: () => ({ devices: [], leadAgentDeviceId: null }),
+ useModelRouteDevices: ({ leadAgentDeviceId }: { leadAgentDeviceId?: string | null }) => ({
+ devices: leadAgentDeviceId ? [{ deviceId: leadAgentDeviceId, name: 'Shared models' }] : [],
+ leadAgentDeviceId: leadAgentDeviceId ?? null,
+ }),
}));
const workerCapabilities = vi.hoisted(() => ({ byAgent: {} as Record<string, AgentCapabilities> }));
@@ -4244,6 +4247,67 @@ vi.mock('@/features/bots/botStore', () => ({ getEffectiveBotModelSettings: () =>
}) }));
vi.mock('@/features/bots/botPronounContext', () => ({ useBotTranslation: () => ({ t: (key: string) => key }) }));
import { BotModelChainEditor } from '@/features/bots/BotModelChainEditor';
+import { BotTaskModelEditor } from '@/features/bots/BotTaskModelEditor';
+
+describe('teammate settings selected location catalog', () => {
+ const originalProviders = providersRef.providers;
+ const share = 'share:settings-test';
+ const models = [
+ { id: 'google/gemini-4-argon', name: 'Shared Gemini', contextWindow: 200000, efforts: ['high'], defaultEffort: 'high' },
+ { id: 'gpt-6.1-terra', name: 'Shared Terra', contextWindow: 200000, efforts: ['high'], defaultEffort: 'high' },
+ ];
+ beforeEach(() => {
+ remoteProvidersRef.providers = [{
+ id: 'xd', name: 'Shared gateway', source: 'builtin', connected: true, remoteInvocationEnabled: true,
+ agents: ['codex'], auth: { method: 'api-key' }, routing: { codex: {} },
+ models: { codex: models },
+ }];
+ workerCapabilities.byAgent.codex = {
+ availableModels: models.map(({ name, ...model }) => ({ ...model, displayName: name })),
+ hasFastMode: false, effortLevels: [], permissionModes: [],
+ };
+ });
+ afterEach(() => {
+ providersRef.providers = originalProviders;
+ remoteProvidersRef.providers = [];
+ workerCapabilities.byAgent = {};
+ });
+
+ it.each(['primary', 'backup', 'task'] as const)('shows shared-only Gemini and Terra in the %s picker', async (position) => {
+ for (const model of models) {
+ const route = { harness: 'codex' as const, providerId: 'xd', model: model.id,
+ effort: 'high', fastMode: false, agentDeviceId: share };
+ const local = { ...route, agentDeviceId: null, model: 'gpt-5.5' };
+ const view = render(position === 'task'
+ ? <BotTaskModelEditor value={route} onChange={vi.fn()} />
+ : <BotModelChainEditor value={position === 'backup' ? [local, route] : [route]} onChange={vi.fn()} />);
+ const picker = view.container.querySelectorAll('button[aria-haspopup="listbox"]')[position === 'backup' ? 1 : 0]!;
+ expect(picker.textContent).toContain(model.name);
+ expect(picker.textContent).not.toContain('settings.auxiliaryModels.unavailable');
+ expect(picker.getAttribute('title')).toContain(model.name);
+ expect(picker.textContent).toContain('高');
+ fireEvent.click(picker);
+ const menu = await screen.findByRole('listbox');
+ expect(within(menu).getAllByText(model.name).length).toBeGreaterThan(0);
+ view.unmount();
+ }
+ });
+
+ it('uses the selected shared name rather than a same-ID local model', () => {
+ const model = models[0]!;
+ providersRef.providers = [{
+ id: 'xd', name: 'Local gateway', source: 'builtin', connected: true,
+ agents: ['codex'], auth: { method: 'api-key' }, routing: { codex: {} },
+ models: { codex: [{ ...model, name: 'Local Gemini', efforts: ['low'], defaultEffort: 'low' }] },
+ }];
+ const view = render(<BotModelChainEditor value={[{ harness: 'codex', providerId: 'xd', model: model.id,
+ effort: 'high', fastMode: false, agentDeviceId: share }]} onChange={vi.fn()} />);
+ const picker = view.container.querySelector('button[aria-haspopup="listbox"]')!;
+ expect(picker.textContent).toContain('Shared Gemini');
+ expect(picker.textContent).not.toContain('Local Gemini');
+ expect(picker.textContent).toContain('高');
+ });
+});
describe('Teammate settings with the real model picker', () => {
it('opens the real config and saves the selected source, harness, effort and Fast as one route', async () => {
diff --git a/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx
index 50d7ca1267..280166c53e 100644
--- a/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx
@@ -7,7 +7,10 @@ export function ModelRouteSelector({ agentDeviceId, sshRemote, deviceId, ...prop
ComponentProps<typeof ModelSelector> & { agentDeviceId?: string | null; sshRemote?: boolean }) {
const locations = useModelRouteDevices({ controlledDeviceId: deviceId ?? null,
leadAgentDeviceId: agentDeviceId, sshRemote });
- return <ModelSelector {...props} deviceId={deviceId}
+ // The trigger and the menu must read the selected, readable execution location.
+ // Keep the home location separate for browsing local/controlled-host models.
+ const catalogDeviceId = locations.devices ? locations.leadAgentDeviceId ?? deviceId : deviceId;
+ return <ModelSelector {...props} deviceId={catalogDeviceId}
remoteAgent={locations.devices ? { devices: locations.devices,
- selectedDeviceId: agentDeviceId ?? null, homeDeviceId: deviceId } : undefined} />;
+ selectedDeviceId: locations.leadAgentDeviceId, homeDeviceId: deviceId } : undefined} />;
}
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx
index 9e1a59425e..ee34a0b404 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx
@@ -1,5 +1,10 @@
// @vitest-environment jsdom
-vi.mock('@/hooks/useModelRouteDevices', () => ({ useModelRouteDevices: () => ({ devices: [{ deviceId: 'share:one', name: 'Shared account' }] }) }));
+vi.mock('@/hooks/useModelRouteDevices', () => ({
+ useModelRouteDevices: ({ leadAgentDeviceId, sshRemote }: { leadAgentDeviceId?: string | null; sshRemote?: boolean }) => ({
+ devices: sshRemote ? undefined : [{ deviceId: 'share:one', name: 'Shared account' }],
+ leadAgentDeviceId: leadAgentDeviceId ?? null,
+ }),
+}));
vi.mock('@/hooks/useDeviceProviders', () => ({ useDeviceProviders: () => ({ providers: [] }) }));
@@ -220,7 +225,7 @@ describe('BotModelChainEditor', () => {
roster.availableVendors = new Set();
roster.loaded = false;
const onChange = vi.fn();
- render(<BotModelChainEditor value={[]} onChange={onChange} />);
+ const view = render(<BotModelChainEditor value={[]} onChange={onChange} />);
const props = modelSelectorProps.mock.lastCall?.[0];
expect(props).toMatchObject({ disabled: false, unifiedAgents: ['pi', 'codex', 'claude-code'],
remoteAgent: { devices: [{ deviceId: 'share:one', name: 'Shared account' }] } });
@@ -228,6 +233,9 @@ describe('BotModelChainEditor', () => {
agentDevice: { deviceId: 'share:one', name: 'Shared account' } });
expect(onChange).toHaveBeenLastCalledWith([{ harness: 'codex', model: 'remote-model', providerId: 'openai',
effort: 'medium', fastMode: false, agentDeviceId: 'share:one' }]);
+ view.rerender(<BotModelChainEditor value={onChange.mock.lastCall![0]} onChange={onChange} />);
+ expect(modelSelectorProps.mock.lastCall?.[0]).toMatchObject({ deviceId: 'share:one',
+ remoteAgent: { selectedDeviceId: 'share:one', homeDeviceId: undefined } });
onChange.mockClear();
fireEvent.click(screen.getByText('bots.modelChain.add'));
expect(onChange).not.toHaveBeenCalled();
@@ -383,3 +391,17 @@ it('uses the selected device catalog without SSH subscription exclusions or loca
fireEvent.click(within(screen.getByTestId('bot-model-fallbacks')).getByRole('button', { name: 'choose-official-codex-model' }));
expect(change).toHaveBeenCalledWith([expect.objectContaining({ providerId: 'openai', harness: 'codex' })]);
});
+
+it.each([undefined, 'controlled-host'])('keeps home %s separate from the selected shared catalog', (deviceId) => {
+ render(<BotModelChainEditor deviceId={deviceId} value={[{ harness: 'codex', model: 'shared-model',
+ providerId: 'openai', effort: 'high', fastMode: false, agentDeviceId: 'share:one' }]} onChange={vi.fn()} />);
+ expect(modelSelectorProps.mock.lastCall?.[0]).toMatchObject({ deviceId: 'share:one',
+ remoteAgent: { selectedDeviceId: 'share:one', homeDeviceId: deviceId } });
+});
+
+it('preserves the SSH catalog when execution locations cannot be browsed', () => {
+ render(<BotModelChainEditor remote value={[{ harness: 'codex', model: 'ssh-model',
+ providerId: 'openai', effort: 'high', fastMode: false, agentDeviceId: 'share:one' }]} onChange={vi.fn()} />);
+ expect(modelSelectorProps.mock.lastCall?.[0]).toMatchObject({ deviceId: undefined,
+ remoteAgent: undefined, excludeSubscriptionDirect: true, excludeChatBridgedCodex: true });
+});