Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
18 changes: 17 additions & 1 deletion locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "欢迎。开始创作吧!",
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/composables/useVirtualMasonry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
90 changes: 90 additions & 0 deletions src/renderer/src/panel/AssetsView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ function assetNames(wrapper: Awaited<ReturnType<typeof mountAssets>>): string[]
.map((tip) => tip.props('text') as string)
}

function viewer(): HTMLElement | null {
return document.querySelector<HTMLElement>('[data-testid="output-detail"]')
}

function viewerTitle(): string {
return viewer()?.querySelector('h2')?.textContent?.trim() ?? ''
}

async function press(key: string): Promise<void> {
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 = ''
Expand Down Expand Up @@ -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<HTMLElement>('[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<HTMLVideoElement>('[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<HTMLElement>('[data-testid="output-detail-download"]')!.click()
await flushPromises()

expect(downloadAsset).toHaveBeenCalledExactlyOnceWith('local', 'b', 'forest.png')
})
})
70 changes: 65 additions & 5 deletions src/renderer/src/panel/AssetsView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'
import { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useLocalStorage, useScroll } from '@vueuse/core'
import { DropdownMenuRadioGroup } from 'reka-ui'
Expand Down Expand Up @@ -29,6 +29,8 @@ import MenuSeparator from '@comfyorg/design-system/menu/MenuSeparator'
import BaseInput from '../components/ui/BaseInput.vue'
import ContextMenu from '../components/ContextMenu.vue'
import Tooltip from '../components/ui/Tooltip.vue'
import OutputDetailDialog from './OutputDetailDialog.vue'
import type { OutputDetailItem } from './OutputDetailDialog.vue'
import { useModal } from '../composables/useModal'
import { useAuthStore } from '../stores/authStore'
import { useInstallationStore } from '../stores/installationStore'
Expand Down Expand Up @@ -185,7 +187,7 @@ function cardShape(index: number): Shape {
return showSkeleton.value || !asset ? skeletonShape(index) : assetShape(asset)
}

const { cards, galleryStyle, cardStyle, measureCard } = useVirtualMasonry({
const { cards, galleryStyle, cardStyle, measureCard, scrollToIndex } = useVirtualMasonry({
scroller,
gallery: useTemplateRef<HTMLElement>('gallery'),
count: () => (showSkeleton.value ? SKELETON_COUNT : visibleAssets.value.length),
Expand Down Expand Up @@ -270,6 +272,49 @@ watch(
{ immediate: true }
)

const detailKey = ref<string | null>(null)

const detailIndex = computed<number | null>({
get: () => {
if (detailKey.value === null) return null
const index = visibleAssets.value.findIndex((asset) => cardKey(asset) === detailKey.value)
return index >= 0 ? index : null
},
set: (index) => {
const asset = index === null ? undefined : visibleAssets.value[index]
detailKey.value = asset ? cardKey(asset) : null
}
})

const detailItems = computed<OutputDetailItem[]>(() =>
visibleAssets.value.map((asset) => ({
key: cardKey(asset),
name: asset.name,
kind: asset.kind,
sizeBytes: asset.sizeBytes,
createdAt: asset.createdAt,
tags: asset.tags,
previewUrl: asset.previewUrl,
thumbnailUrl: asset.thumbnailUrl
}))
)

watch(detailIndex, (index) => {
if (index === null) detailKey.value = null
else scrollToIndex(index)
})

function openDetail(asset: GalleryAsset): void {
detailKey.value = cardKey(asset)
}

async function closeDetail(): Promise<void> {
const viewedKey = detailKey.value ?? ''
detailKey.value = null
await nextTick()
scroller.value?.querySelector<HTMLElement>(`[data-card-key="${CSS.escape(viewedKey)}"]`)?.focus()
}

function warmNameTooltips(): void {
clearTimeout(warmTimer)
warmTimer = setTimeout(() => (nameTooltipsWarm.value = true), NAME_TOOLTIP_DELAY_MS)
Expand Down Expand Up @@ -631,7 +676,7 @@ function extensionOf(name: string): string {
:key="String(card.key)"
:ref="measureCard"
:data-index="card.index"
class="group rounded-card bg-[rgb(29_29_29/0.72)] p-1"
class="group rounded-card bg-[rgb(29_29_29/0.72)] p-1 has-[[data-card-key]:focus-visible]:shadow-[0_0_0_2px_var(--color-ring)]"
:style="cardStyle(card)"
:data-testid="`asset-${asset.id}`"
@contextmenu.prevent="openAssetMenu(asset, $event)"
Expand All @@ -642,7 +687,14 @@ function extensionOf(name: string): string {
:delay-ms="nameTooltipsWarm ? 0 : NAME_TOOLTIP_DELAY_MS"
class="w-full align-top"
>
<div class="block w-full">
<button
type="button"
class="block w-full cursor-pointer text-left outline-none"
:aria-label="t('assets.inspect', { name: asset.name })"
:data-testid="`asset-open-${asset.id}`"
:data-card-key="cardKey(asset)"
@click="openDetail(asset)"
>
<span
class="relative block overflow-hidden rounded-control bg-[rgb(235_235_235/0.05)]"
:style="aspectStyle(assetShape(asset))"
Expand Down Expand Up @@ -695,7 +747,7 @@ function extensionOf(name: string): string {
>{{ assetDetails(asset) }}</span
>
</span>
</div>
</button>
</Tooltip>

<div
Expand Down Expand Up @@ -730,6 +782,14 @@ function extensionOf(name: string): string {
</ul>
</div>

<OutputDetailDialog
v-if="detailIndex !== null"
v-model:index="detailIndex"
:items="detailItems"
@close="closeDetail"
@download="download(visibleAssets[$event]!)"
/>

<ContextMenu
:open="assetMenu !== null"
:x="assetMenu?.x ?? 0"
Expand Down
Loading
Loading