A few answers have noted that PhD theses with two authors do exist, and that is interesting trivia.
However, I think it is useful to address your underlying issue. I.e.,
what is the best strategy to adopt when you are collaborating closely with another PhD student, you are working on a similar topic, and you have the same supervisor?
This situation arises for many PhD students (I can think of a few), yet they still work out a way to write their own thesis.
If you are publishing joint papers, then you may want to think about ways that you and the other student can be the lead author on different papers. You probably also want to formalise the description of who made what contributions to each paper. I know at my institution, papers that form part of a PhD need to have a statement signed by all co-authors listing the contribution of each author.
You want to think about how your thesis can be distinct. You should work with your supervisor to carve out your unique focus.