This may be a Vision Pro bug. When I return to my Mac after a session using Apple’s Vision Pro with a Virtual Display; with Scrivener open; and having maximized window size (but not in Full Screen mode), when I return to the MacBook Pro 14 (current OS), the Scrivener window is typically at four times the width of the actual monitor.
I write on my MBP, but I do a lot of work when travelling on the Vision Pro; so this comes up a lot. It’s nondestructive of course, but very irritating; and the window can’t be resized to fit the monitor I actually have, using the fit and resize controls under the green window button; it retains the reference to the AVP virtual monitor size, it seems.
I see this behaviour with one other app, which is Affinity Designer. So I suspect it’s a simple notification that your code ignores, because other apps adapt fine.