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。

Merge upstream/main into fix-6806-group-settings-save

zcinta0514f697c9568715
diff --cc apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx
index c5cce55a41,9a1297c702..9b3e2d02f9
--- a/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx
+++ b/apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx
@@@ -116,28 -125,26 +122,27 @@@ export function ChatGroupSettings({ gro
{error && <p role="alert" className="text-13 text-[var(--error-fg)]">{error}</p>}
<form className="space-y-3" onSubmit={event => {
event.preventDefault();
- void mutate({ type: 'update', name, topic, description, responseMode: replyMode, speakingMode, expectedRevision: draftRevision.current }).then(ok => { if (ok) dirty.current = false; });
+ void mutate({ type: 'update', name, topic, description, responseMode: replyMode, speakingMode,
+ expectedRevision }).then(ok => { if (ok) setDraft(null); });
}}>
<FormField label={t(key('name'))}>{props => <Input {...props} value={name} maxLength={40} required disabled={!manager || busy}
- onChange={event => { editGroup(); setName(event); }} />}</FormField>
+ onChange={name => editGroup({ name })} />}</FormField>
<FormField label={t(key('topic'))}>{props => <Input {...props} value={topic} maxLength={250} disabled={!manager || busy}
- onChange={event => { editGroup(); setTopic(event); }} />}</FormField>
+ onChange={topic => editGroup({ topic })} />}</FormField>
<FormField label={t(key('description'))}>{props => <Input {...props} value={description} maxLength={2000} disabled={!manager || busy}
- onChange={event => { editGroup(); setDescription(event); }} />}</FormField>
+ onChange={description => editGroup({ description })} />}</FormField>
- {/* One teammate at a time: who answers follows @ (everyone queues when nobody is named), not a group mode. */}
- {group.singleSpeaker ? null : <>
+ {/* Whether unaddressed messages wake anyone; independent of the order teammates answer in. */}
<FormField label={t(shared('replyMode'))}>{props => <Select {...props} label={t(shared('replyMode'))} value={replyMode}
disabled={!manager || busy} options={(['all', 'mentioned'] as const).map(value => ({ value, label: t(REPLY_MODE_LABELS[value]) }))}
- onValueChange={value => { editGroup(); setReplyMode(value as typeof replyMode); }} />}</FormField>
+ onValueChange={value => editGroup({ replyMode: value as typeof replyMode })} />}</FormField>
- <FormField label={t(shared('speakingMode'))}>{props => <Select {...props} label={t(shared('speakingMode'))} value={speakingMode}
+ {/* Single-speaker servers always answer one teammate at a time, so there is no speaking mode. */}
+ {group.singleSpeaker ? null : <FormField label={t(shared('speakingMode'))}>{props => <Select {...props} label={t(shared('speakingMode'))} value={speakingMode}
disabled={!manager || busy} options={(['auto', 'sequential'] as const).map(value => ({ value, label: t(SPEAKING_MODE_LABELS[value]) }))}
- onValueChange={value => editGroup({ speakingMode: value as typeof speakingMode })} />}</FormField>
- </>}
- onValueChange={value => { editGroup(); setSpeakingMode(value as typeof speakingMode); }} />}</FormField>}
++ onValueChange={value => editGroup({ speakingMode: value as typeof speakingMode })} />}</FormField>}
{manager && <Button type="submit" size="sm" variant="secondary" disabled={busy || !name.trim()}>{t(key('save'))}</Button>}
</form>
- {/* Organizer and project folder only serve a division of work, which single-speaker groups do not have. */}
- {group.singleSpeaker ? null : <section className="space-y-3 border-t border-[var(--border-default)] pt-5">
+ {/* The organizer arranges a 分工 whose steps are not written out; a 分工 works in the project folder. */}
+ <section className="space-y-3 border-t border-[var(--border-default)] pt-5">
<FormField label={t('bots.groupChat.organizer')} hint={t('bots.groupChat.settings.organizerNote')}>{props =>
<Select {...props} label={t('bots.groupChat.organizer')} value={group.organizerBotId ?? ''}
disabled={!manager || busy} options={companions.filter(m => m.status === 'active').map(m => ({ value: m.botId, label: m.name }))}
diff --cc apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx
index 325bc3fcc1,6bee67a41a..12a770a6f0
--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatGroupSettings.test.tsx
@@@ -1,14 -1,36 +1,36 @@@
// @vitest-environment jsdom
-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
- import { MemoryRouter } from 'react-router-dom';
+ import type { ReactNode } from 'react';
+ import { MemoryRouter, RouterProvider, createMemoryRouter, useLocation } from 'react-router-dom';
+ import { transferableAbortController } from 'node:util';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
import { ChatGroupSettings } from '../ChatGroupSettings';
+ import { BotSettingsDrawer } from '../BotSettingsDrawer';
import type { BotGroupSummary } from '../../../../shared/botGroupChat';
const mocks = vi.hoisted(() => ({ manage: vi.fn(), ownedBots: vi.fn(), refresh: vi.fn(), confirm: vi.fn() }));
- vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+ const profiles = vi.hoisted(() => ({
+ list: [{ id: 'bot', name: 'Partner', status: 'active', sessions: [] as Array<{ id: string }>, capabilities: {}, skills: [] as string[] }],
+ }));
+ const translate = (key: string, options?: { name?: string }) =>
+ typeof options?.name === 'string' ? `${key}:${options.name}` : key;
+ vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: translate }) }));
+ vi.mock('../botPronounContext', () => ({
+ useBotTranslation: () => ({ t: translate }),
+ BotPronounProvider: ({ children }: { children: ReactNode }) => children,
+ }));
+ vi.mock('../useRemoteBots', () => ({ useRemoteBots: () => [] }));
+ vi.mock('../RemoteBotSettings', () => ({ RemoteBotSettings: () => null }));
+ vi.mock('../companionCloudStore', () => ({ useCompanionCloud: () => ({ demotedBotIds: [] as string[] }) }));
+ vi.mock('../BotsHomeView', () => ({
+ BotSettings: ({ bot, initialPage }: { bot: { id: string; name: string }; initialPage?: string }) => (
+ <div data-testid="bot-settings" data-bot-id={bot.id} data-initial-page={initialPage}>{bot.name}</div>
+ ),
+ }));
vi.mock('@/components/ui/confirm-dialog-provider', () => ({ useConfirmDialog: () => ({ confirm: mocks.confirm }) }));
- vi.mock('@/components/settings/ProfileEditDialog', () => ({ ProfileEditDialog: () => null }));
- vi.mock('../botStore', () => ({ useBotProfiles: () => [{ id: 'bot' }] }));
+ vi.mock('@/components/settings/ProfileEditDialog', () => ({ ProfileEditDialog: ({ open, avatarEditor }: {
+ open: boolean; avatarEditor?: { hint: string; save(avatar: { type: 'reset' }): Promise<void> };
+ }) => open && avatarEditor ? <button onClick={() => void avatarEditor.save({ type: 'reset' })}>{avatarEditor.hint}</button> : null }));
+ vi.mock('../botStore', () => ({ useBotProfiles: () => profiles.list }));
vi.mock('../BotAvatar', () => ({ BotAvatar: () => null }));
vi.mock('../botGroupStore', () => ({ refreshBotGroups: mocks.refresh }));
vi.mock('@/contexts/dataOwnerGeneration', () => ({ getDataOwnerGeneration: () => 1, isDataOwnerGenerationCurrent: () => true }));