diff --git a/apps/web/app/(app)/automation/ReportMistake.tsx b/apps/web/app/(app)/automation/ReportMistake.tsx
index 09f75046..574e7aad 100644
--- a/apps/web/app/(app)/automation/ReportMistake.tsx
+++ b/apps/web/app/(app)/automation/ReportMistake.tsx
@@ -142,12 +142,15 @@ function Content({
setExpectedRuleId(expectedRuleId);
// if AI rule, then use AI to suggest a fix
- if (expectedRule && isAIRule(expectedRule)) {
+ if (
+ (expectedRule && isAIRule(expectedRule)) ||
+ (actualRule && isAIRule(actualRule))
+ ) {
onSetView("ai-fix");
setLoadingAiFix(true);
const response = await reportAiMistakeAction({
actualRuleId: result?.rule?.id,
- expectedRuleId,
+ expectedRuleId: expectedRule?.id,
email: {
from: message.headers.from,
subject: message.headers.subject,
@@ -182,7 +185,7 @@ function Content({
onSetView("manual-fix");
}
},
- [message, result?.rule?.id, onSetView, expectedRule],
+ [message, result?.rule?.id, onSetView, expectedRule, actualRule],
);
if (
@@ -212,6 +215,7 @@ function Content({
loadingAiFix={loadingAiFix}
fixedInstructions={fixedInstructions ?? null}
fixedInstructionsRule={fixedInstructionsRule ?? null}
+ messageId={message.id}
onBack={onBack}
onReject={() => onSetView("manual-fix")}
/>
@@ -237,6 +241,7 @@ function AIFixView({
loadingAiFix,
fixedInstructions,
fixedInstructionsRule,
+ messageId,
onBack,
onReject,
}: {
@@ -246,6 +251,7 @@ function AIFixView({
fixedInstructions: string;
} | null;
fixedInstructionsRule: Rule | null;
+ messageId: string;
onBack: () => void;
onReject: () => void;
}) {
@@ -260,29 +266,29 @@ function AIFixView({
return (
- {fixedInstructions?.fixedInstructions ? (
+ {fixedInstructionsRule?.instructions ? (
) : (
-
No rule found for the fixed instructions.
+
No rule found for the fixed instructions.
)}
{fixedInstructions?.ruleId && (
)}
-
+
+
);
}
@@ -340,16 +346,8 @@ function ThreadSettingsMismatchMessage({
rule is set to not run on threads.
-
-
+
+
);
@@ -368,9 +366,6 @@ function ManualFixView({
result: TestResult | null;
onBack: () => void;
}) {
- const [checking, setChecking] = useState(false);
- const [testResult, setTestResult] = useState();
-
return (
<>
<>
@@ -380,17 +375,7 @@ function ManualFixView({
{isAIRule(actualRule) ? (
) : (
-
-
-
+
)}
>
@@ -402,18 +387,7 @@ function ManualFixView({
{isAIRule(expectedRule) ? (
) : (
-
-
{expectedRule.name} is not an AI rule.
-
-
+
)}
>
@@ -430,39 +404,8 @@ function ManualFixView({
>
)}
-
-
-
- {testResult && (
-
- Test Result:
-
-
- )}
-
-
+
+
>
);
}
@@ -590,7 +533,7 @@ function AIFixForm({
return (
-
@@ -618,45 +563,60 @@ function AIFixForm({
}
function SuggestedFix({
+ messageId,
ruleId,
fixedInstructions,
onReject,
+ showRerunTestButton,
}: {
+ messageId: string;
ruleId: string;
fixedInstructions: string;
onReject: () => void;
+ showRerunTestButton: boolean;
}) {
const [isSaving, setIsSaving] = useState(false);
+ const [accepted, setAccepted] = useState(false);
return (
-
-
-
-
+ {accepted ? (
+ showRerunTestButton && (
+
+
+
+ )
+ ) : (
+
+
+
+
+ )}
);
}
@@ -677,3 +637,60 @@ function Instructions({
);
}
+
+function RerunTestButton({ messageId }: { messageId: string }) {
+ const [checking, setChecking] = useState(false);
+ const [testResult, setTestResult] = useState();
+
+ return (
+ <>
+
+
+ {testResult && (
+
+ Test Result:
+
+
+ )}
+ >
+ );
+}
+
+function BackButton({ onBack }: { onBack: () => void }) {
+ return (
+
+ );
+}
+
+function EditRuleButton({ ruleId }: { ruleId: string }) {
+ return (
+
+ );
+}
diff --git a/apps/web/app/(app)/automation/TestRules.tsx b/apps/web/app/(app)/automation/TestRules.tsx
index f3b8210e..4b3f4211 100644
--- a/apps/web/app/(app)/automation/TestRules.tsx
+++ b/apps/web/app/(app)/automation/TestRules.tsx
@@ -368,7 +368,7 @@ export function TestResultDisplay({
+
Matched rule "{result.rule.name}"