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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): der Prompt-Verlauf laesst sich endlich loeschen
purple3beea599df3b
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsxindex 31b1d8bc..babc9bb2 100644--- a/src/components/create/experimental/Composer.tsx+++ b/src/components/create/experimental/Composer.tsx@@ -1,6 +1,6 @@-import { useCallback, useRef, useState, useSyncExternalStore } from 'react'+import { useCallback, useRef, useSyncExternalStore } from 'react'import { motion, AnimatePresence } from 'framer-motion'-import { Sparkles, X, History, SlidersHorizontal, Square, Workflow } from 'lucide-react'+import { Sparkles, X, SlidersHorizontal, Square, Workflow } from 'lucide-react'import { useCreateStore, MODEL_TYPE_DEFAULTS } from '../../../stores/createStore'import { classifyModel } from '../../../api/comfyui'import { useCreateExp } from './CreateContext'@@ -19,6 +19,7 @@ import { subscribeInstallRuns, getInstallRun } from '../../../lib/model-install-import { useWorkflowStore, shouldShowManagerNotice } from '../../../stores/workflowStore'import { noPromptHint, shouldShowLaneHint } from './laneHint'import { ModelChip } from './ModelChip'+import { PromptHistory } from './PromptHistory'import { SpecialControls } from './SpecialIntentControls'import { CreditsMeter } from './CreditsMeter'import { Button } from '../ui/Button'@@ -27,7 +28,6 @@ import { Segmented } from '../ui/Segmented'import { Slider } from '../ui/Slider'import { Tooltip } from '../ui/Tooltip'import { cn } from '../ui/cn'-import { useClickAway } from '../ui/useClickAway'interface Props {onOpenAdvanced: () => void@@ -447,34 +447,6 @@ function LabeledControl({ label, children }: { label: string; children: React.Re)}-function PromptHistory({ onPick }: { onPick: (p: string) => void }) {- const history = useCreateStore((s) => s.promptHistory)- const [open, setOpen] = useState(false)- const ref = useRef<HTMLDivElement>(null)- useClickAway(ref, () => setOpen(false), open)- if (history.length === 0) return null- return (- <div ref={ref} className="relative">- <Button variant="ghost" size="sm" icon={History} iconOnly title="Prompt history" onClick={() => setOpen((o) => !o)} />- <AnimatePresence>- {open && (- <motion.div- initial={{ opacity: 0, y: 4 }}- animate={{ opacity: 1, y: 0 }}- exit={{ opacity: 0, y: 4 }}- transition={{ duration: 0.12 }}- className="lu-elevated absolute bottom-full mb-1.5 left-0 z-50 w-72 rounded-lg p-1 max-h-64 overflow-y-auto scrollbar-thin"- >- {history.map((h, i) => (- <button key={i} onClick={() => { onPick(h); setOpen(false) }} className="w-full text-left t-control text-gray-300 px-2.5 py-1.5 rounded-md hover:bg-white/[0.06] truncate">{h}</button>- ))}- </motion.div>- )}- </AnimatePresence>- </div>- )-}-// ── aspect helpers ──type AspectKey = '1:1' | '3:4' | '4:3' | '16:9'const RATIO: Record<AspectKey, number> = { '1:1': 1, '3:4': 3 / 4, '4:3': 4 / 3, '16:9': 16 / 9 }diff --git a/src/components/create/experimental/PromptHistory.tsx b/src/components/create/experimental/PromptHistory.tsxnew file mode 100644index 00000000..6aa6d863--- /dev/null+++ b/src/components/create/experimental/PromptHistory.tsx@@ -0,0 +1,116 @@+import { useEffect, useRef, useState } from 'react'+import { motion, AnimatePresence } from 'framer-motion'+import { History, Trash2, X } from 'lucide-react'+import { useCreateStore } from '../../../stores/createStore'+import { Button } from '../ui/Button'+import { cn } from '../ui/cn'+import { useClickAway } from '../ui/useClickAway'++/**+ * The clock button next to the prompt field and the list it opens.+ *+ * Until 2.6.8 the list could only be read from: there was no way to forget a+ * prompt, neither one entry nor the lot, and the store had no action for it+ * either. Two people asked for the missing "Clear" in Discord and were pointed+ * at a button that did not exist on the desktop app. So: a Clear all control at+ * the TOP of the list, where the answer in the channel says it is, and a+ * permanently visible X on every row (no hover, no right click).+ *+ * Clearing is not undoable, so Clear all arms first and only wipes on the+ * second click. That is the same two step delete the workflow list and the+ * agent workflows use; a raw window.confirm blocks the whole webview.+ */+export function PromptHistory({ onPick }: { onPick: (p: string) => void }) {+ const history = useCreateStore((s) => s.promptHistory)+ const clearPromptHistory = useCreateStore((s) => s.clearPromptHistory)+ const removeFromPromptHistory = useCreateStore((s) => s.removeFromPromptHistory)+ const [open, setOpen] = useState(false)+ const [armed, setArmed] = useState(false)+ const ref = useRef<HTMLDivElement>(null)+ const armTimer = useRef<ReturnType<typeof setTimeout> | null>(null)++ const disarm = () => {+ if (armTimer.current) { clearTimeout(armTimer.current); armTimer.current = null }+ setArmed(false)+ }+ const close = () => { setOpen(false); disarm() }+ useClickAway(ref, close, open)+ useEffect(() => () => { if (armTimer.current) clearTimeout(armTimer.current) }, [])++ const clearAll = () => {+ if (!armed) {+ setArmed(true)+ armTimer.current = setTimeout(() => { armTimer.current = null; setArmed(false) }, 4000)+ return+ }+ disarm()+ clearPromptHistory()+ setOpen(false)+ }++ if (history.length === 0) return null++ return (+ <div ref={ref} className="relative">+ <Button+ variant="ghost"+ size="sm"+ icon={History}+ iconOnly+ title="Prompt history"+ onClick={() => (open ? close() : setOpen(true))}+ />+ <AnimatePresence>+ {open && (+ <motion.div+ initial={{ opacity: 0, y: 4 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: 4 }}+ transition={{ duration: 0.12 }}+ className="lu-elevated absolute bottom-full mb-1.5 left-0 z-50 w-72 rounded-lg p-1"+ >+ <div className="flex items-center justify-between gap-2 px-1.5 pb-1 mb-1 border-b border-white/[0.06]">+ <span className="t-label text-gray-500">Prompt history</span>+ <button+ type="button"+ onClick={clearAll}+ title="Delete every remembered prompt"+ className={cn(+ 't-control inline-flex items-center gap-1 px-1.5 py-1 rounded-md transition-colors',+ armed+ ? 'bg-red-500/15 text-red-500 dark:text-red-400'+ : 'text-gray-400 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-500/10',+ )}+ >+ <Trash2 size={12} />+ {armed ? 'Click again to clear' : 'Clear all'}+ </button>+ </div>+ <div className="max-h-56 overflow-y-auto scrollbar-thin">+ {history.map((h, i) => (+ <div key={`${i}-${h}`} className="flex items-center gap-1 rounded-md hover:bg-white/[0.06]">+ <button+ type="button"+ onClick={() => { onPick(h); close() }}+ className="flex-1 min-w-0 text-left t-control text-gray-300 px-2.5 py-1.5 truncate"+ >+ {h}+ </button>+ <button+ type="button"+ title="Remove this prompt"+ aria-label={`Remove prompt: ${h}`}+ onClick={() => removeFromPromptHistory(h)}+ className="shrink-0 mr-1 p-1 rounded text-gray-500 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-500/10 transition-colors"+ >+ <X size={12} />+ </button>+ </div>+ ))}+ </div>+ </motion.div>+ )}+ </AnimatePresence>+ </div>+ )+}diff --git a/src/components/create/experimental/__tests__/prompt-history-clear.test.ts b/src/components/create/experimental/__tests__/prompt-history-clear.test.tsnew file mode 100644index 00000000..c3ae328c--- /dev/null+++ b/src/components/create/experimental/__tests__/prompt-history-clear.test.ts@@ -0,0 +1,114 @@+/**+ * @vitest-environment jsdom+ *+ * Bug A10: the prompt history in Create could not be deleted.+ *+ * pardy22 asked twice, in #general and in #help-18, and a moderator pointed at+ * a "Clear" button at the top of the clock list. That button existed on the web+ * app only; the desktop dropdown was a read-only list and the store had no+ * delete action at all, so there was nothing to find.+ *+ * This file mounts the real dropdown and proves four things a source-reading+ * test cannot: the Clear control is on screen without hovering anything, the+ * first click does NOT delete (it is not undoable, so it arms first), the+ * second one does, and every row carries its own X that removes exactly one+ * entry.+ *+ * Run: npx vitest run src/components/create/experimental/__tests__/prompt-history-clear.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'+import { PromptHistory } from '../PromptHistory'+import { useCreateStore } from '../../../../stores/createStore'++// The store classifies model names on import; the ComfyUI client underneath+// reaches for the Tauri bridge, which does not exist in jsdom.+vi.mock('../../../../api/comfyui', () => ({+ classifyModel: vi.fn(() => 'sdxl'),+}))++const HISTORY = ['a red fox in the snow', 'a blue whale at night']++function show(history: string[] = HISTORY, onPick: (p: string) => void = () => {}) {+ useCreateStore.setState({ promptHistory: history })+ return render(createElement(PromptHistory, { onPick }))+}++/** Opens the dropdown by clicking the clock button. */+function openList() {+ fireEvent.click(screen.getByTitle('Prompt history'))+}++beforeEach(() => {+ useCreateStore.setState({ promptHistory: [] })+})+afterEach(() => {+ cleanup()+ vi.useRealTimers()+})++describe('Create prompt history: deleting it (A10)', () => {+ it('shows the Clear all control at the top of the open list, no hover needed', () => {+ show()+ // Negative control: nothing of the list is on screen before the click.+ expect(screen.queryByText('Clear all')).toBeNull()+ openList()+ expect(screen.getByText('Clear all')).toBeTruthy()+ expect(screen.getByText('Prompt history')).toBeTruthy()+ })++ it('renders a remove button on every row, without hovering', () => {+ show()+ openList()+ for (const entry of HISTORY) {+ expect(screen.getByLabelText(`Remove prompt: ${entry}`)).toBeTruthy()+ }+ })++ it('asks before it clears: one click arms, the second wipes the history', () => {+ show()+ openList()++ fireEvent.click(screen.getByText('Clear all'))+ // Negative control: a single click must NOT delete anything.+ expect(useCreateStore.getState().promptHistory).toEqual(HISTORY)+ expect(screen.getByText('Click again to clear')).toBeTruthy()++ fireEvent.click(screen.getByText('Click again to clear'))+ expect(useCreateStore.getState().promptHistory).toEqual([])+ })++ it('the arming times out, so a stray click never becomes a delete later', () => {+ vi.useFakeTimers()+ show()+ openList()+ fireEvent.click(screen.getByText('Clear all'))+ act(() => { vi.advanceTimersByTime(5000) })+ expect(screen.getByText('Clear all')).toBeTruthy()+ expect(useCreateStore.getState().promptHistory).toEqual(HISTORY)+ })++ it('the X removes exactly its own entry', () => {+ show()+ openList()+ fireEvent.click(screen.getByLabelText(`Remove prompt: ${HISTORY[0]}`))+ expect(useCreateStore.getState().promptHistory).toEqual([HISTORY[1]])+ // The other row is still pickable, the list did not collapse.+ expect(screen.getByText(HISTORY[1])).toBeTruthy()+ })++ it('picking a prompt still works and does not delete it', () => {+ const picked: string[] = []+ show(HISTORY, (p) => picked.push(p))+ openList()+ fireEvent.click(screen.getByText(HISTORY[1]))+ expect(picked).toEqual([HISTORY[1]])+ expect(useCreateStore.getState().promptHistory).toEqual(HISTORY)+ })++ it('renders nothing at all while the history is empty', () => {+ show([])+ expect(screen.queryByTitle('Prompt history')).toBeNull()+ })+})diff --git a/src/stores/__tests__/createStore.test.ts b/src/stores/__tests__/createStore.test.tsindex 541c0973..ccf5282f 100644--- a/src/stores/__tests__/createStore.test.ts+++ b/src/stores/__tests__/createStore.test.ts@@ -566,6 +566,67 @@ describe('createStore', () => {})})+ // ── removeFromPromptHistory / clearPromptHistory (A10) ─────+ //+ // Bug A10 (pardy22, Discord #general + #help-18): the prompt history could+ // not be deleted. The store had no action for it at all, so no button could+ // have worked. These four claims pin the two new actions plus the persisted+ // copy, which is what made the entries come back after a restart.++ describe('removeFromPromptHistory', () => {+ it('drops exactly the one entry', () => {+ useCreateStore.getState().addToPromptHistory('keep me')+ useCreateStore.getState().addToPromptHistory('delete me')+ useCreateStore.getState().removeFromPromptHistory('delete me')+ expect(useCreateStore.getState().promptHistory).toEqual(['keep me'])+ })++ // Negative control: an unknown prompt must not eat the list.+ it('leaves the list alone when the prompt is not in it', () => {+ useCreateStore.getState().addToPromptHistory('a')+ useCreateStore.getState().addToPromptHistory('b')+ useCreateStore.getState().removeFromPromptHistory('never added')+ expect(useCreateStore.getState().promptHistory).toEqual(['b', 'a'])+ })+ })++ describe('clearPromptHistory', () => {+ it('empties the history', () => {+ useCreateStore.getState().addToPromptHistory('a')+ useCreateStore.getState().addToPromptHistory('b')+ useCreateStore.getState().clearPromptHistory()+ expect(useCreateStore.getState().promptHistory).toEqual([])+ })++ // Negative control: clearing the prompts must not touch the gallery.+ it('does not touch the gallery', () => {+ useCreateStore.getState().addToGallery(makeGalleryItem('a'))+ useCreateStore.getState().addToPromptHistory('a')+ useCreateStore.getState().clearPromptHistory()+ expect(useCreateStore.getState().gallery).toHaveLength(1)+ })+ })++ describe('prompt history persistence', () => {+ const persisted = () => {+ const raw = localStorage.getItem('create-store')+ return raw ? (JSON.parse(raw).state as { promptHistory?: string[] }) : null+ }++ it('writes the surviving entries to localStorage, so nothing returns after a restart', () => {+ useCreateStore.getState().addToPromptHistory('keep me')+ useCreateStore.getState().addToPromptHistory('delete me')+ // Guard: without this the assertions below could pass on an empty store.+ expect(persisted()?.promptHistory).toEqual(['delete me', 'keep me'])++ useCreateStore.getState().removeFromPromptHistory('delete me')+ expect(persisted()?.promptHistory).toEqual(['keep me'])++ useCreateStore.getState().clearPromptHistory()+ expect(persisted()?.promptHistory).toEqual([])+ })+ })+// ── setIsGenerating ────────────────────────────────────────describe('setIsGenerating', () => {diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 5a85b2fc..a7b2b0c9 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -390,6 +390,10 @@ interface CreateState {removeFromGallery: (id: string) => voidclearGallery: () => voidaddToPromptHistory: (prompt: string) => void+ /** Drop a single remembered prompt (the X next to the entry). */+ removeFromPromptHistory: (prompt: string) => void+ /** Drop the whole prompt history (the Clear all button in the dropdown). */+ clearPromptHistory: () => voidsetImageModelList: (list: ClassifiedModel[]) => voidsetVideoModelList: (list: ClassifiedModel[]) => voidsetComfyRunning: (running: boolean) => void@@ -749,6 +753,9 @@ export const useCreateStore = create<CreateState>()(const filtered = s.promptHistory.filter(p => p !== prompt)return { promptHistory: [prompt, ...filtered].slice(0, 50) }}),+ removeFromPromptHistory: (prompt) =>+ set((s) => ({ promptHistory: s.promptHistory.filter((p) => p !== prompt) })),+ clearPromptHistory: () => set({ promptHistory: [] }),setImageModelList: (list) => set({ imageModelList: list }),setVideoModelList: (list) => set({ videoModelList: list }),setComfyRunning: (running) => set({ comfyRunning: running }),