Well, I've found a way to make that whole thing work that I really like. It not only works based on what we actually saw, it does so without taking anything away from John's cleverness. And more importantly, it allows me to enjoy his confrontation with Jesse without rolling my eyes. So here goes...
He never did follow Riley around. It was a bluff.
John didn't figure anything out until Sarah told him about Riley's "bleached skulls" breakdown and blabbing about the Mexico trip. He knew he hadn't told her about judgment day, so that's the moment he realized Riley was future girl. He then backtracks through the time he spent with her — backtracks to carrots and apples, how she was in Mexico, etc. It all fits. I also think Sarah saying "I don't believe you" is what makes it the "bad day" John refers to when he later talks to Jesse.
He knew it was unlikely that Cameron killed Riley once he saw the body, which meant her death was either a random crime or she was killed by a co-conspirator. Future girl dropping into his life pretending not to be future girl logically meant there was a plot of some sort. So that's the idea he started running with — there's another future person somewhere who's involved and who likely killed Riley. But who and why?
John talks to Derek, fishing for information and it all comes out. John probably tells him that Riley was from the future and must have been plotting something. He isn't sure what, but suspects it might be an attempt to frame Cameron for murder — maybe an attempt to get him to turn on Cameron. Bingo. Derek makes the connection to Jesse. That also explains why we had to have that scene where Jesse was callous about Riley's death and Derek was all innocent life lost is horrible! It gives Derek something from his own experience to connect into what John has already figured out. Between the two of them, they unravel the whole plot.
John has Derek take him to Jesse, where he confronts her about it all. At that point he does know everything, but he bluffs about having figured it out a while back and bluffs that he gambled with Riley's life so that he could win the game. The reason he bluffs is to intimidate Jesse and prevent her from thinking that it might have worked or that she almost won. He bluffs to win the game right then and there. And he bluffs to make it known that you don't fuck with John Connor.
It works really well for me because it allows John be intelligent, gutsy, clever and not retconned.