diff --git a/frontend/src/components/Generator.tsx b/frontend/src/components/Generator.tsx index f25bdec..7d5c97a 100644 --- a/frontend/src/components/Generator.tsx +++ b/frontend/src/components/Generator.tsx @@ -192,10 +192,12 @@ export default function Generator({ onGenerate }: Props) { // Append continuation to existing prompt setPrompt(prev => { const trimmed = prev.trimEnd() - // If result starts lowercase, it flows from the input — just space - // If result starts uppercase, treat as new sentence — period + space + const endsWithPunct = /[.!?,;:]$/.test(trimmed) const startsLower = /^[a-z]/.test(result) - const separator = startsLower ? ' ' : '. ' + // Already punctuated? Just space. + // Flows naturally (lowercase)? Just space. + // Otherwise: period + space for a new sentence. + const separator = (endsWithPunct || startsLower) ? ' ' : '. ' return trimmed + separator + result }) } else { @@ -229,8 +231,9 @@ export default function Generator({ onGenerate }: Props) { // Fallback: append to additional field setStructuredPrompt(prev => { const existing = prev.additional?.trim() || '' + const endsWithPunct = /[.!?,;:]$/.test(existing) const startsLower = /^[a-z]/.test(result) - const separator = startsLower ? ' ' : '. ' + const separator = (endsWithPunct || startsLower) ? ' ' : '. ' return { ...prev, additional: existing + separator + result } }) } else {