Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): cover Todo navigation and preserve icon tokens
zqchris0819b2eafe4d
diff --git a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsxindex 0f4d5b9c48..71fcced9ee 100644--- a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx+++ b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx@@ -9,7 +9,7 @@ import { useHostManagedSession } from '@/session/hostManagedSession';import type { RemoteResource } from '@cindy/device-link';const h = vi.hoisted(() => ({- profile: {} as any, dismiss: vi.fn(), chooseMode: vi.fn(), screenOptions: [] as Array<Record<string, unknown>>,+ todos: {} as any, profile: {} as any, dismiss: vi.fn(), chooseMode: vi.fn(), screenOptions: [] as Array<Record<string, unknown>>,auth: { accountGeneration: 1, user: null },}));vi.mock('react-native', () => ({@@ -27,10 +27,11 @@ vi.mock('@/theme', async () => {const tokens = await import('@/theme/tokens');return { ...tokens, useTheme: () => ({ colors: tokens.lightColors }), useThemedStyles: (fn: any) => fn(tokens.lightColors) };});-vi.mock('lucide-react-native', () => ({ ChevronLeft: () => null, Settings2: () => null }));+vi.mock('lucide-react-native', () => ({ ChevronLeft: () => null, Settings2: () => null, ListTodo: () => null }));vi.mock('@/session/HomeHeaderGlassButton', () => ({ HomeHeaderGlassButton: ({ onPress, testID, children, disabled }: any) =>createElement('button', { onClick: onPress, disabled, 'data-testid': testID }, children) }));vi.mock('@/session/CompanionPresenceRing', () => ({ CompanionPresenceRing: ({ active }: any) => active ? createElement('i', { 'data-testid': 'ring' }) : null }));+vi.mock('@/session/CompanionTodos', () => ({ CompanionTodos: (props: unknown) => { h.todos = props; return null; } }));vi.mock('@/session/CompanionProfileSheet', () => ({ CompanionProfileSheet: (props: unknown) => { h.profile = props; return null; } }));vi.mock('@/session/useTeammateNavigation', () => ({ useTeammateNavigation: () => ({ chooseMode: h.chooseMode }) }));import { CompanionHeader } from '@/session/CompanionHeader';@@ -39,7 +40,7 @@ let root: Root; let host: HTMLDivElement;const resource = { ref: { kind: 'bot', collectionId: 'bots', id: 'bot' }, display: { title: 'Cindy' } } as RemoteResource;const button = (id: string) => host.querySelector<HTMLButtonElement>(`[data-testid="${id}"]`)!;beforeEach(() => {- vi.clearAllMocks(); h.auth.accountGeneration = 1; h.profile = {}; h.screenOptions = [];+ vi.clearAllMocks(); h.auth.accountGeneration = 1; h.profile = {}; h.todos = {}; h.screenOptions = [];host = document.createElement('div'); root = createRoot(host);});afterEach(() => act(() => root.unmount()));@@ -167,3 +168,24 @@ it('opens learning links in the existing profile sheet on the requested page', asettingsRequest={{ page: 'capabilities', sequence: 2 }} />));expect(h.profile).toMatchObject({ visible: true, initialPage: 'capabilities' });});++it('only opens Todo for an advertised host capability after entry validation and closes it on account change', async () => {+ const props = { resource, deviceId: 'pc', deviceName: 'PC', online: true, onBack: vi.fn(), onSearch: vi.fn() };+ await act(async () => root.render(<CompanionHeader {...props} />));+ expect(button('companion.todos.open')).toBeNull();+ const withTodos: RemoteResource = { ...resource, links: [{ rel: 'todos', label: 'Todo', target: { kind: 'resource', ref: { collectionId: 'teammates', kind: 'bot', id: 'todos:bot' } } }] };+ await act(async () => root.render(<CompanionHeader {...props} resource={withTodos} controlsReady={false} />));+ expect(button('companion.todos.open').disabled).toBe(true);+ await act(async () => button('companion.todos.open').click());+ expect(h.todos.visible).toBe(false);+ await act(async () => root.render(<CompanionHeader {...props} resource={withTodos} />));+ await act(async () => button('companion.todos.open').click());+ expect(h.todos).toMatchObject({ visible: true, deviceId: 'pc', botId: 'bot', online: true });+ expect(h.profile.visible).toBe(false);+ await act(async () => h.todos.onClose());+ expect(h.todos.visible).toBe(false);+ await act(async () => button('companion.todos.open').click());+ h.auth.accountGeneration++;+ await act(async () => root.render(<CompanionHeader {...props} resource={withTodos} />));+ expect(h.todos.visible).toBe(false);+});diff --git a/apps/mobile/src/session/CompanionHeader.tsx b/apps/mobile/src/session/CompanionHeader.tsxindex 9c8d2d022e..ba2a755652 100644--- a/apps/mobile/src/session/CompanionHeader.tsx+++ b/apps/mobile/src/session/CompanionHeader.tsx@@ -18,7 +18,8 @@ const PRESENCE_DOT = 6;/*** 伙伴私聊顶栏(C1,与群聊顶栏同一个 ChatIdentityHeader):返回 + 身份(32 头像、名字、在线点与- * 电脑名)+ 伙伴设置。点身份区与设置按钮都打开伙伴资料;切换伙伴回到列表里做。+ * 电脑名)+ 伙伴设置;宿主提供 Todo 能力时增加独立入口。点身份区与设置按钮都打开+ * 伙伴资料;切换伙伴回到列表里做。*/export function CompanionHeader(props: {resource: RemoteResource; deviceId: string; deviceName: string; online: boolean; controlsReady?: boolean;@@ -60,7 +61,7 @@ function CompanionHeaderContent({ resource, deviceId, deviceName, online, controcontrolsReady={controlsReady}onBack={onBack}onOpenSettings={() => { setInitialPage('home'); setProfile(true); }}- accessory={resource.links?.some(link=>link.target.kind==='resource'&&link.target.ref.id==='todos:'+resource.ref.id)?<HomeHeaderGlassButton testID="companion.todos.open" accessibilityLabel={t('devices.teammateTodo.title')} onPress={()=>setTodos(true)}><ListTodo size={iconSize.lg} strokeWidth={iconStroke.regular} color={colors.textPrimary}/></HomeHeaderGlassButton>:undefined}+ accessory={resource.links?.some(link=>link.target.kind==='resource'&&link.target.ref.id==='todos:'+resource.ref.id)?<HomeHeaderGlassButton testID="companion.todos.open" disabled={!controlsReady} accessibilityLabel={t('devices.teammateTodo.title')} onPress={()=>setTodos(true)}><ListTodo size={iconSize.lg} strokeWidth={iconStroke.regular} color={colors.textPrimary}/></HomeHeaderGlassButton>:undefined}settingsLabel={t('devices.companionProfile.settingsTitle')} /><CompanionTodos visible={todos} onClose={()=>setTodos(false)} botId={resource.ref.id} deviceId={deviceId} deviceName={deviceName} online={online}/><CompanionProfileSheet initialPage={initialPage} visible={profile} onClose={() => setProfile(false)} onClosed={() => { const action = pending.current; pending.current = null; action?.(); }}diff --git a/apps/mobile/src/session/CompanionTodoRow.tsx b/apps/mobile/src/session/CompanionTodoRow.tsxindex 879ecce177..c88d5de7ed 100644--- a/apps/mobile/src/session/CompanionTodoRow.tsx+++ b/apps/mobile/src/session/CompanionTodoRow.tsx@@ -1,7 +1,7 @@import { Pressable, View } from 'react-native';import { MoreHorizontal } from 'lucide-react-native';import { Text } from '@/components/AppText';-import { useTheme, useThemedStyles } from '@/theme';+import { iconSize, useTheme, useThemedStyles } from '@/theme';import {effectiveTodoDeadline,todoDateLabel,@@ -94,7 +94,7 @@ export function CompanionTodoRow({onPress={onMore}style={styles.icon}>- <MoreHorizontal color={colors.textSecondary} size={20} />+ <MoreHorizontal color={colors.textSecondary} size={iconSize.action} /></Pressable></View></View>diff --git a/apps/mobile/src/session/CompanionTodos.tsx b/apps/mobile/src/session/CompanionTodos.tsxindex fb191cacd1..5b93801f30 100644--- a/apps/mobile/src/session/CompanionTodos.tsx+++ b/apps/mobile/src/session/CompanionTodos.tsx@@ -11,6 +11,7 @@ import { useDeviceLink } from '@/device-link/DeviceLinkContext';import { getRemoteResource, invokeRemoteResourceAction } from '@/device-link/remoteResources';import { Text, TextInput } from '@/components/AppText';import {+ iconSize,fontWeight,lineHeight,radius,@@ -568,7 +569,7 @@ function CompanionTodosContent({ visible, onClose, deviceId, deviceName, botId,accessibilityLabel={tr('new')}onPress={() => edit(null, 'edit')}>- <Plus color={colors.textPrimary} size={20} />+ <Plus color={colors.textPrimary} size={iconSize.action} /></Pressable></View><View style={styles.toolbar}>@@ -655,9 +656,9 @@ function CompanionTodosContent({ visible, onClose, deviceId, deviceName, botId,}}>{filter.view === 'done' ? (- <ChevronDown color={colors.textSecondary} size={16} />+ <ChevronDown color={colors.textSecondary} size={iconSize.md} />) : (- <ChevronRight color={colors.textSecondary} size={16} />+ <ChevronRight color={colors.textSecondary} size={iconSize.md} />)}<Text style={styles.caption}>{tr('done')} · {page.completedTotal}