style: cleaned up code for InferredBeliefNode.tsx

ref: N25B-433
This commit is contained in:
JGerla
2026-01-13 08:59:34 +01:00
parent f8acdda03c
commit 2d9f430a30

View File

@@ -13,9 +13,6 @@ import switchStyles from './InferredBeliefNode.module.css';
import {MultiConnectionHandle, SingleConnectionHandle} from "../components/RuleBasedHandle.tsx";
import {allowOnlyConnectionsFromType} from "../HandleRules.ts";
import useFlowStore from "../VisProgStores.tsx";
import type {BasicBeliefType} from "./BasicBeliefNode.tsx";
/**
* The default data structure for an InferredBelief node
@@ -27,31 +24,14 @@ export type InferredBeliefNodeData = {
hasReduce: boolean;
};
type Belief = ReducedInferredBelief | BasicBeliefType;
type ReducedInferredBelief = {
id: string,
left: Belief,
operator: "AND" | "OR"
right: Belief
};
type InferredBelief = {
left: string | undefined,
operator: boolean,
right: string | undefined,
}
// helper validation function for InferredBelief objects
// const isValidInferredBelief = (inferredBelief: InferredBelief) : boolean => {
// return !(inferredBelief.left && inferredBelief.right);
// };
export type InferredBeliefNode = Node<InferredBeliefNodeData>;
/**
* This function is called whenever a connection is made with this node type as the target
* @param _thisNode the node of this node type which function is called
@@ -107,6 +87,7 @@ export function InferredBeliefDisconnectionSource(_thisNode: Node, _targetNodeId
*/
const noBeliefCycles : HandleRule = (connection, _): RuleResult => {
const { nodes, edges } = useFlowStore.getState();
function checkForCycle(targetNodeId: string, current: string) : RuleResult {
const outgoingBeliefs = getOutgoers({id: current}, nodes, edges).filter(node => node.type === 'inferred_belief');
if (outgoingBeliefs.length === 0) return ruleResult.satisfied;