Both the main event and the event inside the idh clause are past. Distinguish the subject of the main verb from that in the following subordinate clause.
Book example: جِئْتُكَ إِذْ طَلَعَتِ الشَّمْسُ.
I came to you when the sun rose.
Jiʾtu: past + first-person subject; -ka: object; idh: indeclinable past-time adverb in an accusative adverbial position; ṭalaʿat: verb + feminine marker; al-shamsu: subject.