Add advanced generation options with Explicit and Smart modes
- Implemented `AdvancedGenerationOptions` component for toggling Explicit and Smart modes with confirmation dialogs. - Integrated generation options into `GhostWriter`, `DraftCompanion`, and `ShortStoryGenerator`. - Introduced `ToggleWithConfirmation` component for user interaction with alerts. - Updated `InputField` to support centered alignment for better layout flexibility. - Localized Explicit and Smart mode strings in English and French. - Enhanced content preview logic to filter placeholder text before display. - Added `autoUpdater` initialization checks and refactored updater setup for improved reliability.
This commit is contained in:
@@ -53,6 +53,7 @@ import QuillSense from "@/lib/models/QuillSense";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {LangContext, LangContextProps} from "@/context/LangContext";
|
||||
import {AIUsageContext, AIUsageContextProps} from "@/context/AIUsageContext";
|
||||
import AdvancedGenerationOptions from "@/components/form/AdvancedGenerationOptions";
|
||||
|
||||
interface ShortStoryGeneratorProps {
|
||||
onClose: () => void;
|
||||
@@ -93,7 +94,10 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
|
||||
const [hasGenerated, setHasGenerated] = useState<boolean>(false);
|
||||
const [abortController, setAbortController] = useState<ReadableStreamDefaultReader<Uint8Array> | null>(null);
|
||||
|
||||
|
||||
const [useExplicit, setUseExplicit] = useState<boolean>(false);
|
||||
const [useSmart, setUseSmart] = useState<boolean>(false);
|
||||
|
||||
const isAnthropicEnabled: boolean = QuillSense.isAnthropicEnabled(session);
|
||||
const isSubTierTwo: boolean = QuillSense.getSubLevel(session) >= 2;
|
||||
const hasAccess: boolean = isAnthropicEnabled || isSubTierTwo;
|
||||
@@ -169,7 +173,9 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
language: language,
|
||||
dialogueType: dialogueType,
|
||||
directives: directives,
|
||||
wordsCount: wordsCount
|
||||
wordsCount: wordsCount,
|
||||
useExplicit: useExplicit,
|
||||
useSmart: useSmart,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -338,7 +344,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 flex items-center justify-center bg-overlay z-40 backdrop-blur-sm">
|
||||
<div ref={modalRef}
|
||||
@@ -454,7 +460,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{activeTab === 2 && (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
@@ -487,7 +493,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<InputField
|
||||
icon={faComments}
|
||||
fieldName={t("shortStoryGenerator.fields.dialogue")}
|
||||
@@ -505,7 +511,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
<InputField
|
||||
icon={faPencilAlt}
|
||||
fieldName={t("shortStoryGenerator.fields.directives")}
|
||||
@@ -519,7 +525,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{activeTab === 3 && (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="space-y-4">
|
||||
@@ -535,7 +541,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="space-y-4">
|
||||
<InputField
|
||||
icon={faCloudSun}
|
||||
@@ -549,7 +555,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<InputField
|
||||
icon={faUserAstronaut}
|
||||
fieldName={t("shortStoryGenerator.fields.character")}
|
||||
@@ -561,9 +567,16 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
<AdvancedGenerationOptions
|
||||
useExplicit={useExplicit}
|
||||
setUseExplicit={setUseExplicit}
|
||||
useSmart={useSmart}
|
||||
setUseSmart={setUseSmart}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{activeTab === 4 && (
|
||||
<div className="p-6">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
@@ -600,7 +613,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{isGenerating && !generatedText ? (
|
||||
<div className="flex flex-col items-center justify-center py-20">
|
||||
<FontAwesomeIcon icon={faSpinner}
|
||||
@@ -613,7 +626,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
<EditorContent editor={editor} className="prose prose-invert max-w-none"/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{generatedText && (
|
||||
<div className="flex justify-between items-center mt-4 pt-4 border-t border-secondary">
|
||||
<div className="flex items-center text-sm text-text-secondary">
|
||||
@@ -640,7 +653,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
<FontAwesomeIcon icon={faChevronRight} className="mr-2 rotate-180 w-4 h-4"/>
|
||||
{t("shortStoryGenerator.navigation.previous")}
|
||||
</button>
|
||||
|
||||
|
||||
<div className="flex items-center space-x-3">
|
||||
<button
|
||||
onClick={onClose}
|
||||
@@ -649,7 +662,7 @@ export default function ShortStoryGenerator({onClose}: ShortStoryGeneratorProps)
|
||||
>
|
||||
{activeTab === 4 && hasGenerated ? t("shortStoryGenerator.navigation.close") : t("shortStoryGenerator.navigation.cancel")}
|
||||
</button>
|
||||
|
||||
|
||||
{activeTab < 3 ? (
|
||||
<button
|
||||
onClick={() => setActiveTab(activeTab + 1)}
|
||||
|
||||
Reference in New Issue
Block a user