Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r7-l2 carry plugin preview version over ipc
Josué761a262b2253
diff --git a/desktop-app/src/__tests__/pluginSdkRuntime.gfsPreview.test.ts b/desktop-app/src/__tests__/pluginSdkRuntime.gfsPreview.test.tsnew file mode 100644index 000000000..3c08ae686--- /dev/null+++ b/desktop-app/src/__tests__/pluginSdkRuntime.gfsPreview.test.ts@@ -0,0 +1,52 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { mkdtemp, rm } from 'node:fs/promises'+import os from 'node:os'+import path from 'node:path'+import type { AppService } from '../appService.js'++vi.mock('electron', () => ({+ app: { isReady: vi.fn(() => false), getPath: vi.fn(() => '/unused') },+ BrowserWindow: class {},+ Notification: class {},+}))++const tempDirs: string[] = []++describe('PluginSdkRuntime GFS preview handoff', () => {+ afterEach(async () => {+ await Promise.all(tempDirs.splice(0).map(dir => rm(dir, { recursive: true, force: true })))+ vi.restoreAllMocks()+ })++ it('includes the resolved resource version in the renderer IPC payload', async () => {+ const userDataDir = await mkdtemp(path.join(os.tmpdir(), 'evenfire-plugin-preview-'))+ tempDirs.push(userDataDir)+ const send = vi.fn()+ const resource = {+ drive: 'main',+ resourceId: 'resource-1',+ parentResourceId: null,+ rid: 'rid-1',+ gfsUri: 'gfs://main/rid-1',+ name: 'README.md',+ kind: 'file',+ version: 8,+ bytes: 80,+ }+ const service = {+ resolveGfsUri: vi.fn().mockResolvedValue(resource),+ } as unknown as AppService+ const runtimeModule = await import('../pluginSdkRuntime.js')+ const runtime = new runtimeModule.PluginSdkRuntime({+ service,+ getMainWindow: () => ({ isDestroyed: () => false, webContents: { send } }) as never,+ userDataDir,+ })++ await expect(runtime.openGfsResource(resource.gfsUri)).resolves.toEqual({ opened: true })+ expect(send).toHaveBeenCalledWith(+ 'pluginSdk:openGfsResource',+ expect.objectContaining({ gfsUri: resource.gfsUri, version: 8 })+ )+ })+})diff --git a/desktop-app/src/pluginSdkRuntime.ts b/desktop-app/src/pluginSdkRuntime.tsindex 7fb39bd3d..c1550ae14 100644--- a/desktop-app/src/pluginSdkRuntime.ts+++ b/desktop-app/src/pluginSdkRuntime.ts@@ -320,6 +320,7 @@ export class PluginSdkRuntime {name: resource.name,kind: resource.kind,bytes: typeof resource.bytes === 'number' ? resource.bytes : null,+ version: resource.version,})return { opened: true }}diff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.tsindex 34101cfad..3d449b81a 100644--- a/desktop-app/src/preload.ts+++ b/desktop-app/src/preload.ts@@ -749,11 +749,23 @@ const clerum = Object.freeze({return () => ipcRenderer.off('pluginSdk:consentCancelled', listener)},onOpenGfsResource: (- callback: (args: { gfsUri: string; name: string; kind: string; bytes: number | null }) => void+ callback: (args: {+ gfsUri: string+ name: string+ kind: string+ bytes: number | null+ version?: number+ }) => void) => {const listener = (_event: unknown,- args: { gfsUri: string; name: string; kind: string; bytes: number | null }+ args: {+ gfsUri: string+ name: string+ kind: string+ bytes: number | null+ version?: number+ }) => callback(args)ipcRenderer.on('pluginSdk:openGfsResource', listener)return () => ipcRenderer.off('pluginSdk:openGfsResource', listener)diff --git a/desktop-app/src/renderer.d.ts b/desktop-app/src/renderer.d.tsindex 3bc69ca54..49063dc8d 100644--- a/desktop-app/src/renderer.d.ts+++ b/desktop-app/src/renderer.d.ts@@ -800,6 +800,7 @@ declare global {name: stringkind: stringbytes: number | null+ version?: number}) => void) => () => voidonNotificationClicked: (diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 2ca343eba..8ec86e8d0 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -888,6 +888,7 @@ export function App() {gfsUri: resource.gfsUri,name: resource.name,bytes: resource.bytes ?? 0,+ version: resource.version,}): nullif (preview?.kind === 'image') {diff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsxindex d8675cdb9..7adc95508 100644--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx@@ -202,6 +202,7 @@ function makeController(overrides: Partial<AppController> = {}): AppController {gfsUri: preview.gfsUri,fileKind: preview.kind,byteLength: preview.bytes,+ ...(preview.version !== undefined ? { resourceVersion: preview.version } : {}),...('mimeType' in preview ? { mimeType: preview.mimeType } : {}),}))@@ -1234,6 +1235,10 @@ describe('App plugin previewable handoff — routes through resolveGfsPreview (R{ uri: 'gfs://main/vid1', kind: 'video' },])+ expect(previewTabs().map(t => t.preview?.resourceVersion)).toEqual([+ mdPayload.version,+ videoPayload.version,+ ])// No leftover files tab seeded with a previewable URI — the R1-H3 loop.expect(filesTabs()).toHaveLength(0)expect(currentController.openFilesSection).not.toHaveBeenCalled()diff --git a/desktop-app/ui/src/gfs/__fixtures__/gfsProducerFixtures.ts b/desktop-app/ui/src/gfs/__fixtures__/gfsProducerFixtures.tsindex 3d56c7b96..22f062dd1 100644--- a/desktop-app/ui/src/gfs/__fixtures__/gfsProducerFixtures.ts+++ b/desktop-app/ui/src/gfs/__fixtures__/gfsProducerFixtures.ts@@ -160,10 +160,10 @@ type OpenGfsResourcePayload = Parameters<* The `onOpenGfsResource` wire payload as `pluginSdkRuntime.openGfsResource`* emits it: it resolves the URI with the user's session (the real* `GfsClient.resolveUri` below — envelope unwrap, the same seam `download` uses)- * and then projects four fields onto the wire. That runtime imports `electron`+ * and then projects five fields onto the wire. That runtime imports `electron`* at module load, so it cannot be driven from a jsdom renderer test (the awkward* case T1 anticipates); the resolve half runs through this repo's REAL producer- * and the runtime's four-field projection is mirrored here in ONE place —+ * and the runtime's projection is mirrored here in ONE place —* `bytes` is coerced to `null` when the resolved resource omits it, exactly as* the runtime does — then structured-cloned to model the IPC boundary.*/@@ -177,6 +177,7 @@ export async function openGfsResourcePayload(name: resolved.name,kind: resolved.kind,bytes: typeof resolved.bytes === 'number' ? resolved.bytes : null,+ version: resolved.version,})}