Skip to content

The agent that grows with you

fix(desktop): restore the remote-owner image routing test

teknium1f6d0e0c20d9a
diff --git a/apps/desktop/src/lib/media-dimensions.test.ts b/apps/desktop/src/lib/media-dimensions.test.ts
index 72f83507a5e..e1d7d18c522 100644
--- a/apps/desktop/src/lib/media-dimensions.test.ts
+++ b/apps/desktop/src/lib/media-dimensions.test.ts
@@ -1,6 +1,7 @@
-import { expect, it } from 'vitest'
+import { expect, it, vi } from 'vitest'
import type { HermesConnection } from '@/global'
+import { $connection } from '@/store/session'
import {
getMediaImageDimensions,
@@ -8,9 +9,27 @@ import {
mediaImageKey,
rememberMediaImageDimensions,
rememberMediaImageFailure,
+ resolveMediaDisplaySrc,
validImageDimensions
} from './media'
+it('reads a remote-owned image through its gateway, never the local file reader', async () => {
+ const readFileDataUrl = vi.fn(async () => 'data:local')
+ const api = vi.fn(async () => ({ dataUrl: 'data:remote' }))
+ vi.stubGlobal('hermesDesktop', { readFileDataUrl, api })
+ // A local foreground must not pull a remote tile's path off this disk.
+ $connection.set({ connectionId: 'local', mode: 'local', profile: 'default' } as HermesConnection)
+
+ try {
+ await expect(resolveMediaDisplaySrc('/srv/out.png', { connectionId: 'remote-1' })).resolves.toBe('data:remote')
+ expect(api).toHaveBeenCalledWith({ connectionId: 'remote-1', path: '/api/fs/read-data-url?path=%2Fsrv%2Fout.png' })
+ expect(readFileDataUrl).toHaveBeenCalledTimes(0)
+ } finally {
+ $connection.set(null)
+ vi.unstubAllGlobals()
+ }
+})
+
it('shares proven path aliases only within an owner and bounds regenerated metadata by LRU', () => {
const a = { connectionId: 'a', profile: 'work', mode: 'remote' } as HermesConnection
const b = { ...a, connectionId: 'b' }