Yeah, if it were up to me to rewrite Star Wars from memory while taking liberties in a postapocalyptic context, that’s one thing I’d tweak. I think the Jedi ghosts should function with ambiguity so that even if you wanted to say they were imaginary it wouldn’t change the story. The two instances that sort of do this is Kenobi in ROTJ and Luke in TROS, as their ghosts reveal novel, technical information to the living characters. It’s one thing to have your mentor pop up and encourage you to use what you know or even piece something together from what you know, and another to pop up and reveal previously unknown intel.
But that’s moot for our purposes here. Even so, though, it would seem sorta dumb to me for Luke to just say, “Well when I died I snooped around and learned that you were Palpatine’s granddaughter and so I told Leia.” But you’re right; I can’t really imagine how else Leia would possibly have known!
Imagine if R2-D2 had been shot by stormtroopers on the Death Star while attempting to come aboard the Falcon, and so Kenobi allows himself to be killed. Then when they make it to the rebel base, he appears as a ghost to deliver his omniscient insight about how to coordinate an assault.
All this is to say that I just can’t make any sense out of the idea that Leia knew. And so I would rather Luke take a “so what?” approach, as if to say “I’ve been there, kid” and tell her it doesn’t mean anything. It’d be nice to include Leia in the scene to a greater extent, and what the scriptwriters did sort of makes sense in an immediate emotional way even though it causes confusion and muddies the story up to that point.