Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/thumbnails/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,17 @@ export default function Home() {
setBlobUrls([]);
};

// Start over: clear results and go back to step 1
const handleStartOver = () => {
cleanupBlobUrls();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If “Start Over” can be clicked while generation or suggested-refinement fetches are still in flight, those async completions can still update results/suggestedRefinements (index-keyed) after this reset, potentially causing stale suggestions or a stuck loading state. Consider adding a guard/cancellation mechanism for outstanding async work when starting over.

🤖 Was this useful? React with 👍 or 👎

setResults([]);
setLabeledResults([]);
setSuggestedRefinements({});
setLoadingSuggestions({});
setError(null);
goTo(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleStartOver clears generation state but doesn’t reset refinementState (e.g., isRefinementMode) or close related UI like the history browser. If a user clicks Start Over while refining, this can leave the app “stuck” in refinement mode and also prevent suggested refinements from being fetched on the next run due to the !refinementState.isRefinementMode guard.

🤖 Was this useful? React with 👍 or 👎

};

const generate = async () => {
// Get all valid template IDs (custom + curated)
const allValidTemplateIds = new Set([
Expand Down Expand Up @@ -2125,7 +2136,7 @@ export default function Home() {

{/* Compact nav */}
<div className={styles.navRow} style={{ marginTop: 12 }}>
<button onClick={() => goTo(1)} style={{ padding: '6px 12px', fontSize: 13 }}>← Start Over</button>
<button onClick={handleStartOver} style={{ padding: '6px 12px', fontSize: 13 }}>← Start Over</button>
</div>
</>
)}
Expand Down