From 6df32dd772fc33faebaf8e272bbdf9bf4052ef70 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 2 Jul 2025 22:10:43 -0700 Subject: [PATCH] feat: allow for manual rule creation --- .../GenerateRuleDialog/GenerationScreen.tsx | 27 ++++++++++------ .../GenerateRuleDialog/InputScreen.tsx | 32 ++++++++++++------- .../components/GenerateRuleDialog/index.tsx | 10 ++++++ 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx b/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx index ee67e42d3..112437c99 100644 --- a/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx +++ b/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx @@ -19,12 +19,14 @@ interface GenerationScreenProps { inputPrompt: string; onBack: () => void; onSuccess: () => void; + isManualMode?: boolean; } export function GenerationScreen({ inputPrompt, onBack, onSuccess, + isManualMode = false, }: GenerationScreenProps) { const ideMessenger = useContext(IdeMessengerContext); @@ -55,10 +57,12 @@ export function GenerationScreen({ } }); - // Start generation once when component mounts + // Start generation once when component mounts (only if not in manual mode) useEffect(() => { - void generateRule(); - }, []); + if (!isManualMode) { + void generateRule(); + } + }, [isManualMode]); const handleRuleTypeChange = (newRuleType: RuleType) => { setSelectedRuleType(newRuleType); @@ -130,7 +134,7 @@ export function GenerationScreen({ } }; - const showNameSpinner = isGenerating && !formData.name; + const showNameSpinner = isGenerating && !formData.name && !isManualMode; const tooltipId = "rule-type-tooltip"; return ( @@ -156,7 +160,7 @@ export function GenerationScreen({ type="text" className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus box-border w-full rounded-md border px-3 py-2 text-xs focus:outline-none" placeholder={showNameSpinner ? "" : "Enter rule name..."} - disabled={isGenerating} + disabled={isGenerating && !isManualMode} {...register("name")} /> {showNameSpinner && ( @@ -189,9 +193,9 @@ export function GenerationScreen({ onChange={(e) => handleRuleTypeChange(e.target.value as RuleType) } - disabled={isGenerating} + disabled={isGenerating && !isManualMode} > - {isGenerating ? ( + {isGenerating && !isManualMode ? ( ) : ( <> @@ -248,7 +252,8 @@ export function GenerationScreen({