Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
WIP: preserve #4358 merge against 6210df89 before current-main sync
Dante60825607c2a0
diff --cc apps/mobile/src/__tests__/historyViewProvider.test.tsxindex 566314bc30,b116517213..66917fa568--- a/apps/mobile/src/__tests__/historyViewProvider.test.tsx+++ b/apps/mobile/src/__tests__/historyViewProvider.test.tsx@@@ -4,9 -4,9 +4,10 @@@ import { createRoot, type Root } from 'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import {DEVICE_LINK_CAPABILITY_HISTORY_VIEW_V1,+ SHARED_TASK_CAPABILITY,type DeviceLinkClient,type DeviceLinkStatus,+ type DeviceView,type LinkAcceptPayload,type PresenceSnapshot,} from '@cindy/device-link';@@@ -119,75 -114,22 +122,91 @@@ beforeEach(async () =>});afterEach(async () => { await act(async () => root.unmount()); });+describe('Provider device roster reads', () => {+ it('starts a fresh snapshot when Home joins a recovery read that predates its presence fence', async () => {+ const stale = deferredRoster();+ const current = deferredRoster();+ auth.apiFetch.mockReturnValueOnce(stale.promise).mockReturnValueOnce(current.promise);+ const client = transport.clients[0];++ await act(async () => {+ client.status = 'online';+ client.statusChanged('online');+ });+ expect(auth.apiFetch).toHaveBeenCalledTimes(1);++ await act(async () => client.presenceChanged({+ deviceId: 'desktop', deviceName: 'Desktop', platform: 'darwin', appVersion: 'test',+ online: true, remoteControlEnabled: true, busy: false, lastSeenAt: 1,+ }));+ const joined = context.readDeviceList();+ expect(auth.apiFetch).toHaveBeenCalledTimes(1);+ const fresh = context.readDeviceList({ fresh: true });+ expect(auth.apiFetch).toHaveBeenCalledTimes(2);++ const desktop: DeviceView = {+ deviceId: 'desktop', name: 'Desktop', platform: 'darwin', appVersion: 'test',+ online: true, remoteControlEnabled: true, busy: false, lastSeenAt: new Date(1).toISOString(),+ isSelf: false,+ };+ await act(async () => {+ stale.resolve({ devices: [] });+ current.resolve({ devices: [desktop] });+ });++ expect(await joined).toEqual({ devices: [] });+ expect(await fresh).toEqual({ devices: [desktop] });+ });++ it('prevents an older roster response from superseding a newer fresh read', async () => {+ const stale = deferredRoster();+ const current = deferredRoster();+ auth.apiFetch.mockReturnValueOnce(stale.promise).mockReturnValueOnce(current.promise);+ const client = transport.clients[0];++ await act(async () => {+ client.status = 'online';+ client.statusChanged('online');+ });+ const joined = context.readDeviceList();+ const fresh = context.readDeviceList({ fresh: true });++ const offlineDesktop: DeviceView = {+ deviceId: 'desktop', name: 'Desktop', platform: 'darwin', appVersion: 'test',+ online: false, remoteControlEnabled: true, busy: false, lastSeenAt: new Date(1).toISOString(),+ isSelf: false,+ };+ const onlineDesktop: DeviceView = { ...offlineDesktop, online: true };+ await act(async () => {+ stale.resolve({ devices: [offlineDesktop] });+ });+ expect(context.getPresenceAvailability('desktop')).toBeNull();+ await act(async () => {+ current.resolve({ devices: [onlineDesktop] });+ });++ expect(await joined).toEqual({ devices: [offlineDesktop] });+ expect(await fresh).toEqual({ devices: [onlineDesktop] });+ expect(context.getPresenceAvailability('desktop')).toBe(true);+ });+});++ describe('Provider shared-task relay compatibility', () => {+ it('distinguishes an old online relay from disconnection and re-negotiates after upgrade', async () => {+ const client = transport.clients[0];+ expect(context.sharedTaskAvailable).toBeUndefined();+ await act(async () => client.statusChanged('online'));+ expect(context.sharedTaskAvailable).toBe(false);+ await act(async () => client.statusChanged('connecting'));+ expect(context.sharedTaskAvailable).toBeUndefined();+ client.serverCapabilities = [SHARED_TASK_CAPABILITY];+ await act(async () => client.statusChanged('online'));+ expect(context.sharedTaskAvailable).toBe(true);+ await act(async () => client.statusChanged('stopped'));+ expect(context.sharedTaskAvailable).toBeUndefined();+ });+ });+describe('Provider network recovery priority', () => {const wifi = { type: 'WIFI', isConnected: true, isInternetReachable: true };it('coalesces equal hints but expedites transport changes and offline recovery', async () => {