From 8f5eeb77a93350ac37e6c849b472d7dc189c070e Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 10:02:41 +0000 Subject: [PATCH] Fix invalid rule application feedback Display a modal when an invalid rule is applied to premises, and return the rule to the "Drop rule" box. --- src/components/RulesOfInferencePlayground.tsx | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/RulesOfInferencePlayground.tsx b/src/components/RulesOfInferencePlayground.tsx index 0cf186c..e378764 100644 --- a/src/components/RulesOfInferencePlayground.tsx +++ b/src/components/RulesOfInferencePlayground.tsx @@ -1,7 +1,8 @@ import { useEffect, useMemo, useState } from "react"; import { Button } from "@/components/ui/button"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { useToast } from "@/components/ui/use-toast"; +import { useToast } from "@/hooks/use-toast"; +import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; // Rules of Inference Playground (Example 1: Resolution) // Layout: 3 columns (Premises | Notepad lines with rule margin | Rules) @@ -127,6 +128,7 @@ export default function RulesOfInferencePlayground() { const [steps, setSteps] = useState([]); const [activePremises, setActivePremises] = useState([]); const [activeRule, setActiveRule] = useState(undefined); + const [showInvalidRuleModal, setShowInvalidRuleModal] = useState(false); useEffect(() => { // Reset when example changes @@ -203,11 +205,8 @@ export default function RulesOfInferencePlayground() { // Validate again defensively const valid = deriveCandidates(activeRule, activePremises).includes(result); if (!valid) { - toast({ - title: "Rule not applicable", - description: `The rule "${activeRule}" cannot be applied to the selected premises. Try a different rule or different premises.`, - variant: "destructive", - }); + setShowInvalidRuleModal(true); + setActiveRule(undefined); // Clear the rule from the drop zone return; } @@ -395,6 +394,23 @@ export default function RulesOfInferencePlayground() { + + {/* Invalid Rule Modal */} + + + + Rule Not Applicable + + The selected rule cannot be applied to the chosen premises. Please try a different rule or select different premises. + + + + setShowInvalidRuleModal(false)}> + Try Again + + + + ); } \ No newline at end of file