Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
chore: 同步主干并保留远程媒体双方回归测试
Dashf2d7682163eb
diff --cc apps/mobile/src/__tests__/remoteMedia.test.tsindex 37d39ef774,da5a927a78..73050a71cb--- a/apps/mobile/src/__tests__/remoteMedia.test.ts+++ b/apps/mobile/src/__tests__/remoteMedia.test.ts@@@ -12,42 -12,25 +12,61 @@@ import} from "@/session/remoteMedia";describe("mobile remote media", () => {+ it('retains a background fallback and releases its staging copy and cloud object', async () => {+ const { recordPeerMedia } = await import('@/device-link/peerFileRegistry');+ const local = { ossKey: '', mimeType: 'application/pdf', size: 3 };+ const dispose = vi.fn();+ recordPeerMedia(local, 'file:///background/pdf', dispose);+ let retain!: NonNullable<import('@/session/remoteMedia').MobileRemoteMediaFetchOptions['retainBackground']>;+ const discardBackgroundOssKey = vi.fn();+ await resolveMobileRemoteMedia({ kind: 'file', url: 'xdt-file://open?path=/a.pdf' }, {+ fetchRemoteMedia: async (_url, options) => {+ retain = options!.retainBackground!;+ return { ...local, inlineBase64: 'YWJj' };+ },+ presignGet: async () => ({ getUrl: 'https://oss/new', expiresAt: '2099-01-01T00:00:00Z' }),+ }, { stream: false, discardBackgroundOssKey });+ const cacheDownload = vi.fn(async () => local);+ await retain({ ...local, ossKey: 'oss/new', cacheDownload });+ expect(cacheDownload).toHaveBeenCalledWith('https://oss/new');+ expect(dispose).toHaveBeenCalledOnce();+ expect(discardBackgroundOssKey).toHaveBeenCalledWith('oss/new');+ });+ it('returns a completed fallback copy while preserving ownership of the OSS object', async () => {+ const { recordPeerMedia, releasePeerMedia } = await import('@/device-link/peerFileRegistry');+ const local = { ossKey: '', mimeType: 'application/pdf', size: 3 };+ recordPeerMedia(local, 'file:///cached/pdf', () => {});+ const cacheDownload = vi.fn(async () => local);+ const onOssKey = vi.fn();+ try {+ const result = await resolveMobileRemoteMedia({ kind: 'file', url: 'xdt-file://open?path=/a.pdf' }, {+ fetchRemoteMedia: async () => ({ ossKey: 'oss/file', size: 3, mimeType: local.mimeType, cacheDownload }),+ presignGet: async () => ({ getUrl: 'https://oss/file', expiresAt: '2099-01-01T00:00:00Z' }),+ }, { stream: false, onOssKey });+ expect(result).toMatchObject({ url: 'file:///cached/pdf', ossKey: 'oss/file' });+ expect(cacheDownload).toHaveBeenCalledWith('https://oss/file');+ expect(onOssKey).toHaveBeenCalledExactlyOnceWith('oss/file');+ } finally { releasePeerMedia('file:///cached/pdf'); }+ });+ // Unit regression: retained sent images must serve original and thumbnail requests+ // offline. Existing tests covered only remote downloads and already-resolved copies.+ it.each([false, true])('reads a retained sent image offline (thumbnail=%s), with forced repair bypass', async (thumbnail) => {+ const findLocalImage = vi.fn(async () => ({ uri: 'file:///doc/sent.png', size: 100, mimeType: 'image/png' }));+ const fetchRemoteMedia = vi.fn(async () => { throw new Error('NOT_CONNECTED'); });+ const presignGet = vi.fn();+ const media = { kind: 'image' as const, url: `cindy-media://blobs/${'a'.repeat(64)}.png` };+ const deps = { findLocalImage, fetchRemoteMedia, presignGet };+ await expect(resolveMobileRemoteMedia(media, deps, { thumbnail })).resolves.toMatchObject({+ url: 'file:///doc/sent.png', size: 100, ossKey: '', expiresAt: REMOTE_MEDIA_NEVER_EXPIRES,+ });+ expect(fetchRemoteMedia).not.toHaveBeenCalled();+ expect(presignGet).not.toHaveBeenCalled();+ await expect(resolveMobileRemoteMedia(media, deps, { skipCache: true })).rejects.toThrow('NOT_CONNECTED');+ expect(findLocalImage).toHaveBeenCalledOnce();+ findLocalImage.mockRejectedValueOnce(new Error('unreadable local file'));+ await expect(resolveMobileRemoteMedia(media, deps)).rejects.toThrow('NOT_CONNECTED');+ });+it.each(['DEVICE_OFFLINE', 'NOT_CONNECTED', 'DEVICE_LINK_NOT_CONNECTED', 'PEER_OFFLINE'])('recognizes the structured %s code even when its message has no code', (code) => {expect(mediaLoadFailureKey(Object.assign(new Error('remote device is unavailable'), { code }))).toBe('message.lightbox.deviceOffline');