Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r7-l13 preserve newer preview on stale open
Josuéb8495622131e
diff --git a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.tsindex 84767d3c6..d3f3d6ab9 100644--- a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts+++ b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts@@ -916,6 +916,36 @@ describe('workspaceTabs — preview multi-instance by gfsUri (spec 18 §3.B.1)',expect(tab?.preview).toMatchObject({ resourceVersion: 1, reloadVersion: 2 })expect(tab?.preview).not.toHaveProperty('unavailable')})++ it('focuses a preview from a stale row without replacing its newer metadata', () => {+ let state = openFilesTab(createEmptyWorkspaceTabsState(), { id: 'files' })+ state = openPreviewTab(state, {+ id: 'preview-current',+ gfsUri: 'gfs://main/versioned',+ title: 'current.md',+ fileKind: 'markdown',+ byteLength: 80,+ resourceVersion: 8,+ })+ const current = state+ state = openFilesTab(state, { id: 'files-again' })++ const focused = openPreviewTab(state, {+ id: 'preview-stale',+ gfsUri: 'gfs://main/versioned',+ title: 'stale.md',+ fileKind: 'markdown',+ byteLength: 12,+ resourceVersion: 3,+ })++ expect(focused.activeTabId).toBe('preview-current')+ expect(focused.tabs).toBe(current.tabs)+ expect(focused.tabs.find(tab => tab.id === 'preview-current')).toMatchObject({+ title: 'current.md',+ preview: { byteLength: 80, resourceVersion: 8 },+ })+ })})describe('workspaceTabs — new chat (blank) with kind guard', () => {diff --git a/desktop-app/ui/src/lib/workspaceTabs.ts b/desktop-app/ui/src/lib/workspaceTabs.tsindex a7b545f44..7ddda66e9 100644--- a/desktop-app/ui/src/lib/workspaceTabs.ts+++ b/desktop-app/ui/src/lib/workspaceTabs.ts@@ -316,6 +316,15 @@ export function openPreviewTab(...(input.mimeType !== undefined ? { mimeType: input.mimeType } : {}),}if (existing) {+ const currentPreview = existing.preview+ if (+ !currentPreview?.unavailable &&+ input.resourceVersion !== undefined &&+ currentPreview?.resourceVersion !== undefined &&+ input.resourceVersion < currentPreview.resourceVersion+ ) {+ return { tabs: state.tabs, activeTabId: existing.id }+ }// Focus AND refresh the whole payload: unlike the other open* dedupe// branches, a preview tab's payload carries non-key fields (fileKind /// byteLength / mimeType) beyond its `gfsUri` key. If the resource at the URI