It sounds like what you felt was real and mutual, and that’s not a small thing. At the same time, he’s showing you that he’s still emotionally tied up in his past relationship. Even if he cares about you, someone who is still dealing with ex isn’t fully available.
Stay friendly if you want, but protect your heart. If he truly wants something with you, he’ll come back when he’s fully single, emotionally clear, and ready to choose you without hesitation. Until then, you deserve someone who isn’t conflicted.