I mean, I feel like I basically did the same thing when you left before too. I don't think you can make it better, and I don't know that you can force someone to cheer up - but you can be there when they need you.
Like anything you can say just seems lame - like, you can say 'maybe they'll come back', and they might, but even if they do - you'll have missed life experiences when they were gone, and they may not remember being here before and the experiences you had there, so it's not a sure deal.