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): das X einer Zeile entschaerft den scharfen Clear all

purplef2b14d02ed0f
diff --git a/src/components/create/experimental/PromptHistory.tsx b/src/components/create/experimental/PromptHistory.tsx
index 6aa6d863..27895cd3 100644
--- a/src/components/create/experimental/PromptHistory.tsx
+++ b/src/components/create/experimental/PromptHistory.tsx
@@ -96,11 +96,14 @@ export function PromptHistory({ onPick }: { onPick: (p: string) => void }) {
>
{h}
</button>
+ {/* Removing one row also disarms Clear all: otherwise a
+ later click on the head would wipe the list after a
+ completely different action. */}
<button
type="button"
title="Remove this prompt"
aria-label={`Remove prompt: ${h}`}
- onClick={() => removeFromPromptHistory(h)}
+ onClick={() => { disarm(); 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} />
diff --git a/src/components/create/experimental/__tests__/prompt-history-clear.test.ts b/src/components/create/experimental/__tests__/prompt-history-clear.test.ts
index c3ae328c..905e82a8 100644
--- a/src/components/create/experimental/__tests__/prompt-history-clear.test.ts
+++ b/src/components/create/experimental/__tests__/prompt-history-clear.test.ts
@@ -98,6 +98,21 @@ describe('Create prompt history: deleting it (A10)', () => {
expect(screen.getByText(HISTORY[1])).toBeTruthy()
})
+ // N1 from the review: arming is about the whole list. If a single X does not
+ // disarm it, the next click on the head wipes everything after a completely
+ // different action, and the customer never saw a second confirmation.
+ it('removing one entry disarms Clear all, so the next head click asks again', () => {
+ show()
+ openList()
+ fireEvent.click(screen.getByText('Clear all'))
+ fireEvent.click(screen.getByLabelText(`Remove prompt: ${HISTORY[0]}`))
+ expect(screen.getByText('Clear all')).toBeTruthy()
+
+ fireEvent.click(screen.getByText('Clear all'))
+ // Negative control: that click may only arm, never delete the rest.
+ expect(useCreateStore.getState().promptHistory).toEqual([HISTORY[1]])
+ })
+
it('picking a prompt still works and does not delete it', () => {
const picked: string[] = []
show(HISTORY, (p) => picked.push(p))