And in the above quote, I think, like the op example, こんなところでぼうっとしているのだった is the same as こんなところでぼうっとしていた and 顔を覗かせてくるのだった is the same as 顔を覗かせてきた. (I mean that the のだったs in green don't have any meaning or specific function.)
While のである in red is for emphasis.
(That is to say, none of the のだs in question is explanatory のだs since nothing is explained)
Am I on the right track?