Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): align AI reply UI and existing test fixtures
zqchrisddffbeec9534
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteDialog.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteDialog.test.tsxindex 74c5baf817..bbe2df20e7 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteDialog.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteDialog.test.tsx@@ -3,13 +3,14 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';import { ChatInviteDialog } from '../ChatInviteDialog';-const mocks = vi.hoisted(() => ({ createInvite: vi.fn(), previewInvite: vi.fn(), acceptInvite: vi.fn(), revokeInvite: vi.fn(), copy: vi.fn(), success: vi.fn() }));+const mocks = vi.hoisted(() => ({ createInvite: vi.fn(), previewInvite: vi.fn(), acceptInvite: vi.fn(), status: vi.fn(), revokeInvite: vi.fn(), copy: vi.fn(), success: vi.fn() }));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string, values?: { date?: string }) => values?.date ? `${key}: ${values.date}` : key, i18n: { language: 'en' } }) }));vi.mock('../botGroupStore', () => ({ refreshBotGroups: vi.fn() }));vi.mock('@/lib/toast', () => ({ toast: { success: mocks.success } }));const k = (name: string) => `bots.groupChat.server.${name}`;const link = `cindy://chat-invite/${'a'.repeat(43)}`;beforeEach(() => {+ mocks.status.mockResolvedValue({ personalMask: false });vi.clearAllMocks(); setDataOwnerGeneration('account', 1);mocks.createInvite.mockResolvedValue({ ok: true, link, expiresAt: null, reusable: true });mocks.previewInvite.mockResolvedValue({ ok: true, groupId: 'room', name: 'Room', inviterName: 'Host', expiresAt: null, reusable: true, joined: false });diff --git a/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteHost.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteHost.test.tsxindex e6e94f61b2..9efc759f68 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteHost.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatInviteHost.test.tsx@@ -6,7 +6,7 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest';import { ChatInviteHost, reportMalformedChatInvite, requestChatInvite } from '../ChatInviteHost';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';-const api = vi.hoisted(() => ({ previewInvite: vi.fn(), acceptInvite: vi.fn() }));+const api = vi.hoisted(() => ({ previewInvite: vi.fn(), acceptInvite: vi.fn(), status: vi.fn() }));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));vi.mock('../botGroupStore', () => ({ refreshBotGroups: vi.fn() }));vi.mock('@/lib/toast', () => ({ toast: { success: vi.fn() } }));@@ -19,6 +19,7 @@ function mount() {}async function retry() { await act(async () => { fireEvent.click(screen.getByRole('button', { name: k('retryInvite') })); }); }beforeEach(() => {+ api.status.mockResolvedValue({ personalMask: false });vi.clearAllMocks();setDataOwnerGeneration('owner-a');api.previewInvite.mockResolvedValue({ ok: true, groupId: 'room', name: 'Invited group', inviterName: 'Host', joined: false });diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsxindex 28e380d17e..fc6b27e8df 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx@@ -29,6 +29,8 @@ beforeEach(() => {resetBotGroupStoreForTests();groups = [group()];Object.defineProperty(window, 'electronAPI', { configurable: true, value: { maker: {+ chatServer: {},+ onBotGroupChanged: vi.fn(() => () => undefined),listBotGroups: vi.fn(async () => ({ ok: true, groups })),} } });});diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex addcc68126..acc89c4ab9 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -10151,31 +10151,31 @@"choose": "選擇一位夥伴","enabled": "自動代答","triggerLabel": "觸發方式",- "resumeAfter": "离開多久後恢覆",+ "resumeAfter": "離開多久後恢復","start": "開始時間","end": "結束時間","startManual": "現在開啟","stop": "停止代答","todos": "整理與我有關的待辦","digestLabel": "彙總給我",- "saving": "正在保存…",- "saveError": "未能保存,仍按原設定代答。請重試。",+ "saving": "正在儲存…",+ "saveError": "未能儲存,仍按原設定代答。請重試。","retry": "重試",- "loading": "正在加載你的設定…",+ "loading": "正在載入你的設定…","takeover": "我來回覆","resume": "恢復代答","status": {"enabled": "已啟用","paused": "已讓位","off": "未開啟",- "offline": "已离線",+ "offline": "已離線","waiting": "待觸發",- "unbound": "未綁定"+ "unbound": "未連結"},"detail": {"paused": "你已接回這段交流","off": "自動代答已關閉",- "offline": "代答已暫停 · 電腦离線",+ "offline": "代答已暫停 · 電腦離線","waiting": "等待手動開啟","unbound": "尚未選擇夥伴","enabled": "夥伴正在為你待答"@@ -10189,8 +10189,8 @@"daily": "每日彙總","manual": "手動彙整"},- "minutes": "{{count}} 分钟",- "presence": "你正在參與 · 离開 {{minutes}} 分钟後恢覆",+ "minutes": "{{count}} 分鐘",+ "presence": "你正在參與 · 離開 {{minutes}} 分鐘後恢復","scheduledWait": "等待 {{time}} 開始","attribution": "{{name}} 為 {{owner}} 回覆","digestNow": "立即整理",diff --git a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json b/apps/mobile/src/i18n/locales/zh-TW/groupChat.jsonindex 583c118175..95a46ee1b2 100644--- a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json+++ b/apps/mobile/src/i18n/locales/zh-TW/groupChat.json@@ -336,31 +336,31 @@"choose": "選擇一位夥伴","enabled": "自動代答","triggerLabel": "觸發方式",- "resumeAfter": "离開多久後恢覆",+ "resumeAfter": "離開多久後恢復","start": "開始時間","end": "結束時間","startManual": "現在開啟","stop": "停止代答","todos": "整理與我有關的待辦","digestLabel": "彙總給我",- "saving": "正在保存…",- "saveError": "未能保存,仍按原設定代答。請重試。",+ "saving": "正在儲存…",+ "saveError": "未能儲存,仍按原設定代答。請重試。","retry": "重試",- "loading": "正在加載你的設定…",+ "loading": "正在載入你的設定…","takeover": "我來回覆","resume": "恢復代答","status": {"enabled": "已啟用","paused": "已讓位","off": "未開啟",- "offline": "已离線",+ "offline": "已離線","waiting": "待觸發",- "unbound": "未綁定"+ "unbound": "未連結"},"detail": {"paused": "你已接回這段交流","off": "自動代答已關閉",- "offline": "代答已暫停 · 電腦离線",+ "offline": "代答已暫停 · 電腦離線","waiting": "等待手動開啟","unbound": "尚未選擇夥伴","enabled": "夥伴正在為你待答"@@ -374,8 +374,8 @@"daily": "每日彙總","manual": "手動彙整"},- "minutes": "{{count}} 分钟",- "presence": "你正在參與 · 离開 {{minutes}} 分钟後恢覆",+ "minutes": "{{count}} 分鐘",+ "presence": "你正在參與 · 離開 {{minutes}} 分鐘後恢復","scheduledWait": "等待 {{time}} 開始","attribution": "{{name}} 為 {{owner}} 回覆","digestNow": "立即整理",diff --git a/apps/mobile/src/session/GroupMaskControls.tsx b/apps/mobile/src/session/GroupMaskControls.tsxindex 87ed96f33a..938de494db 100644--- a/apps/mobile/src/session/GroupMaskControls.tsx+++ b/apps/mobile/src/session/GroupMaskControls.tsx@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';import { Text, TextInput } from '@/components/AppText';import { MainWindowActionButton } from '@/components/MobilePrimitives';import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';-import { spacing, radius, typeScale, fontWeight } from '@/theme/tokens';+import { spacing, radius, typeScale, lineHeight, fontWeight, iconSize } from '@/theme/tokens';import { chatMemberAvatar } from '@/chat/chatServerClient';import { botGroupMemberAvatar } from './botGroupRemote';import { NativeSwitch, showConfirm } from '@/platform/chrome';@@ -15,14 +15,16 @@ import { BotGroupMenu } from './BotGroupMenu';import { BotGroupAvatar } from './BotGroupAvatars';import type { GroupPersonalMask } from './useGroupPersonalMask';+// Overlapping avatar geometry belongs to this composition, like BotGroupDuoAvatar.+const avatarSizes = { self: 28, companion: 18, reply: 20 } as const;const key = (name: string) => `groupChat.mask.${name}`;const maskIdentity = (value: ChatMaskIdentity) => ({ botId: value.id, name: value.name, ...chatMemberAvatar(value.avatarUrl), avatar: botGroupMemberAvatar({ name: value.name, ...chatMemberAvatar(value.avatarUrl), avatarColor: '' }) });export function GroupMaskAvatar({ self, companion, deviceId = '' }: { self: ChatMaskIdentity; companion: ChatMaskIdentity; deviceId?: string }) {const { colors } = useTheme(), { t } = useTranslation();return <View style={{ width: 36, height: 36 }} accessible accessibilityLabel={t(key('attribution'), { name: companion.name, owner: self.name })}>- <BotGroupAvatar deviceId={deviceId} identity={maskIdentity(self)} size={28} online />+ <BotGroupAvatar deviceId={deviceId} identity={maskIdentity(self)} size={avatarSizes.self} online /><View style={{ position: 'absolute', right: 0, bottom: 0, borderRadius: radius.pill, borderWidth: 2, borderColor: colors.surface }}>- <BotGroupAvatar deviceId={deviceId} identity={maskIdentity(companion)} size={18} online />+ <BotGroupAvatar deviceId={deviceId} identity={maskIdentity(companion)} size={avatarSizes.companion} online /></View></View>;}@@ -47,7 +49,7 @@ export function GroupMaskSettingsSheet({ visible, mask, onClose, onClosed }: { vconst pick = (label: string, value: string, options: Array<{ id: string; title: string }>, select: (value: string) => void) =><BotGroupMenu title={label} accessibilityLabel={label} disabled={mask.saving} sections={[{ id: 'options', options: options.map(o => ({ ...o, selected: o.id === value })) }]} onSelect={select}>{open => <Pressable onPress={open} style={styles.row} accessibilityRole="button"><Text style={styles.label}>{label}</Text>- <Text style={styles.value} numberOfLines={2}>{options.find(o => o.id === value)?.title ?? t(key('choose'))}</Text><ChevronDown size={16} color={colors.textSecondary} /></Pressable>}+ <Text style={styles.value} numberOfLines={2}>{options.find(o => o.id === value)?.title ?? t(key('choose'))}</Text><ChevronDown size={iconSize.md} color={colors.textSecondary} /></Pressable>}</BotGroupMenu>;const toggle = (label: string, value: boolean, change: (value: boolean) => void, disabled = false) => <View style={styles.row}><Text style={styles.label}>{label}</Text><NativeSwitch accessibilityLabel={label} value={value} disabled={mask.saving || disabled} onValueChange={change} /></View>;@@ -100,14 +102,14 @@ export function GroupMaskCatchupSheet({ visible, mask, onClose, onClosed, onLoca<Text style={[styles.label, styles.author]}>{mention.authorName}</Text>{mention.reply ? <Pressable accessibilityRole="button" accessibilityState={{ expanded: expanded === mention.messageId }} style={styles.disclosure}onPress={() => setExpanded(value => value === mention.messageId ? null : mention.messageId)}>- <Text style={styles.secondary}>{t(key('catchup.answered'))}</Text><ChevronDown size={16} color={colors.textSecondary} />+ <Text style={styles.secondary}>{t(key('catchup.answered'))}</Text><ChevronDown size={iconSize.md} color={colors.textSecondary} /></Pressable> : null}</View><Pressable accessibilityRole="button" onPress={() => onLocate(mention)} style={styles.question}>- <Text style={styles.body}>{mention.text}</Text><ChevronRight size={18} color={colors.textSecondary} />+ <Text style={styles.body}>{mention.text}</Text><ChevronRight size={iconSize.lg} color={colors.textSecondary} /></Pressable>{expanded === mention.messageId && mention.reply ? <View style={styles.reply}>- <BotGroupAvatar deviceId="" identity={maskIdentity(mention.reply.companion)} size={20} online />+ <BotGroupAvatar deviceId="" identity={maskIdentity(mention.reply.companion)} size={avatarSizes.reply} online /><Text style={[styles.body, { color: colors.textSecondary }]}>{mention.reply.text}</Text></View> : null}</View>)}@@ -118,10 +120,10 @@ export function GroupMaskCatchupSheet({ visible, mask, onClose, onClosed, onLocaconst makeStyles = (colors: ThemeColors) => StyleSheet.create({content: { padding: spacing.lg, gap: spacing.sm },row: { flexDirection: 'row', alignItems: 'center', minHeight: 48, gap: spacing.sm },- label: { flex: 1, fontSize: typeScale.body, color: colors.textPrimary },- body: { flex: 1, fontSize: typeScale.body, color: colors.textPrimary, lineHeight: 24 },- value: { flexShrink: 1, maxWidth: '55%', fontSize: typeScale.body, color: colors.textSecondary, textAlign: 'right' },- secondary: { fontSize: typeScale.caption, color: colors.textSecondary },+ label: { flex: 1, fontSize: typeScale.body, lineHeight: lineHeight.body, color: colors.textPrimary },+ body: { flex: 1, fontSize: typeScale.body, lineHeight: lineHeight.bodyRelaxed, color: colors.textPrimary },+ value: { flexShrink: 1, maxWidth: '55%', fontSize: typeScale.body, lineHeight: lineHeight.body, color: colors.textSecondary, textAlign: 'right' },+ secondary: { fontSize: typeScale.caption, lineHeight: lineHeight.caption, color: colors.textSecondary },status: { flexDirection: 'row', alignItems: 'center', gap: spacing.xs, minHeight: 44 },time: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: spacing.sm },input: { flex: 1, minHeight: 44, fontSize: typeScale.body, color: colors.textPrimary },