How to know when and when not to give space?

I think my boyfriend has depression but sometimes I don't know whether he needs space or needs me to be there.

Last night for example he was acting all grumpy, complaining about everything, huffing and not wanting to watch or do anything I suggested. So I decided to just go to bed early. But when I did he got all annoyed at me asking why I was going to bed when it was so early. Basically acting like he didn't want me to leave. But when I was there he wouldn't talk to me or make a choice on what to do.

Worried it will be the same again tonight when I get home from work. I don't want him to be all down because it breaks my heart and its a pain in the arse because he refuses anything I suggest making for dinner or doing.