There’s something amiss, something subtle, about this example…
Either begin the sentence with At first I thought or use until for the transition, but don’t do both; they don’t work together here.
I woke up to hear knocking on glass. At first I thought it was the window, but then I heard it come from the mirror again.
I woke up to hear knocking on glass. I thought it was the window until I heard it come from the mirror again.
Notice that the second version doesn’t have a comma, whereas the first one (a compound sentence with the conjunction but) does.