Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Keep the earliest stash so undo survives browsing examples

Bitti0d43ed52c49c
diff --git a/src/App.test.tsx b/src/App.test.tsx
index f2a56a4..5330f93 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -26,6 +26,16 @@ describe("project library controls", () => {
expect(box.value).toBe("a rocket launch over the ocean at dawn");
expect(screen.queryByRole("button", { name: /put my words back/ })).toBeNull();
+ // Browsing several examples is the ordinary way the row is used, so the
+ // offer must survive it — and must put back the ORIGINAL words, not the
+ // example the previous click left behind.
+ fireEvent.change(box, { target: { value: "a rocket launch over the ocean at dawn" } });
+ fireEvent.click(screen.getByRole("button", { name: "Product reveal" }));
+ fireEvent.click(screen.getByRole("button", { name: "Social ad" }));
+ fireEvent.click(screen.getByRole("button", { name: "Mini documentary" }));
+ fireEvent.click(screen.getByRole("button", { name: /put my words back/ }));
+ expect(box.value).toBe("a rocket launch over the ocean at dawn");
+
// Replacing an untouched example is not a loss, so nothing is offered.
fireEvent.change(box, { target: { value: "" } });
fireEvent.click(screen.getByRole("button", { name: "Social ad" }));
diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsx
index 8404f94..8c6587a 100644
--- a/src/components/PromptComposer.tsx
+++ b/src/components/PromptComposer.tsx
@@ -62,7 +62,13 @@ export function PromptComposer({ busy, onCreate }: PromptComposerProps) {
submits, rather than on a timer that could expire mid-read. */
const [replacedText, setReplacedText] = useState<string | null>(null);
const useIdea = (ideaPrompt: string) => {
- setReplacedText(replacesUserText ? prompt : null);
+ /* Keep the EARLIEST stash, not the latest. After the first chip click the
+ box holds an example, so replacesUserText is false — clearing here would
+ withdraw the undo offer the moment the user clicks a second chip to
+ compare examples, which is the ordinary way the chip row is used. An
+ undo that quietly stops being true is worse than none, because it is
+ what convinced them not to copy their text first. */
+ setReplacedText(replacesUserText ? prompt : replacedText);
setPrompt(ideaPrompt);
};
diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsx
index 63cb9fe..22b1a10 100644
--- a/src/components/workspace/ReferencesView.tsx
+++ b/src/components/workspace/ReferencesView.tsx
@@ -68,7 +68,7 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
<div>
<span className="eyebrow">Consistency library</span>
<h1>References</h1>
- <p>Keep the people, places, products, and visual rules for this project in one place. Each new shot uses the first two in this list.</p>
+ <p>Keep the people, places, products, and visual rules for this project in one place. Each new shot uses the first two it can use from this list.</p>
</div>
<div>
<button className="secondary-button" onClick={() => addTextReference()}><FileText size={16} /> New definition</button>