There was a pretty remarkable episode of Star Trek: The Next Generation
(last season, I think) in which the Enterprise was caught in some sort of
time bubble. The same sequence of events was repeated four times (maybe a
production shortcut, too), but each time there were more instances of deja
vu and generally suspicious occurrences. Finally people pieced things together
and solved the puzzle -- just in time to save the ship, of course. I'm
sorry I can't remember the title of this episode (or any clearer details),
but I hope this helps.