commit b9207ea9c266325edc7e2e08ff3a3f62637c8ba6
parent 8868d3997f669378ed99152021a7fea3b908c413
Author: Hunter
Date:   Wed,  4 Mar 2026 15:15:34 -0500

fix push/pull bugs

Diffstat:
Mindex.html | 31++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/index.html b/index.html @@ -740,10 +740,15 @@ return task.state; // If no subtasks, keep current state } const anyUnchecked = task.subtasks.some(t => t.state === 0); + const allChecked = task.subtasks.every(t => t.state === 1); const allCheckedOrIndeterminate = task.subtasks.every(t => t.state === 1 || t.state === 2); - - if (allCheckedOrIndeterminate) { - return 1; // Checked + + if (allChecked) { + return 1; // All children genuinely checked + } else if (allCheckedOrIndeterminate) { + // Mix of checked and indeterminate (no unchecked) + // Indeterminate parent stays indeterminate; checked/unchecked parent becomes checked + return task.state === 2 ? 2 : 1; } else if (anyUnchecked) { return 0; // Unchecked } @@ -782,6 +787,14 @@ }); } + // Adjust a moved task's state to be valid under its new parent + function adjustMovedTaskState(movedTask, newParent) { + if (movedTask.state === 2 && newParent.state === 0) { + movedTask.state = 0; + updateSubtasksState(movedTask, 0); + } + } + function deleteSubtask(subtask) { const parentTask = taskPath[taskPath.length - 1]; const index = parentTask.subtasks.findIndex(t => t.id === subtask.id); @@ -960,6 +973,9 @@ // Add the subtask to the target task's subtasks targetTask.subtasks.push(subtask); + // Adjust moved task's state for its new parent + adjustMovedTaskState(subtask, targetTask); + // Update parent task state after removal updateTaskAndAncestors(parentTask); @@ -1005,6 +1021,9 @@ // Add the subtask to the target task's subtasks targetTask.subtasks.push(subtask); + // Adjust moved task's state for its new parent + adjustMovedTaskState(subtask, targetTask); + // Update parent task state after removal updateTaskAndAncestors(parentTask); @@ -1050,6 +1069,9 @@ grandParent.subtasks.splice(currentParentIndex + 1, 0, subtask); } + // Adjust moved task's state for its new parent + adjustMovedTaskState(subtask, grandParent); + // Update task states updateTaskAndAncestors(currentParent); updateTaskAndAncestors(grandParent); @@ -1110,6 +1132,9 @@ grandParent.subtasks.splice(currentParentIndex + 1, 0, subtask); } + // Adjust moved task's state for its new parent + adjustMovedTaskState(subtask, grandParent); + // Update task states updateTaskAndAncestors(currentParent); updateTaskAndAncestors(grandParent);