I'm writing a visionOS application using SwiftUI. The app utilises multiple WindowGroups.
I'm struggling with window management, especially in terms of window dismissal and app relaunch.
Here's a demo code presenting the problem:
import SwiftUI
@main
struct demoApp: App {
    var body: some Scene {
        WindowGroup {
            FirstView()
        }
        WindowGroup(id: "second") {
            SecondView()
        }
    }
}
import SwiftUI
struct FirstView: View {
    @Environment(\.openWindow) var openWindow
    var body: some View {
        VStack {
            Text("First window group")
            Button("Open second window group") {
                openWindow(id: "second")
            }
        }
    }
}
import SwiftUI
struct SecondView: View {
    var body: some View {
        Text("Second window group")
    }
}
I'm proceeding with the following actions:
- The app launches with the first - WindowGroup.
- Click the button calling - \.openWindowand opening the second- WindowGroup.
- Click the native 'close' button at the bottom of the first window. 
- Click the native 'close' button at the bottom of the second window. Now all of the groups are closed. 
- Relaunch the app by clicking the app icon from the Home menu. 
The app launches showing the second WindowGroup as it was the last one closed. I want the app to open the first WindowGroup (the root one in my case) instead.
Is there any way of specifying which window group of the scene should be opened in such situation?
I haven't found any information in the documentation about detecting which WindowGroup is opened at the moment, also haven't managed to come up with a solution using \.scenePhase.