diff --git a/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx b/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx index dff645cce3..d85d6be119 100644 --- a/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx +++ b/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx @@ -134,40 +134,13 @@ export const PromptBox2D = ({ }, ]); - const [generationCountList, setGenerationCountList] = useState( - [], - ); - - // Update generation count options from selected model capabilities useEffect(() => { - const caps = getCapabilitiesForModel(selectedImageModel); - const items: PopoverItem[] = Array.from( - { length: caps.maxGenerationCount }, - (_, i) => i + 1, - ).map((count) => ({ - label: String(count), - selected: count === generationCount, - })); - setGenerationCountList(items); - - // Clamp selection to allowed range - if (generationCount < 1 || generationCount > caps.maxGenerationCount) { - setGenerationCount( - Math.min(Math.max(1, generationCount), caps.maxGenerationCount), - ); + if (selectedImageModel?.isValidGenerationCount(generationCount)) { + return; } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [selectedImageModel]); - - // Keep UI selection in sync when store value changes - useEffect(() => { - setGenerationCountList((prev) => - prev.map((item) => ({ - ...item, - selected: item.label === String(generationCount), - })), - ); - }, [generationCount]); + const defaultGenerations = selectedImageModel?.defaultGenerationCount || 4; + setGenerationCount(defaultGenerations); + }, [selectedImageModel, generationCount]); useEffect(() => { setResolutionList((prev) => @@ -209,17 +182,6 @@ export const PromptBox2D = ({ // Image prompt row replaces legacy upload/gallery UI - const handleGenerationCountSelect = (selectedItem: PopoverItem) => { - const count = parseInt(selectedItem.label, 10); - setGenerationCount(count); - setGenerationCountList((prev) => - prev.map((item) => ({ - ...item, - selected: item.label === selectedItem.label, - })), - ); - }; - const handlePaste = (e: React.ClipboardEvent) => { e.preventDefault(); e.stopPropagation(); @@ -613,23 +575,13 @@ export const PromptBox2D = ({ )} - - - } - buttonClassName="h-9" - /> - + { + setGenerationCount(count); + }} + /> )} - - - } - panelClassName="min-w-28" - buttonClassName="h-9" - /> - + { + onGenerationCountChange?.(count); + }} + />