fix push/pull bugs

Hunter
Wednesday, March 4th, 2026 at 3:15 PM

index.html+28-3

index.html
 740  					return task.state; // If no subtasks, keep current state
 741  				}
 742  				const anyUnchecked = task.subtasks.some(t => t.state === 0);
 743 +				const allChecked = task.subtasks.every(t => t.state === 1);
 744  				const allCheckedOrIndeterminate = task.subtasks.every(t => t.state === 1 || t.state === 2);
     -				
     -				if (allCheckedOrIndeterminate) {
     -					return 1; // Checked
 745 +
 746 +				if (allChecked) {
 747 +					return 1; // All children genuinely checked
 748 +				} else if (allCheckedOrIndeterminate) {
 749 +					// Mix of checked and indeterminate (no unchecked)
 750 +					// Indeterminate parent stays indeterminate; checked/unchecked parent becomes checked
 751 +					return task.state === 2 ? 2 : 1;
 752  				} else if (anyUnchecked) {
 753  					return 0; // Unchecked
 754  				}

 787  				});
 788  			}
 789  
 790 +			// Adjust a moved task's state to be valid under its new parent
 791 +			function adjustMovedTaskState(movedTask, newParent) {
 792 +				if (movedTask.state === 2 && newParent.state === 0) {
 793 +					movedTask.state = 0;
 794 +					updateSubtasksState(movedTask, 0);
 795 +				}
 796 +			}
 797 +
 798  			function deleteSubtask(subtask) {
 799  				const parentTask = taskPath[taskPath.length - 1];
 800  				const index = parentTask.subtasks.findIndex(t => t.id === subtask.id);

 973  				// Add the subtask to the target task's subtasks
 974  				targetTask.subtasks.push(subtask);
 975  
 976 +				// Adjust moved task's state for its new parent
 977 +				adjustMovedTaskState(subtask, targetTask);
 978 +
 979  				// Update parent task state after removal
 980  				updateTaskAndAncestors(parentTask);
 981  

1021  				// Add the subtask to the target task's subtasks
1022  				targetTask.subtasks.push(subtask);
1023  
1024 +				// Adjust moved task's state for its new parent
1025 +				adjustMovedTaskState(subtask, targetTask);
1026 +
1027  				// Update parent task state after removal
1028  				updateTaskAndAncestors(parentTask);
1029  

1069  					grandParent.subtasks.splice(currentParentIndex + 1, 0, subtask);
1070  				}
1071  
1072 +				// Adjust moved task's state for its new parent
1073 +				adjustMovedTaskState(subtask, grandParent);
1074 +
1075  				// Update task states
1076  				updateTaskAndAncestors(currentParent);
1077  				updateTaskAndAncestors(grandParent);

1132  					grandParent.subtasks.splice(currentParentIndex + 1, 0, subtask);
1133  				}
1134  
1135 +				// Adjust moved task's state for its new parent
1136 +				adjustMovedTaskState(subtask, grandParent);
1137 +
1138  				// Update task states
1139  				updateTaskAndAncestors(currentParent);
1140  				updateTaskAndAncestors(grandParent);