diff --git a/src/components/OutputsTable/ScenarioEditor.tsx b/src/components/OutputsTable/ScenarioEditor.tsx
index 79e1dc7..ef15b27 100644
--- a/src/components/OutputsTable/ScenarioEditor.tsx
+++ b/src/components/OutputsTable/ScenarioEditor.tsx
@@ -5,7 +5,7 @@ import { type Scenario } from "./types";
import { useExperiment, useHandledAsyncCallback } from "~/utils/hooks";
import { useState } from "react";
-import { Box, Button, Flex, HStack, Icon, Stack, Tooltip } from "@chakra-ui/react";
+import { Box, Button, Flex, HStack, Icon, Spinner, Stack, Tooltip } from "@chakra-ui/react";
import { cellPadding } from "../constants";
import { BsX } from "react-icons/bs";
import { RiDraggable } from "react-icons/ri";
@@ -43,11 +43,12 @@ export default function ScenarioEditor({
}, [mutation, values]);
const hideMutation = api.scenarios.hide.useMutation();
- const [onHide] = useHandledAsyncCallback(async () => {
+ const [onHide, hidingInProgress] = useHandledAsyncCallback(async () => {
await hideMutation.mutateAsync({
id: scenario.id,
});
await utils.scenarios.list.invalidate();
+ await utils.promptVariants.stats.invalidate();
}, [hideMutation, scenario.id]);
const reorderMutation = api.scenarios.reorder.useMutation();
@@ -106,7 +107,7 @@ export default function ScenarioEditor({
cursor: "pointer",
}}
>
-
+
{
@@ -54,10 +55,15 @@ export const scenariosRouter = createTRPCRouter({
}),
hide: publicProcedure.input(z.object({ id: z.string() })).mutation(async ({ input }) => {
- return await prisma.testScenario.update({
+ const hiddenScenario = await prisma.testScenario.update({
where: { id: input.id },
data: { visible: false, experiment: { update: { updatedAt: new Date() } } },
});
+
+ // Reevaluate all evaluations now that this scenario is hidden
+ await reevaluateAll(hiddenScenario.experimentId);
+
+ return hiddenScenario;
}),
reorder: publicProcedure
diff --git a/src/server/utils/evaluations.ts b/src/server/utils/evaluations.ts
index bc5df23..24d519a 100644
--- a/src/server/utils/evaluations.ts
+++ b/src/server/utils/evaluations.ts
@@ -89,3 +89,11 @@ export const reevaluateEvaluation = async (evaluation: Evaluation) => {
}),
);
};
+
+export const reevaluateAll = async (experimentId: string) => {
+ const evaluations = await prisma.evaluation.findMany({
+ where: { experimentId },
+ });
+
+ await Promise.all(evaluations.map(reevaluateEvaluation));
+}