Spaces:
Running
Running
Commit ·
ae39bbb
1
Parent(s): a23ac42
Exclude condition nodes from task counts and filter out inactive conditional path subgoals
Browse files942 unmodified lines9439449459469479489499509519529539549552 unmodified lines95895996096196296382 unmodified lines104610471048104910501051105210531054105510561057942 unmodified lineswhile (queue.length > 0) {const currentId = queue.shift();const currentNode = ndsList.find(node => node.id === currentId);if (!currentNode || currentNode.data.status !== 'Done') {return false;}const outEdges = edges.filter(e => e.source === currentId);outEdges.forEach(edge => {if (!visited.has(edge.target)) {visited.add(edge.target);queue.push(edge.target);}2 unmodified linesreturn true;};const queue = [];nodes.forEach(node => {82 unmodified lines.map(e => nds.find(node => node.id === e.target)).filter(Boolean);const subgoalsCount = connectedSubgoals.length;const subgoalsDone = connectedSubgoals.filter(node => isNodeAndTreeCompleted(node.id, nds)).length;const subgoalsData = {total: subgoalsCount,done: subgoalsDone};const currentSubgoals = n.data.subgoals || { total: 0, done: 0 };942 unmodified lines9439449459469479489499509519529539549559569579589599609619629639649659669679682 unmodified lines97197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101782 unmodified lines110011011102110311041105110611071108110911101111111211131114111511161117942 unmodified lineswhile (queue.length > 0) {const currentId = queue.shift();const currentNode = ndsList.find(node => node.id === currentId);if (!currentNode) continue;// If it is a task node (sketch or habit), it must be 'Done'if (currentNode.type === 'sketch' || currentNode.type === 'habit') {if (currentNode.data.status !== 'Done') {return false;}}const outEdges = edges.filter(e => e.source === currentId);outEdges.forEach(edge => {if (!visited.has(edge.target)) {// If the current node is a condition node, we ONLY follow selected options!if (currentNode.type === 'condition') {const selected = currentNode.data.selectedOptions || (currentNode.data.decision === 'True' ? ['opt-yes'] : (currentNode.data.decision === 'False' ? ['opt-no'] : []));if (!selected.includes(edge.sourceHandle)) {return; // Skip this edge, it's an inactive path}}visited.add(edge.target);queue.push(edge.target);}2 unmodified linesreturn true;};// Helper to get stats (total tasks and done tasks) in the active downstream tree of a nodeconst getSubgoalBranchStats = (nodeId, ndsList) => {let total = 0;let done = 0;const queue = [nodeId];const visited = new Set(queue);while (queue.length > 0) {const currentId = queue.shift();const currentNode = ndsList.find(node => node.id === currentId);if (!currentNode) continue;// If it is a task node, count itif (currentNode.type === 'sketch' || currentNode.type === 'habit') {total++;if (currentNode.data.status === 'Done') {done++;}}const outEdges = edges.filter(e => e.source === currentId);outEdges.forEach(edge => {if (!visited.has(edge.target)) {// If the current node is a condition node, we ONLY follow selected options!if (currentNode.type === 'condition') {const selected = currentNode.data.selectedOptions || (currentNode.data.decision === 'True' ? ['opt-yes'] : (currentNode.data.decision === 'False' ? ['opt-no'] : []));if (!selected.includes(edge.sourceHandle)) {return; // Skip this edge, it's an inactive path}}visited.add(edge.target);queue.push(edge.target);}});}return { total, done };};const queue = [];nodes.forEach(node => {82 unmodified lines.map(e => nds.find(node => node.id === e.target)).filter(Boolean);let totalTasks = 0;let doneTasks = 0;connectedSubgoals.forEach(node => {const stats = getSubgoalBranchStats(node.id, nds);totalTasks += stats.total;doneTasks += stats.done;});const subgoalsData = {total: totalTasks,done: doneTasks};const currentSubgoals = n.data.subgoals || { total: 0, done: 0 };
src/features/canvas/hooks/useCanvasLogic.js+66-6