diff --git a/locales/en.json b/locales/en.json index 171e7fd15..96375e25c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -107,7 +107,23 @@ "filter": "Filter", "signedOutTitle": "Log in to see your assets", "signedOutBody": "Assets that you make in Comfy Cloud show here.", - "signIn": "Log in to Comfy Cloud" + "signIn": "Log in to Comfy Cloud", + "inspect": "Inspect {name}", + "detail": { + "tags": "Tags", + "tagsHint": "Tags are edited in ComfyUI.", + "createdAt": "Created {date}", + "fit": "Fit", + "zoom": "Zoom", + "zoomLevel": "Zoom: {level}" + }, + "kindSingular": { + "image": "Image", + "video": "Video", + "audio": "Audio", + "3d": "3D", + "file": "File" + } }, "home": { "title": "Welcome. Let's create!", diff --git a/locales/zh.json b/locales/zh.json index dae5dbdc0..68f4beb74 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -107,7 +107,23 @@ "filter": "筛选", "signedOutTitle": "登录以查看你的资产", "signedOutBody": "你在 Comfy Cloud 中生成的资产会显示在这里。", - "signIn": "登录 Comfy Cloud" + "signIn": "登录 Comfy Cloud", + "inspect": "查看 {name}", + "detail": { + "tags": "标签", + "tagsHint": "标签在 ComfyUI 中编辑。", + "createdAt": "创建于 {date}", + "fit": "适应", + "zoom": "缩放", + "zoomLevel": "缩放:{level}" + }, + "kindSingular": { + "image": "图片", + "video": "视频", + "audio": "音频", + "3d": "3D", + "file": "文件" + } }, "home": { "title": "欢迎。开始创作吧!", diff --git a/src/renderer/src/composables/useVirtualMasonry.ts b/src/renderer/src/composables/useVirtualMasonry.ts index 6f6309ccd..352c33b8c 100644 --- a/src/renderer/src/composables/useVirtualMasonry.ts +++ b/src/renderer/src/composables/useVirtualMasonry.ts @@ -88,5 +88,9 @@ export function useVirtualMasonry(options: VirtualMasonryOptions) { virtualizer.value.measureElement(el instanceof Element ? el : null) } - return { cards, galleryStyle, cardStyle, measureCard } + function scrollToIndex(index: number): void { + virtualizer.value.scrollToIndex(index, { align: 'auto' }) + } + + return { cards, galleryStyle, cardStyle, measureCard, scrollToIndex } } diff --git a/src/renderer/src/panel/AssetsView.test.ts b/src/renderer/src/panel/AssetsView.test.ts index ce8605ad5..98f7625a6 100644 --- a/src/renderer/src/panel/AssetsView.test.ts +++ b/src/renderer/src/panel/AssetsView.test.ts @@ -111,6 +111,20 @@ function assetNames(wrapper: Awaited>): string[] .map((tip) => tip.props('text') as string) } +function viewer(): HTMLElement | null { + return document.querySelector('[data-testid="output-detail"]') +} + +function viewerTitle(): string { + return viewer()?.querySelector('h2')?.textContent?.trim() ?? '' +} + +async function press(key: string): Promise { + const target = document.activeElement ?? document.body + target.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true })) + await flushPromises() +} + beforeEach(() => { page = document.createElement('div') page.dataset.panelPage = '' @@ -535,4 +549,80 @@ describe('AssetsView', () => { message: 'b.svg' }) }) + + it('opens a picture full size when its card is clicked, and puts focus back on the card when Escape closes it', async () => { + const wrapper = await mountAssets([ + asset('/out/forest.png', 'forest.png', 'image', { + previewUrl: 'comfy-output://file/full', + thumbnailUrl: 'comfy-output://file/full?thumbnail=1' + }) + ]) + const card = wrapper.get('[data-testid="asset-open-/out/forest.png"]') + + await card.trigger('click') + await flushPromises() + + expect(viewerTitle()).toBe('forest.png') + expect( + viewer()!.querySelector('[data-testid="output-detail-image"]')!.getAttribute('src') + ).toBe('comfy-output://file/full') + + await press('Escape') + + expect(viewer()).toBeNull() + expect(document.activeElement).toBe(card.element) + }) + + it('steps through the files in page order with the arrow keys and the filmstrip', async () => { + const wrapper = await mountAssets([ + asset('new', 'new.png', 'image', { createdAt: '2026-11-03T00:00:00Z' }), + asset('mid', 'mid.png', 'image', { createdAt: '2026-11-02T00:00:00Z' }), + asset('old', 'old.png', 'image', { createdAt: '2026-11-01T00:00:00Z' }) + ]) + + await wrapper.get('[data-testid="asset-open-mid"]').trigger('click') + await flushPromises() + expect(viewerTitle()).toBe('mid.png') + + await press('ArrowRight') + expect(viewerTitle()).toBe('old.png') + + await press('ArrowRight') + expect(viewerTitle(), 'the last file wraps round to the first').toBe('new.png') + + await press('ArrowLeft') + expect(viewerTitle()).toBe('old.png') + + document.querySelector('[data-testid="output-detail-thumb-1"]')!.click() + await flushPromises() + expect(viewerTitle()).toBe('mid.png') + }) + + it('plays a video in the viewer with its controls', async () => { + const wrapper = await mountAssets([ + asset('clip', 'surfer.mp4', 'video', { previewUrl: 'comfy-output://file/surfer' }) + ]) + + await wrapper.get('[data-testid="asset-open-clip"]').trigger('click') + await flushPromises() + + const video = viewer()!.querySelector('[data-testid="output-detail-video"]')! + expect(video.getAttribute('src')).toBe('comfy-output://file/surfer') + expect(video.controls).toBe(true) + }) + + it('downloads the file the viewer is showing', async () => { + const wrapper = await mountAssets([ + asset('a', 'surfer.mp4', 'video', { createdAt: '2026-11-02T00:00:00Z' }), + asset('b', 'forest.png', 'image', { createdAt: '2026-11-01T00:00:00Z' }) + ]) + + await wrapper.get('[data-testid="asset-open-a"]').trigger('click') + await flushPromises() + await press('ArrowRight') + document.querySelector('[data-testid="output-detail-download"]')!.click() + await flushPromises() + + expect(downloadAsset).toHaveBeenCalledExactlyOnceWith('local', 'b', 'forest.png') + }) }) diff --git a/src/renderer/src/panel/AssetsView.vue b/src/renderer/src/panel/AssetsView.vue index 16187e912..2be6e22b9 100644 --- a/src/renderer/src/panel/AssetsView.vue +++ b/src/renderer/src/panel/AssetsView.vue @@ -1,5 +1,5 @@ + + diff --git a/src/renderer/src/panel/OutputDetailThumb.vue b/src/renderer/src/panel/OutputDetailThumb.vue new file mode 100644 index 000000000..c7bf57bbf --- /dev/null +++ b/src/renderer/src/panel/OutputDetailThumb.vue @@ -0,0 +1,35 @@ + + +