From d04908d00db28a136c8c730bf19788bdef429413 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Mon, 16 Nov 2026 00:51:22 -0800 Subject: [PATCH] feat(assets): open a file full size when its card is clicked Clicking an asset card did nothing: only right-click and the hover buttons had actions. A click now opens the file in a viewer over the page: the full image (Fit, 50%, 100%, 200%), the video with its controls, or the audio player, with its name, type, creation time, format, dimensions, size and tags beside it, and Download. The arrow keys and a filmstrip step through the files in the page's order and filter. Escape, the close button or a click outside closes it and puts focus back on the card. While the viewer steps, the gallery scrolls the viewed card into place behind it, so the card is still mounted to take focus back. This is the Assets half of Pablo's #2008, ported onto main without the Apps bridge and workflow parts, which wait on the Apps stack. Filmstrip videos load only once they scroll into view, so a long gallery does not start a metadata request per video. --- locales/en.json | 18 +- locales/zh.json | 18 +- .../src/composables/useVirtualMasonry.ts | 6 +- src/renderer/src/panel/AssetsView.test.ts | 90 ++++++ src/renderer/src/panel/AssetsView.vue | 70 ++++- src/renderer/src/panel/OutputDetailDialog.vue | 287 ++++++++++++++++++ src/renderer/src/panel/OutputDetailThumb.vue | 35 +++ 7 files changed, 516 insertions(+), 8 deletions(-) create mode 100644 src/renderer/src/panel/OutputDetailDialog.vue create mode 100644 src/renderer/src/panel/OutputDetailThumb.vue 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 @@ + + +