I've never coded…either in my sleep or while awake (I don't count html as coding), but I do have this effect when sewing. When I have a particularly vexing—or interesting—problem, I have often found that I will solve the problem while I'm asleep—and that I remember the solution when I wake. I don't know that tea has anything to do with it, but as long as I'm thinking of the problem when I fall asleep, I find that I know the answer when I awake.
I should figure out how to refine it, though, it's a great mind-hack!!
Yes Reg-o-rama! That exactly it, I'm grateful that you mentioned that. As I fall asleep I always think about the problem, in my case code. Then I miraculously have the answer in the morning. I think provoking thought about the problem while falling asleep seems to be the trigger for this "mind hack".
Thanks for enlightening me with the missing ingredient to the hack!