Open child windows for a document in a document based SwiftData app

In a document based SwiftData app for macOS, how do you go about opening a (modal) child window connected to the ModelContainer of the currently open document?

Using .sheet() does not really result in a good UX, as the appearing view lacks the standard window toolbar.

Using a separate WindowGroup with an argument would achieve the desired UX. However, as WindowGroup arguments need to be Hashable and Codable, there is no way to pass a ModelContainer or a ModelContext there:

        WindowGroup(id: "myWindowGroup", for: MyWindowGroupArguments.self) { $args in
                ViewThatOpensInAWindow(args: args)
        }

Is there any other way?

Open child windows for a document in a document based SwiftData app
 
 
Q