Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(create): Delete says what it does to a cloud result

purplea31f0344c09c
diff --git a/src/components/create/experimental/CreatePanel.tsx b/src/components/create/experimental/CreatePanel.tsx
index e60cac09..52fe2008 100644
--- a/src/components/create/experimental/CreatePanel.tsx
+++ b/src/components/create/experimental/CreatePanel.tsx
@@ -1,11 +1,12 @@
import { itemHasAlpha } from '../../../lib/transparent-image'
-import { useEffect, useRef, useState, type MouseEvent as ReactMouseEvent } from 'react'
+import { useEffect, useMemo, useRef, useState, type MouseEvent as ReactMouseEvent } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { Images, Play, PanelRightClose, Trash2, Download, MonitorOff, AudioLines, FolderInput, Check, X, Eye, EyeOff, Tag } from 'lucide-react'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
import { galleryLabel } from '../../../lib/render/gallery-label'
import { GALLERY_DRAG_TYPE, playsAsVideo } from './galleryUrl'
import { deleteTitle, unavailableTitle } from './galleryWording'
+import { deleteFateOf, deleteFates } from '../../../lib/gallery-trash'
import { isMlxImageHost } from '../../../api/mlx-image'
import { downloadGalleryItem } from './galleryDownload'
import { useComfyMedia } from './useComfyMedia'
@@ -44,6 +45,9 @@ interface Props {
*/
export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {
const all = useCreateStore((s) => s.gallery)
+ // What Delete does to each tile: a local file to the bin, a cloud result
+ // only out of this gallery (lib/gallery-trash.ts).
+ const fateOf = useMemo(() => deleteFateOf(all), [all])
const folderOpen = useCreateStore((s) => s.galleryFolderOpen)
const removeFromGallery = useCreateStore((s) => s.removeFromGallery)
// C27: the output folder of a local ComfyUI. The Mac has none, the cloud neither.
@@ -225,7 +229,7 @@ export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {
<OnBody>
<Modal open={confirming.length > 0} onClose={() => setConfirming([])} title="Delete from the gallery" maxWidth="max-w-md">
<div data-testid="gallery-delete-confirm">
- <p className="t-body text-gray-700 dark:text-gray-200">{deleteConfirmLine(confirming.length, isMlxImageHost())}</p>
+ <p className="t-body text-gray-700 dark:text-gray-200">{deleteConfirmLine(deleteFates(confirming, all), isMlxImageHost())}</p>
<ModalActions>
<ModalButton onClick={() => setConfirming([])}>Cancel</ModalButton>
<ModalButton variant="danger" onClick={deleteAll}>
@@ -306,7 +310,7 @@ export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {
<button
onClick={() => removeFromGallery(g.id)}
className="lu-on-dark absolute -top-1.5 -right-1.5 w-6 h-6 rounded-full bg-red-600/90 hover:bg-red-600 text-gray-100 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center shadow-sm"
- title={deleteTitle(isMlxImageHost())}
+ title={deleteTitle(isMlxImageHost(), fateOf(g))}
>
<Trash2 size={12} />
</button>
diff --git a/src/components/create/experimental/OutputView.tsx b/src/components/create/experimental/OutputView.tsx
index acead822..381dffa2 100644
--- a/src/components/create/experimental/OutputView.tsx
+++ b/src/components/create/experimental/OutputView.tsx
@@ -14,6 +14,7 @@ import { PromptDetails } from './PromptDetails'
import { hasPromptPanel } from '../../../lib/render/ran-prompt'
import { markGalleryItemAvailable, playsAsVideo } from './galleryUrl'
import { deleteTitle, unavailableLine, playerHasControls, UNAVAILABLE_VIDEO_BOX } from './galleryWording'
+import { deleteFate } from '../../../lib/gallery-trash'
import { downloadGalleryItem } from './galleryDownload'
import { galleryLabel } from '../../../lib/render/gallery-label'
import { resultFacts } from '../../../lib/render/result-facts'
@@ -200,6 +201,10 @@ export function ResultView({ item, onFullscreen, onShowPrompt, onSendToEditor, o
// An old animated .webp clip shows as a picture, which still moves (A19).
const inPlayer = playsAsVideo(item)
const isAudio = item.type === 'audio'
+ // What Delete does here: a local file goes to the bin, a cloud result only
+ // leaves this gallery (lib/gallery-trash.ts). A string, so the view only
+ // draws again when the answer changes.
+ const fate = useCreateStore((s) => deleteFate(item, s.gallery.filter((g) => g.id !== item.id)))
// A 3D model has its own view with its own bar (download menu, looks), so
// it skips the hover buttons of a picture.
if (item.type === '3d') {
@@ -213,7 +218,7 @@ export function ResultView({ item, onFullscreen, onShowPrompt, onSendToEditor, o
<span className="truncate max-w-[420px]">{galleryLabel(item)}</span>
<span>·</span>
<button type="button" className="underline underline-offset-2 hover:text-gray-300" onClick={() => useCreateStore.getState().removeFromGallery(item.id)}>
- {deleteTitle(isMlxImageHost())}
+ {deleteTitle(isMlxImageHost(), fate)}
</button>
</div>
)
@@ -284,9 +289,9 @@ export function ResultView({ item, onFullscreen, onShowPrompt, onSendToEditor, o
)}
{/* Discord 2026-09-28 (#feature-requests "DELETE BUTTON"):
delete from the big view too, not only from the tile's corner.
- The file goes to the Recycle Bin, on a Mac to the Trash
- (lib/gallery-trash.ts). */}
- <IconBtn title={deleteTitle(isMlxImageHost())} onClick={() => useCreateStore.getState().removeFromGallery(item.id)}>
+ A local file goes to the Recycle Bin, on a Mac to the Trash; a
+ cloud result only leaves this gallery (lib/gallery-trash.ts). */}
+ <IconBtn title={deleteTitle(isMlxImageHost(), fate)} onClick={() => useCreateStore.getState().removeFromGallery(item.id)}>
<Trash2 size={14} />
</IconBtn>
</div>
diff --git a/src/components/create/experimental/__tests__/delete-words-follow-the-result.test.tsx b/src/components/create/experimental/__tests__/delete-words-follow-the-result.test.tsx
new file mode 100644
index 00000000..6eb6a781
--- /dev/null
+++ b/src/components/create/experimental/__tests__/delete-words-follow-the-result.test.tsx
@@ -0,0 +1,55 @@
+// @vitest-environment jsdom
+/**
+ * C3D (14.11.2026): under a cloud 3D result the line said "Delete (moves the
+ * file to the Trash)". Delete of a cloud result only takes the entry out of
+ * this gallery (lib/gallery-trash.ts): no file on this computer, nothing on
+ * the server. The words now follow what Delete does, for 3D and every other
+ * result, under the result and on its hover button.
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+
+const host = vi.hoisted(() => ({ mac: true }))
+vi.mock('../../../../api/mlx-image', async (o) => ({ ...(await o<typeof import('../../../../api/mlx-image')>()), isMlxImageHost: () => host.mac }))
+vi.mock('../../../three/LazyModelViewer', () => ({ LazyModelViewer: () => <div data-testid="viewer" /> }))
+
+import { ResultView } from '../OutputView'
+import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'
+
+const item = (over: Partial<GalleryItem>): GalleryItem => ({
+ id: 'g1', type: 'image', filename: 'lu_00001_.png', subfolder: '', prompt: 'p', negativePrompt: '',
+ model: 'm', modelType: 'sdxl', seed: 1, steps: 1, cfgScale: 1, sampler: 'euler', scheduler: 'normal',
+ width: 8, height: 8, batchSize: 1, createdAt: 1, ...over,
+}) as GalleryItem
+
+function show(it: GalleryItem) {
+ useCreateStore.setState({ gallery: [it] })
+ render(<ResultView item={it} onFullscreen={() => {}} />)
+}
+
+afterEach(() => { cleanup(); host.mac = true; useCreateStore.setState({ gallery: [] }) })
+
+describe('the words of Delete under a result', () => {
+ it('a cloud 3D result: only from this gallery, the cloud copy stays', () => {
+ show(item({ type: '3d', filename: undefined, jobId: 'j1', remoteUrl: 'https://s/b.glb', model: 'trellis-2' }))
+ const facts = screen.getByTestId('result-facts')
+ expect(facts.textContent).toContain('Delete (only from this gallery, the cloud copy stays)')
+ expect(facts.textContent).not.toMatch(/Trash|Recycle Bin/)
+ })
+
+ it('a 3D model made on this Mac: its file goes to the Trash', () => {
+ show(item({ type: '3d', filename: undefined, localPath: '/out/a.glb' }))
+ expect(screen.getByTestId('result-facts').textContent).toContain('Delete (moves the file to the Trash)')
+ })
+
+ it('a cloud picture: the hover button says the same as under a cloud 3D result', () => {
+ show(item({ filename: undefined, jobId: 'j2', remoteUrl: 'https://s/a.png' }))
+ expect(screen.getByTitle('Delete (only from this gallery, the cloud copy stays)')).toBeTruthy()
+ })
+
+ it('a local ComfyUI picture on Windows: the Recycle Bin, as always', () => {
+ host.mac = false
+ show(item({}))
+ expect(screen.getByTitle('Delete (moves the file to the Recycle Bin)')).toBeTruthy()
+ })
+})
diff --git a/src/components/create/experimental/__tests__/galerie-mehrfachauswahl.test.tsx b/src/components/create/experimental/__tests__/galerie-mehrfachauswahl.test.tsx
index 2b9b843c..5d95060e 100644
--- a/src/components/create/experimental/__tests__/galerie-mehrfachauswahl.test.tsx
+++ b/src/components/create/experimental/__tests__/galerie-mehrfachauswahl.test.tsx
@@ -20,7 +20,7 @@ vi.mock('../useComfyMedia', () => ({
}))
vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => false, MLX_MODEL_PREFIX: 'MLX ' }))
const trash = vi.hoisted(() => vi.fn(async () => null))
-vi.mock('../../../../lib/gallery-trash', () => ({ trashGalleryFile: trash }))
+vi.mock('../../../../lib/gallery-trash', async (o) => ({ ...(await o<typeof import('../../../../lib/gallery-trash')>()), trashGalleryFile: trash }))
const download = vi.hoisted(() => vi.fn(async () => {}))
vi.mock('../galleryDownload', () => ({ downloadGalleryItem: download }))
diff --git a/src/components/create/experimental/__tests__/galerie-ordner-oberflaeche.test.tsx b/src/components/create/experimental/__tests__/galerie-ordner-oberflaeche.test.tsx
index 01bfeb57..47cb1262 100644
--- a/src/components/create/experimental/__tests__/galerie-ordner-oberflaeche.test.tsx
+++ b/src/components/create/experimental/__tests__/galerie-ordner-oberflaeche.test.tsx
@@ -21,7 +21,7 @@ vi.mock('../useComfyMedia', () => ({
}))
vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => false, MLX_MODEL_PREFIX: 'MLX ' }))
const trash = vi.hoisted(() => vi.fn(async () => null))
-vi.mock('../../../../lib/gallery-trash', () => ({ trashGalleryFile: trash }))
+vi.mock('../../../../lib/gallery-trash', async (o) => ({ ...(await o<typeof import('../../../../lib/gallery-trash')>()), trashGalleryFile: trash }))
import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'
import { CreatePanel } from '../CreatePanel'
diff --git a/src/components/create/experimental/__tests__/gallery-selection.test.ts b/src/components/create/experimental/__tests__/gallery-selection.test.ts
index cacdf8f3..2ae0f588 100644
--- a/src/components/create/experimental/__tests__/gallery-selection.test.ts
+++ b/src/components/create/experimental/__tests__/gallery-selection.test.ts
@@ -80,7 +80,16 @@ describe('the menu', () => {
describe('the delete question', () => {
it('names the count and where the files go, per host', () => {
- expect(deleteConfirmLine(1, false)).toBe('Delete 1 item? Its file moves to the Recycle Bin.')
- expect(deleteConfirmLine(4, true)).toBe('Delete 4 items? Their files move to the Trash.')
+ expect(deleteConfirmLine(['trash'], false)).toBe('Delete 1 item? Its file moves to the Recycle Bin.')
+ expect(deleteConfirmLine(['trash', 'trash', 'trash', 'trash'], true)).toBe('Delete 4 items? Their files move to the Trash.')
+ })
+
+ // C3D (14.11.2026): a cloud result only leaves this gallery.
+ it('says a cloud result only leaves this gallery and its cloud copy stays', () => {
+ expect(deleteConfirmLine(['cloud'], true)).toBe('Delete 1 item? It leaves this gallery. The copy in your cloud account stays.')
+ expect(deleteConfirmLine(['cloud', 'cloud'], false)).toBe('Delete 2 items? They leave this gallery. The copies in your cloud account stay.')
+ expect(deleteConfirmLine(['entry'], true)).toBe('Delete 1 item? It leaves the gallery.')
+ expect(deleteConfirmLine(['trash', 'cloud', 'cloud'], true)).toBe('Delete 3 items? The local file moves to the Trash. The cloud results only leave this gallery.')
+ expect(deleteConfirmLine(['trash', 'trash', 'cloud', 'entry'], false)).toBe('Delete 4 items? The local files move to the Recycle Bin. The cloud result only leaves this gallery.')
})
})
diff --git a/src/components/create/experimental/__tests__/gallery-wording-per-host.test.ts b/src/components/create/experimental/__tests__/gallery-wording-per-host.test.ts
index 6b38901e..719f16a2 100644
--- a/src/components/create/experimental/__tests__/gallery-wording-per-host.test.ts
+++ b/src/components/create/experimental/__tests__/gallery-wording-per-host.test.ts
@@ -13,13 +13,13 @@ import { deleteTitle, unavailableLine, unavailableTitle } from '../galleryWordin
describe('on a Mac', () => {
it('no sentence names ComfyUI, an engine to wait for, or the Recycle Bin', () => {
- const all = [unavailableLine(true, true), unavailableLine(false, true), unavailableTitle(true, true), unavailableTitle(false, true), deleteTitle(true)]
+ const all = [unavailableLine(true, true), unavailableLine(false, true), unavailableTitle(true, true), unavailableTitle(false, true), deleteTitle(true, 'trash'), deleteTitle(true, 'cloud'), deleteTitle(true, 'entry')]
for (const line of all) expect(line).not.toMatch(/ComfyUI|Recycle Bin|local engine/)
expect(unavailableLine(true, true)).toBe('This file is no longer on this Mac.')
})
it('Delete names the Trash, where the file goes', () => {
- expect(deleteTitle(true)).toBe('Delete (moves the file to the Trash)')
+ expect(deleteTitle(true, 'trash')).toBe('Delete (moves the file to the Trash)')
})
})
@@ -29,7 +29,7 @@ describe('COUNTER-CHECK: Windows and Linux read what they always did', () => {
expect(unavailableLine(false, false)).toBe("This render lives on the local engine, which isn't reachable right now. It shows up again as soon as ComfyUI is running.")
expect(unavailableTitle(true, false)).toBe('No longer in the ComfyUI output folder')
expect(unavailableTitle(false, false)).toBe("Local render, but the local engine isn't reachable")
- expect(deleteTitle(false)).toBe('Delete (moves the file to the Recycle Bin)')
+ expect(deleteTitle(false, 'trash')).toBe('Delete (moves the file to the Recycle Bin)')
})
})
@@ -53,3 +53,15 @@ describe('a video whose file cannot be read (Fund 26)', () => {
expect(source).toContain('!playerHasControls(!!item.unavailable) && UNAVAILABLE_VIDEO_BOX')
})
})
+
+// C3D (14.11.2026): under a cloud result Delete said the file goes to the
+// Trash. A cloud result only leaves this gallery (lib/gallery-trash.ts).
+describe('Delete says what it does to the entry', () => {
+ it('a cloud result: only from this gallery, on every host', () => {
+ for (const mac of [true, false]) {
+ expect(deleteTitle(mac, 'cloud')).toBe('Delete (only from this gallery, the cloud copy stays)')
+ expect(deleteTitle(mac, 'entry')).toBe('Delete (only from the gallery)')
+ for (const fate of ['cloud', 'entry'] as const) expect(deleteTitle(mac, fate)).not.toMatch(/Trash|Recycle Bin|moves the file/)
+ }
+ })
+})
diff --git a/src/components/create/experimental/gallerySelection.ts b/src/components/create/experimental/gallerySelection.ts
index 0dcb9e3e..5690c98e 100644
--- a/src/components/create/experimental/gallerySelection.ts
+++ b/src/components/create/experimental/gallerySelection.ts
@@ -5,6 +5,7 @@
// the same code its tile buttons use.
import type { MenuAction } from '../../ui/menu-actions'
+import type { DeleteFate } from '../../../lib/gallery-trash'
export interface GallerySelection {
/** Selected ids, in gallery order. */
@@ -90,10 +91,24 @@ export function buildGalleryMenu(h: GalleryMenuHandlers, count: number): MenuAct
]
}
-/** The question before deleting. Where the files go, as deleteTitle says it per host. */
-export function deleteConfirmLine(count: number, mac: boolean): string {
+/** The question before deleting. What happens to each entry, as deleteTitle
+ * says it (lib/gallery-trash.ts, deleteFates): a local file goes to the bin
+ * of the host, a cloud result only leaves this gallery. */
+export function deleteConfirmLine(fates: readonly DeleteFate[], mac: boolean): string {
+ const n = fates.length
const bin = mac ? 'the Trash' : 'the Recycle Bin'
- return count === 1
- ? `Delete 1 item? Its file moves to ${bin}.`
- : `Delete ${count} items? Their files move to ${bin}.`
+ const head = n === 1 ? 'Delete 1 item?' : `Delete ${n} items?`
+ const trash = fates.filter((f) => f === 'trash').length
+ const cloud = fates.filter((f) => f === 'cloud').length
+ if (trash === n) return n === 1 ? `${head} Its file moves to ${bin}.` : `${head} Their files move to ${bin}.`
+ if (cloud === n) {
+ return n === 1
+ ? `${head} It leaves this gallery. The copy in your cloud account stays.`
+ : `${head} They leave this gallery. The copies in your cloud account stay.`
+ }
+ if (trash === 0 && cloud === 0) return `${head} ${n === 1 ? 'It leaves' : 'They leave'} the gallery.`
+ const parts = [head]
+ if (trash > 0) parts.push(trash === 1 ? `The local file moves to ${bin}.` : `The local files move to ${bin}.`)
+ if (cloud > 0) parts.push(cloud === 1 ? 'The cloud result only leaves this gallery.' : 'The cloud results only leave this gallery.')
+ return parts.join(' ')
}
diff --git a/src/components/create/experimental/galleryWording.ts b/src/components/create/experimental/galleryWording.ts
index 3e1da4f0..bfbb1d1a 100644
--- a/src/components/create/experimental/galleryWording.ts
+++ b/src/components/create/experimental/galleryWording.ts
@@ -5,6 +5,8 @@
// isMlxImageHost(); with it false every string is the one Windows and Linux
// always had.
+import type { DeleteFate } from '../../../lib/gallery-trash'
+
/** The line over a result whose file cannot be shown. */
export function unavailableLine(gone: boolean, mac: boolean): string {
if (mac) {
@@ -24,11 +26,14 @@ export function unavailableTitle(gone: boolean, mac: boolean): string {
}
/**
- * The tooltip of Delete. A local render goes to the Recycle Bin on Windows
- * and to the Trash on a Mac (lib/gallery-trash.ts), and each is called by
- * its own name.
+ * The words of Delete, after what it really does (lib/gallery-trash.ts,
+ * deleteFate). A local file goes to the Recycle Bin on Windows and to the
+ * Trash on a Mac, each called by its own name. A cloud result only leaves
+ * this gallery: the copy in the cloud account is not deleted.
*/
-export function deleteTitle(mac: boolean): string {
+export function deleteTitle(mac: boolean, fate: DeleteFate): string {
+ if (fate === 'cloud') return 'Delete (only from this gallery, the cloud copy stays)'
+ if (fate === 'entry') return 'Delete (only from the gallery)'
return mac ? 'Delete (moves the file to the Trash)' : 'Delete (moves the file to the Recycle Bin)'
}
diff --git a/src/lib/__tests__/gallery-trash.test.ts b/src/lib/__tests__/gallery-trash.test.ts
index 34a0164b..e949c4e5 100644
--- a/src/lib/__tests__/gallery-trash.test.ts
+++ b/src/lib/__tests__/gallery-trash.test.ts
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
const backend = vi.hoisted(() => ({ call: vi.fn(), tauri: vi.fn(() => true) }))
vi.mock('../../api/backend', async (o) => ({ ...(await o<typeof import('../../api/backend')>()), backendCall: backend.call, isTauri: backend.tauri }))
-import { isTrashableMacRender, isTrashableRender, trashGalleryFile } from '../gallery-trash'
+import { deleteFate, deleteFateOf, deleteFates, isTrashableMacRender, isTrashableRender, trashGalleryFile } from '../gallery-trash'
import type { GalleryItem } from '../../stores/createStore'
const item = (over: Partial<GalleryItem> = {}): GalleryItem => ({
@@ -73,3 +73,43 @@ describe('gallery delete reaches the file (Discord 2026-09-25)', () => {
})
})
})
+
+// C3D (14.11.2026): the words of Delete follow what it does. A cloud result
+// (a 3D model or any other) keeps its copy in the account: no file, no call.
+describe('what Delete does to an entry', () => {
+ const gallery = [
+ item({ id: 'cloud3d', type: '3d', filename: undefined, jobId: 'j1', remoteUrl: 'https://s/b.glb' }),
+ item({ id: 'cloudimg', filename: undefined, jobId: 'j2' }),
+ item({ id: 'comfy', filename: 'one.png' }),
+ item({ id: 'twinA', filename: 'two.png' }),
+ item({ id: 'twinB', filename: 'two.png' }),
+ item({ id: 'temp', filename: 'tmp.png', comfyType: 'temp' }),
+ item({ id: 'mac', filename: undefined, localPath: '/out/a.glb' }),
+ item({ id: 'macA', filename: undefined, localPath: '/out/b.png' }),
+ item({ id: 'macB', filename: undefined, localPath: '/out/b.png' }),
+ item({ id: 'nofile', filename: undefined }),
+ ] as GalleryItem[]
+ const others = (g: GalleryItem) => gallery.filter((x) => x.id !== g.id)
+
+ it('cloud results only leave the gallery, local files go to the bin, shared ones stay', () => {
+ const fates = Object.fromEntries(gallery.map((g) => [g.id, deleteFate(g, others(g))]))
+ expect(fates).toEqual({
+ cloud3d: 'cloud', cloudimg: 'cloud', comfy: 'trash', twinA: 'entry', twinB: 'entry',
+ temp: 'entry', mac: 'trash', macA: 'entry', macB: 'entry', nofile: 'entry',
+ })
+ })
+
+ it('the whole-gallery form gives the same answer for every entry', () => {
+ const fateOf = deleteFateOf(gallery)
+ for (const g of gallery) expect(fateOf(g), g.id).toBe(deleteFate(g, others(g)))
+ })
+
+ it('deleting two that share a file: the second takes the file along', () => {
+ expect(deleteFates(['twinA', 'twinB', 'cloud3d'], gallery)).toEqual(['entry', 'trash', 'cloud'])
+ })
+
+ it('a cloud 3D result calls nothing on delete', async () => {
+ expect(await trashGalleryFile(gallery[0], others(gallery[0]))).toBeNull()
+ expect(backend.call).not.toHaveBeenCalled()
+ })
+})
diff --git a/src/lib/gallery-trash.ts b/src/lib/gallery-trash.ts
index a946d5c2..5fe41037 100644
--- a/src/lib/gallery-trash.ts
+++ b/src/lib/gallery-trash.ts
@@ -25,18 +25,66 @@ interface GalleryRender {
localPath?: string
}
-export function isTrashableRender(item: GalleryRender, remaining: GalleryRender[]): boolean {
+export function isTrashableRender(item: GalleryRender, remaining: readonly GalleryRender[]): boolean {
if (!item.filename || item.jobId || item.remoteUrl || item.localPath) return false
if ((item.comfyType ?? 'output') !== 'output') return false
return !remaining.some((g) => g.filename === item.filename && (g.subfolder ?? '') === (item.subfolder ?? ''))
}
/** A render of the Mac's engines: a file on this Mac that no other entry shows. */
-export function isTrashableMacRender(item: GalleryRender, remaining: GalleryRender[]): boolean {
+export function isTrashableMacRender(item: GalleryRender, remaining: readonly GalleryRender[]): boolean {
if (!item.localPath || item.jobId || item.remoteUrl) return false
return !remaining.some((g) => g.localPath === item.localPath)
}
+/**
+ * What Delete does to an entry, so the words on the button say it truly
+ * (C3D, 14.11.2026: under a cloud result it said the file goes to the Trash).
+ * trash a file on this computer that no other entry shows: to the Trash
+ * or the Recycle Bin (trashGalleryFile below);
+ * cloud a cloud result: it only leaves this app's gallery. Nothing on the
+ * server is deleted, the copy in the account stays (the web gallery
+ * still shows it until it expires);
+ * entry anything else (a file another entry still shows, a file outside
+ * the output folder): only the entry goes.
+ */
+export type DeleteFate = 'trash' | 'cloud' | 'entry'
+
+export function deleteFate(item: GalleryRender, remaining: readonly GalleryRender[]): DeleteFate {
+ if (item.jobId || item.remoteUrl) return 'cloud'
+ return isTrashableMacRender(item, remaining) || isTrashableRender(item, remaining) ? 'trash' : 'entry'
+}
+
+/** The fates of several entries deleted one after the other, as the gallery
+ * does it: a file two of them share goes with the second. */
+export function deleteFates<T extends GalleryRender & { id: string }>(ids: readonly string[], gallery: readonly T[]): DeleteFate[] {
+ let rest = gallery
+ return ids.map((id) => {
+ const item = rest.find((g) => g.id === id)
+ rest = rest.filter((g) => g.id !== id)
+ return item ? deleteFate(item, rest) : 'entry'
+ })
+}
+
+/** deleteFate for every entry of a whole gallery at once, without a scan of
+ * the gallery per entry (the strip has thousands, C27): who else shows the
+ * same file is counted once. Same answer as deleteFate(item, the others). */
+export function deleteFateOf<T extends GalleryRender>(all: readonly T[]): (item: T) => DeleteFate {
+ const comfy = new Map<string, number>()
+ const mac = new Map<string, number>()
+ const comfyKey = (g: GalleryRender) => `${g.subfolder ?? ''}\u0000${g.filename}`
+ for (const g of all) {
+ if (g.filename) comfy.set(comfyKey(g), (comfy.get(comfyKey(g)) ?? 0) + 1)
+ if (g.localPath) mac.set(g.localPath, (mac.get(g.localPath) ?? 0) + 1)
+ }
+ return (item) => {
+ if (item.jobId || item.remoteUrl) return 'cloud'
+ if (item.localPath) return (mac.get(item.localPath) ?? 0) <= 1 ? 'trash' : 'entry'
+ if (!item.filename || (item.comfyType ?? 'output') !== 'output') return 'entry'
+ return (comfy.get(comfyKey(item)) ?? 0) <= 1 ? 'trash' : 'entry'
+ }
+}
+
/** Returns an error line for the user, or null when all went well. */
export async function trashGalleryFile(item: GalleryRender, remaining: GalleryRender[]): Promise<string | null> {
if (!isTauri()) return null