Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): r7-l10 make unavailable plugin previews idempotent

Josué083f82478077
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 8ec86e8d0..b70c119d3 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -42,6 +42,7 @@ import { EntityChangeRegistry } from '@lib/entityChangeRegistry'
import {
authoritativeGfsStatus,
expireGfsPreviewTabs,
+ markPluginGfsPreviewUnavailable,
shouldRevalidateGfsQuery,
} from '@lib/gfsEntityChangeState'
import { resolveGfsPreview } from '@lib/gfsPreview'
@@ -986,9 +987,7 @@ export function App() {
})
)
setPluginGfsPreview(current =>
- isCurrentGeneration() && current?.gfsUri === gfsUri
- ? { ...current, unavailable: true, reloadVersion: current.reloadVersion + 1 }
- : current
+ isCurrentGeneration() ? markPluginGfsPreviewUnavailable(current, gfsUri) : current
)
return
}
@@ -1012,7 +1011,7 @@ export function App() {
)
return current
if (preview.kind !== 'image') {
- return { ...current, unavailable: true, reloadVersion: current.reloadVersion + 1 }
+ return markPluginGfsPreviewUnavailable(current, gfsUri)
}
if (
!current.unavailable &&
@@ -1053,9 +1052,7 @@ export function App() {
previewRetryAttemptRef.current.clear()
setWorkspaceTabs(expireGfsPreviewTabs)
setPluginGfsPreview(current =>
- current && !current.unavailable
- ? { ...current, unavailable: true, reloadVersion: current.reloadVersion + 1 }
- : current
+ markPluginGfsPreviewUnavailable(current, current?.gfsUri ?? '')
)
void queryClient.removeQueries({ queryKey: desktopQueryKeys.gfsRoot })
return
@@ -1069,9 +1066,7 @@ export function App() {
})
)
setPluginGfsPreview(current =>
- isCurrentGeneration() && current?.gfsUri === gfsUri
- ? { ...current, unavailable: true, reloadVersion: current.reloadVersion + 1 }
- : current
+ isCurrentGeneration() ? markPluginGfsPreviewUnavailable(current, gfsUri) : current
)
void queryClient.invalidateQueries({
queryKey: desktopQueryKeys.gfsRoot,
diff --git a/desktop-app/ui/src/lib/__tests__/gfsEntityChangeState.test.ts b/desktop-app/ui/src/lib/__tests__/gfsEntityChangeState.test.ts
new file mode 100644
index 000000000..165898641
--- /dev/null
+++ b/desktop-app/ui/src/lib/__tests__/gfsEntityChangeState.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from 'vitest'
+import { markPluginGfsPreviewUnavailable } from '../gfsEntityChangeState'
+
+describe('plugin preview unavailable reconciliation', () => {
+ it('increments the reload identity once and preserves it on repeated invalidation', () => {
+ const available = {
+ gfsUri: 'gfs://main/image',
+ name: 'diagram.png',
+ bytes: 32,
+ mimeType: 'image/png',
+ version: 8,
+ reloadVersion: 4,
+ }
+
+ const unavailable = markPluginGfsPreviewUnavailable(available, available.gfsUri)
+ expect(unavailable).toMatchObject({ unavailable: true, reloadVersion: 5 })
+ expect(markPluginGfsPreviewUnavailable(unavailable, available.gfsUri)).toBe(unavailable)
+ })
+
+ it('does not alter an unrelated or absent plugin preview', () => {
+ const current = {
+ gfsUri: 'gfs://main/visible.png',
+ name: 'visible.png',
+ bytes: 8,
+ mimeType: 'image/png',
+ reloadVersion: 1,
+ }
+
+ expect(markPluginGfsPreviewUnavailable(current, 'gfs://main/other.png')).toBe(current)
+ expect(markPluginGfsPreviewUnavailable(null, 'gfs://main/visible.png')).toBeNull()
+ })
+})
diff --git a/desktop-app/ui/src/lib/gfsEntityChangeState.ts b/desktop-app/ui/src/lib/gfsEntityChangeState.ts
index 1a63aec44..1258185af 100644
--- a/desktop-app/ui/src/lib/gfsEntityChangeState.ts
+++ b/desktop-app/ui/src/lib/gfsEntityChangeState.ts
@@ -31,3 +31,11 @@ export function expireGfsPreviewTabs(state: WorkspaceTabsState): WorkspaceTabsSt
state
)
}
+
+/** Make the plugin overlay unavailable once; repeated unchanged invalidations are idempotent. */
+export function markPluginGfsPreviewUnavailable<
+ T extends { gfsUri: string; reloadVersion: number; unavailable?: boolean },
+>(current: T | null, gfsUri: string): T | null {
+ if (!current || current.gfsUri !== gfsUri || current.unavailable) return current
+ return { ...current, unavailable: true, reloadVersion: current.reloadVersion + 1 }
+}