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(gallery): move from the large view stays readable and keeps the arrows (D3, Discord 01.11.)

purple6eff52a94c79
diff --git a/src/components/create/experimental/Lightbox.tsx b/src/components/create/experimental/Lightbox.tsx
index 32c7c04e..52f35ff4 100644
--- a/src/components/create/experimental/Lightbox.tsx
+++ b/src/components/create/experimental/Lightbox.tsx
@@ -8,7 +8,7 @@ import { useCreateExp } from './CreateContext'
import { useComfyMedia } from './useComfyMedia'
import { PromptDetails } from './PromptDetails'
import { cn } from '../ui/cn'
-import { MoveToFolderModal } from './GalleryFolders'
+import { MoveToFolderModal, OnBody } from './GalleryFolders'
import { playsAsVideo } from './galleryUrl'
import { itemsInFolder } from '../../../lib/gallery-folders'
@@ -33,6 +33,18 @@ export function galleryNeighbor<T extends { id: string; folderId?: string }>(
return shown[at + step] ?? null
}
+/**
+ * The entry to show once `id` has left the view (moved to another folder, one
+ * or several at once): the next one still shown, at the end the one before,
+ * null when none is left. `before` is the view while `id` was in it.
+ */
+export function viewSuccessor(before: readonly string[], now: readonly string[], id: string): string | null {
+ const at = before.indexOf(id)
+ if (at < 0) return null
+ const still = new Set(now)
+ return before.slice(at + 1).find((x) => still.has(x)) ?? before.slice(0, at).reverse().find((x) => still.has(x)) ?? null
+}
+
export function Lightbox({ item, onClose, onSaveCharacter, onNavigate, promptOpen = false }: {
item: GalleryItem | null
onClose: () => void
@@ -58,6 +70,24 @@ export function Lightbox({ item, onClose, onSaveCharacter, onNavigate, promptOpe
const folderOpen = useCreateStore((s) => s.galleryFolderOpen)
const prev = item && onNavigate ? galleryNeighbor(all, folderOpen, item.id, -1) : null
const next = item && onNavigate ? galleryNeighbor(all, folderOpen, item.id, 1) : null
+ // D3 (Discord 01.11.2026): an entry moved out of the open folder is no
+ // longer in the view the arrows step through, and they were gone. The view
+ // goes on with the next entry of the folder, or closes when none is left.
+ // An entry opened while not in the view (from the stage) is left alone.
+ const viewKey = itemsInFolder(all, folderOpen).map((g) => g.id).join('\n')
+ const lastView = useRef<{ id: string; ids: string[] } | null>(null)
+ useEffect(() => {
+ if (!item) { lastView.current = null; return }
+ const ids = viewKey ? viewKey.split('\n') : []
+ if (ids.includes(item.id)) { lastView.current = { id: item.id, ids }; return }
+ const before = lastView.current
+ lastView.current = null
+ if (!before || before.id !== item.id) return
+ const to = viewSuccessor(before.ids, ids, item.id)
+ const target = to ? useCreateStore.getState().gallery.find((g) => g.id === to) : undefined
+ if (target && onNavigate) onNavigate(target)
+ else onClose()
+ }, [item, viewKey, onNavigate, onClose])
const [zoom, setZoom] = useState({ id: '', scale: 1, x: 50, y: 50, panX: 0, panY: 0 })
const scale = item && zoom.id === item.id ? zoom.scale : 1
const panX = scale > 1 ? zoom.panX : 0
@@ -220,11 +250,20 @@ export function Lightbox({ item, onClose, onSaveCharacter, onNavigate, promptOpe
<ChevronRight size={18} />
</button>
)}
- {/* The dialog sits inside the large view, so a click in it must not
- reach the backdrop that closes the view. */}
- <div className="contents" onClick={(e) => e.stopPropagation()}>
- <MoveToFolderModal ids={movingId === item.id ? [item.id] : []} onClose={() => setMovingId(null)} />
- </div>
+ {/* The dialog goes onto the page, out of this dark surface: its
+ `lu-on-dark` turned the field text white on the white dialog of
+ the light theme (Discord 01.11.2026). The layer keeps it above
+ the large view (z-80). A click in it still bubbles through the
+ React tree, so it must not reach the backdrop that closes the view. */}
+ {movingId === item.id && (
+ <div className="contents" onClick={(e) => e.stopPropagation()}>
+ <OnBody>
+ <div className="fixed inset-0 z-[90]">
+ <MoveToFolderModal ids={[item.id]} onClose={() => setMovingId(null)} />
+ </div>
+ </OnBody>
+ </div>
+ )}
{item.type === 'audio' ? (
<motion.div
initial={{ scale: 0.95 }}
diff --git a/src/components/create/experimental/__tests__/galerie-betrachter-verschieben.test.tsx b/src/components/create/experimental/__tests__/galerie-betrachter-verschieben.test.tsx
new file mode 100644
index 00000000..0d98f39b
--- /dev/null
+++ b/src/components/create/experimental/__tests__/galerie-betrachter-verschieben.test.tsx
@@ -0,0 +1,143 @@
+// @vitest-environment jsdom
+/**
+ * D3-Nachtrag (Discord #bug-reports, 01.11.2026, in 3.0.8):
+ *
+ * 1) "Move to folder" aus der Grossansicht war im Hellmodus kaum lesbar, die
+ * Zeile fuer den neuen Ordner fast unsichtbar. Der Dialog hing in der
+ * schwarzen Grossansicht (`lu-on-dark`), die die helle Schrift fuer dunkle
+ * Flaechen erzwingt; der Dialog selbst ist im Hellmodus weiss (gemessen
+ * 1,10:1). Er gehoert nicht in diese Flaeche.
+ *
+ * 2) Wurde das offene Bild aus dem offenen Ordner verschoben, zeigte die
+ * Grossansicht keine Pfeile mehr: das Bild stand nicht mehr in der Ansicht,
+ * nach der geblaettert wird. Jetzt springt sie auf das naechste Bild der
+ * Ansicht (am Ende auf das vorige) und schliesst, wenn keins mehr da ist.
+ * Das gilt fuer jede Verschiebung, auch fuer mehrere auf einmal.
+ *
+ * Run: npx vitest run src/components/create/experimental/__tests__/galerie-betrachter-verschieben.test.tsx
+ */
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { useState } from 'react'
+
+vi.mock('../CreateContext', () => ({
+ useCreateExp: () => ({ quota: null, enhanceVideo: vi.fn() }),
+}))
+vi.mock('../useComfyMedia', () => ({
+ useComfyMedia: () => ({ src: 'blob:media', onError: vi.fn(), onLoad: vi.fn() }),
+}))
+vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => false, MLX_MODEL_PREFIX: 'MLX ' }))
+
+import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'
+import { Lightbox, viewSuccessor } from '../Lightbox'
+
+const ITEM = (id: string, extra: Partial<GalleryItem> = {}): GalleryItem => ({
+ id, type: 'image', filename: `${id}.png`, subfolder: '', prompt: `prompt ${id}`, negativePrompt: '',
+ model: 'm.safetensors', modelType: 'sdxl', seed: 1, steps: 20, cfgScale: 5, sampler: 'euler',
+ scheduler: 'normal', width: 512, height: 512, batchSize: 1, createdAt: 1, ...extra,
+})
+
+beforeEach(() => {
+ useCreateStore.setState({
+ backend: 'local',
+ // Im Ordner "Portraits": a, c, d. b liegt in keinem.
+ gallery: [ITEM('a', { folderId: 'f-1' }), ITEM('b'), ITEM('c', { folderId: 'f-1' }), ITEM('d', { folderId: 'f-1' })],
+ galleryFolders: [{ id: 'f-1', name: 'Portraits' }, { id: 'f-2', name: 'Done' }],
+ galleryFolderOpen: 'f-1',
+ })
+})
+afterEach(() => { cleanup() })
+
+function Viewer({ start }: { start: string }) {
+ const [item, setItem] = useState<GalleryItem | null>(useCreateStore.getState().gallery.find((g) => g.id === start) ?? null)
+ return (
+ <>
+ <Lightbox item={item} onClose={() => setItem(null)} onNavigate={setItem} />
+ <span data-testid="closed">{item ? 'open' : 'closed'}</span>
+ </>
+ )
+}
+const shownPrompt = () => (screen.getByTestId('lightbox-image') as HTMLImageElement).alt
+
+/** Over the dialog of the large view: a new folder by name, then Move. */
+function moveByDialog(name: string) {
+ fireEvent.click(screen.getByRole('button', { name: 'Move to folder' }))
+ fireEvent.change(screen.getByRole('textbox', { name: 'New folder name' }), { target: { value: name } })
+ fireEvent.click(screen.getByRole('button', { name: 'Move' }))
+}
+
+describe('viewSuccessor', () => {
+ it('nimmt das naechste noch gezeigte, am Ende das vorige, sonst keins', () => {
+ expect(viewSuccessor(['a', 'c', 'd'], ['a', 'd'], 'c')).toBe('d')
+ expect(viewSuccessor(['a', 'c', 'd'], ['a', 'c'], 'd')).toBe('c')
+ // Mehrere auf einmal weg: das naechste, das noch da ist.
+ expect(viewSuccessor(['a', 'c', 'd', 'e'], ['a', 'e'], 'c')).toBe('e')
+ expect(viewSuccessor(['a', 'c', 'd'], ['a'], 'c')).toBe('a')
+ expect(viewSuccessor(['c'], [], 'c')).toBeNull()
+ })
+})
+
+describe('Verschieben aus der Grossansicht', () => {
+ it('der Dialog liegt nicht in der dunklen Flaeche der Grossansicht (Hellmodus lesbar)', () => {
+ render(<Viewer start="c" />)
+ fireEvent.click(screen.getByRole('button', { name: 'Move to folder' }))
+ const field = screen.getByRole('textbox', { name: 'New folder name' })
+ expect(field.closest('.lu-on-dark')).toBeNull()
+ expect(screen.getByTestId('move-to-folder').closest('.lu-on-dark')).toBeNull()
+ })
+
+ it('ein Klick im Dialog schliesst die Grossansicht nicht', () => {
+ render(<Viewer start="c" />)
+ fireEvent.click(screen.getByRole('button', { name: 'Move to folder' }))
+ fireEvent.click(screen.getByTestId('move-to-folder'))
+ expect(screen.getByTestId('closed').textContent).toBe('open')
+ })
+
+ it('springt nach dem Verschieben auf das naechste Bild des Ordners, und die Pfeile gehen wieder', () => {
+ render(<Viewer start="c" />)
+ moveByDialog('Elsewhere')
+ expect(shownPrompt()).toBe('prompt d')
+ expect(useCreateStore.getState().gallery.find((g) => g.id === 'c')?.folderId).not.toBe('f-1')
+ fireEvent.click(screen.getByTestId('lightbox-prev'))
+ expect(shownPrompt()).toBe('prompt a')
+ fireEvent.keyDown(window, { key: 'ArrowRight' })
+ expect(shownPrompt()).toBe('prompt d')
+ })
+
+ it('am Ende des Ordners springt sie auf das vorige', () => {
+ render(<Viewer start="d" />)
+ moveByDialog('Elsewhere')
+ expect(shownPrompt()).toBe('prompt c')
+ expect(screen.getByTestId('lightbox-prev')).toBeTruthy()
+ })
+
+ it('schliesst, wenn im Ordner nichts mehr zu sehen ist', () => {
+ useCreateStore.setState({ gallery: [ITEM('a', { folderId: 'f-1' }), ITEM('b')] })
+ render(<Viewer start="a" />)
+ moveByDialog('Elsewhere')
+ expect(screen.getByTestId('closed').textContent).toBe('closed')
+ })
+
+ it('in "All" bleibt das Bild stehen und die Pfeile bleiben', () => {
+ useCreateStore.setState({ galleryFolderOpen: null })
+ render(<Viewer start="b" />)
+ moveByDialog('Elsewhere')
+ expect(shownPrompt()).toBe('prompt b')
+ expect(screen.getByTestId('lightbox-prev')).toBeTruthy()
+ expect(screen.getByTestId('lightbox-next')).toBeTruthy()
+ })
+
+ it('mehrere auf einmal verschoben: weiter mit dem naechsten, das noch im Ordner ist', () => {
+ render(<Viewer start="a" />)
+ act(() => { useCreateStore.getState().moveToGalleryFolder(['a', 'c'], 'f-2') })
+ expect(shownPrompt()).toBe('prompt d')
+ expect(screen.queryByTestId('lightbox-prev')).toBeNull()
+ })
+
+ it('ein Bild, das von vornherein nicht im offenen Ordner steht, bleibt offen', () => {
+ render(<Viewer start="b" />)
+ act(() => { useCreateStore.getState().moveToGalleryFolder(['c'], 'f-2') })
+ expect(shownPrompt()).toBe('prompt b')
+ expect(screen.getByTestId('closed').textContent).toBe('open')
+ })
+})