MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / EditFilteringModal

Function EditFilteringModal

components/approval/editModals.tsx:27–186  ·  view source on GitHub ↗
(props: {
  open: boolean;
  setOpen: () => void;
  actions: { name: string; description: string }[];
  setChosenActions: (chosenActions: string[]) => void;
  messageData: { id: string; raw_text: string };
})

Source from the content-addressed store, hash-verified

25import QuestionText from "./question";
26
27export function EditFilteringModal(props: {
28 open: boolean;
29 setOpen: () => void;
30 actions: { name: string; description: string }[];
31 setChosenActions: (chosenActions: string[]) => void;
32 messageData: { id: string; raw_text: string };
33}) {
34 const { profile } = useProfile();
35 const supabase = useSupabaseClient<Database>();
36 const [localChosenFunctions, setLocalChosenFunctions] = useState<
37 string[] | null
38 >(
39 parseFilteringOutputv3(
40 props.messageData?.raw_text ?? "",
41 props.actions.map((m) => snakeToCamel(m.name)),
42 )?.selectedFunctions ?? null,
43 );
44 const [warningModalOpen, setWarningModalOpen] = useState<boolean>(false);
45 const [changed, setChanged] = useState<boolean>(false);
46 useEffect(() => {
47 if (props.open) {
48 setLocalChosenFunctions(
49 parseFilteringOutputv3(
50 props.messageData?.raw_text ?? "",
51 props.actions.map((a) => a.name),
52 )?.selectedFunctions,
53 );
54 }
55 }, [props.messageData, props.open]);
56
57 return (
58 <>
59 <WarningModal
60 open={warningModalOpen}
61 setOpen={setWarningModalOpen}
62 title={"Are you sure you want to regenerate the answer?"}
63 description={
64 "This will overwrite the current generated answer with a new one. This action cannot be undone."
65 }
66 actionName={"Regenerate Answer"}
67 actionColour={"red"}
68 action={async () => {
69 if (!changed || !localChosenFunctions) return;
70 const { error } = await supabase
71 .from("approval_answer_messages")
72 .update({
73 raw_text: `<thinking>${
74 profile?.full_name ?? profile?.email_address ?? "A user"
75 } set this through the UI at ${new Date().toString()}</thinking>
76<selected_functions>
77${localChosenFunctions.join("\n")}
78</selected_functions>`,
79 })
80 .eq("id", props.messageData.id);
81 if (error) throw new Error(error.message);
82 props.setChosenActions(localChosenFunctions);
83 }}
84 />

Callers

nothing calls this directly

Calls 4

useProfileFunction · 0.90
parseFilteringOutputv3Function · 0.90
snakeToCamelFunction · 0.90
classNamesFunction · 0.90

Tested by

no test coverage detected