In the Face of Evil when the Doctor arrives on the planet he then breaks the fourth wall and says the following. “I think this is not Hyde Park. Could be a nexial discontinuity. Must remember to overhaul those tracers, put a knot in my hanky. [finds a knot in his hanky] Wonder what that was for. Little look around, Doctor? Why not.”
He doesn’t remember being on the planet until he observes the Mordee spaceship and then it comes back to him. During the Doctor's first visit he used Sidelian memory transfer to reprogram the Mordee computer with his own brain patterns. He forgot to erase his brain pattern afterwards and thus the computer which had become sentient formed two distinct personalities. It’s own and that of the Doctor’s.
I think Desmond has come full circle and now he realizes what it is he has to do in order to fix whatever it is that has gone wrong with the island/computer/entity.