Well don't beat yourself up over it. You are not the first. And she is not the only child like that.
She seems to have a real radar, even if she is sleeping, that you have left the room.
Do you have white noise on while she sleeps? Maybe that will help.
Does she have a lovey? That might help too.
A flashlight in her bed with her? That might help too.
Have you talked to her about it? She is 4 now... she can understand.
Does she have night-time fears? This is common at certain age junctures and at this age.
Would you be inclined to just compromise... meaning, that she STAY in her "room" versus in her "bed" only? ie: my daughter went through a phase where she did not want to sleep IN her bed, but would sleep on the FLOOR next to her bed. (who knows why). LOL
And she would make a "nest" on the floor with all her comfy blankets and stuffed animals and then would sleep, well, amongst all that. And she'd do that every night. Then she got out of that phase.
But for me, the main thing was that she SLEPT... so I didn't mind if she slept on the floor.
Or, you sit on a chair in her room, instead of lying down on the floor in her room. And tell her. THIS is the routine now. This or I Ieave.
And you give her a head's up... that WHEN she falls asleep, you will leave. But you WILL check in on her periodically. (not that you 'have to' do that... but just to appease her mind), and that might console her.
Tell her she is a big girl. 4 years old. She CAN do it.
I know, its not easy. One day she will not even want you around. Though hard, just enjoy it. She probably just misses you and finds you very comforting.
My daughter tells me that too... that "Mommy you are so cozy..." when she falls asleep.
All the best,
Susan