Skip to content

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

TypeScript

fix(desktop-app): r8-l7 label and close unavailable image dialog

Josué57ed82aa3aec
diff --git a/desktop-app/ui/src/components/GfsImagePreview/GfsImagePreview.test.tsx b/desktop-app/ui/src/components/GfsImagePreview/GfsImagePreview.test.tsx
index 9384d8f83..64eba5421 100644
--- a/desktop-app/ui/src/components/GfsImagePreview/GfsImagePreview.test.tsx
+++ b/desktop-app/ui/src/components/GfsImagePreview/GfsImagePreview.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { GfsImagePreview } from './index'
describe('GfsImagePreview layout', () => {
@@ -114,4 +114,26 @@ describe('GfsImagePreview layout', () => {
expect(dialog.getAttribute('aria-labelledby')).toBe(title.id)
expect(screen.getByRole('button', { name: 'Close image preview' })).toBeTruthy()
})
+
+ it('keeps the authoritative unavailable shell named and closable without fetching bytes', () => {
+ const onClose = vi.fn()
+ const downloadPreview = vi.mocked(window.clerum.gfs.downloadPreview)
+ render(
+ <GfsImagePreview
+ byteLength={3}
+ fileName="diagram.png"
+ gfsUri="gfs://main/image-1"
+ mimeType="image/png"
+ onClose={onClose}
+ unavailable
+ />
+ )
+
+ const dialog = screen.getByRole('dialog', { name: 'File unavailable' })
+ const title = within(dialog).getByRole('heading', { name: 'File unavailable', level: 3 })
+ expect(dialog.getAttribute('aria-labelledby')).toBe(title.id)
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Close image preview' }))
+ expect(onClose).toHaveBeenCalledOnce()
+ expect(downloadPreview).not.toHaveBeenCalled()
+ })
})
diff --git a/desktop-app/ui/src/components/GfsImagePreview/index.tsx b/desktop-app/ui/src/components/GfsImagePreview/index.tsx
index c89772834..c19e9838d 100644
--- a/desktop-app/ui/src/components/GfsImagePreview/index.tsx
+++ b/desktop-app/ui/src/components/GfsImagePreview/index.tsx
@@ -1,7 +1,6 @@
import { useEffect, useId, useRef } from 'react'
import { createPortal } from 'react-dom'
import { Button } from '@components/Common'
-import { EmptyState } from '@components/Common'
import { IconClose } from '@components/SidebarNav/icons'
import { useWorkspaceModalStyle } from '@hooks/useWorkspaceModalStyle'
import { GfsImagePreviewBody } from './Body'
@@ -36,6 +35,20 @@ export function GfsImagePreview({
return () => window.removeEventListener('keydown', handleKeyDown)
}, [onClose])
+ const closeButton = (
+ <Button
+ className="da-gfs-image-preview-dialog__close"
+ data-preview-close
+ ref={closeButtonRef}
+ aria-label="Close image preview"
+ color="neutral"
+ onClick={onClose}
+ variant="ghost"
+ >
+ <IconClose width={18} height={18} />
+ </Button>
+ )
+
return createPortal(
<div
className="da-gfs-image-preview-modal"
@@ -52,7 +65,17 @@ export function GfsImagePreview({
aria-labelledby={titleId}
>
{unavailable ? (
- <EmptyState title="File unavailable" body="This item is no longer available." />
+ <>
+ <header className="da-gfs-image-preview-dialog__header">
+ <h3 id={titleId}>File unavailable</h3>
+ {closeButton}
+ </header>
+ <div className="da-gfs-image-preview-dialog__body">
+ <div className="empty-state">
+ <p className="muted">This item is no longer available.</p>
+ </div>
+ </div>
+ </>
) : (
<GfsImagePreviewBody
key={`${gfsUri}:${reloadVersion ?? 0}`}
@@ -62,19 +85,7 @@ export function GfsImagePreview({
mimeType={mimeType}
onDownloadError={onDownloadError}
titleId={titleId}
- headerActions={
- <Button
- className="da-gfs-image-preview-dialog__close"
- data-preview-close
- ref={closeButtonRef}
- aria-label="Close image preview"
- color="neutral"
- onClick={onClose}
- variant="ghost"
- >
- <IconClose width={18} height={18} />
- </Button>
- }
+ headerActions={closeButton}
/>
)}
</section>