How to overcome the feeling of wasted time when i worked hard on a single task and still couldn’t finish it as i planned

Katja X.
I often struggle greatly with this as I have depression, but I try to cut myself some slack and celebrate the amount I did get done and see if I am able to do some other small unrelated task, like going for a short walk or sweeping or doing the dishes, and finish that instead so I can feel accomplished in something and try to recenter myself and refocus on whats important which is my mental well being since it is quite unlikely that I will even think about the task much later in life. And if I feel better about accomplishing something and part of the task I will feel more inclined to return to the task later on when I am no longer fustrated or unmotivated.