Test A Foldable App Across Multiple Scenes

Two windows can show the same document without sharing every piece of interface state. If opening Search in one window changes the selection in the other, the app probably has a scene-level value stored in a process-wide singleton.

iPhone Duo makes this an iPhone concern. Apple’s multi-display and scene talk explains that it supports multiple instances of an app’s UI. It also describes a crucial boundary: new windows can be created on the inner display, while that action is unavailable on the outer display.

The device is announced, with availability beginning October 23. You can test much of the ownership model using existing multiwindow environments before claiming any Duo hardware validation.

Put each value at the right scope

A simple document editor has three different kinds of state:

StateOwnerExpected behavior
Selected document and search queryOne sceneSelecting in A does not navigate B
Unsaved edit buffer and undo interactionOne editor sessionClosing B does not discard A’s edit
Saved document revisionShared document repositorySuccessful saves become visible to interested scenes

A scene’s navigation restoration can use appropriate SceneStorage values. It is not the durable store for document contents. Restoration and data persistence solve different problems.

For an initial policy test, ordinary values are enough:

import Foundation

struct SceneEditorState {
    var selectedID: UUID?
    var search = ""
}

let firstDocumentID = UUID()
let secondDocumentID = UUID()
var sceneA = SceneEditorState(selectedID: firstDocumentID)
let sceneB = SceneEditorState(selectedID: secondDocumentID)
sceneA.search = "invoice"

precondition(sceneB.search.isEmpty)

The generated identifiers stand in for two records from your document list. In the app, create an editor state per scene rather than injecting one shared navigation object into every WindowGroup instance.

Serialization alone does not prevent a stale save

An actor can serialize repository access. It cannot know that a text value was edited from an old revision unless the caller tells it.

Suppose both scenes load revision zero. Scene A saves its changes, producing revision one. Scene B then saves its old buffer. A plain actor method assigning text would safely serialize both calls and still lose A’s work.

Make the expected revision part of the save contract:

import Foundation

struct Draft: Sendable, Equatable {
    let id: UUID
    var revision: Int
    var text: String
}
actor DraftRepository {
    enum SaveError: Error {
        case missing
        case conflict(Draft)
    }
    private var drafts: [UUID: Draft]
    init(_ initial: [Draft]) {
        drafts = Dictionary(uniqueKeysWithValues: initial.map { ($0.id, $0) })
    }
    func read(_ id: UUID) -> Draft? { drafts[id] }
    func save(id: UUID, expectedRevision: Int, text: String) throws -> Draft {
        guard var draft = drafts[id] else { throw SaveError.missing }
        guard draft.revision == expectedRevision else { throw SaveError.conflict(draft) }
        draft.revision += 1
        draft.text = text
        drafts[id] = draft
        return draft
    }
}

The check and update have no suspension between them. In this in-memory example, an old revision produces a conflict carrying the current document, leaving the saved value intact.

A production persistence layer must perform the equivalent check and write in one transaction. If you add await to the middle of the actor method, actor reentrancy can invalidate assumptions held before that suspension. An actor around several database calls is not a substitute for the database’s transaction boundary.

Give a conflict a visible recovery path

When B receives a conflict, retain B’s unsaved text. Offer a comparison, duplicate document, or an explicit merge based on the product. Do not catch the error and immediately retry with the newest revision; that would turn the protection into an automatic overwrite.

For field-based documents, a three-way merge can reconcile nonconflicting edits. A freeform drawing or rich-text document may need a more specialized model. The correct choice depends on what an edit means in that document.

After a successful save, notify interested scenes that a newer revision exists. A clean editor may reload it. A dirty editor should reconcile it against its own base revision. Do not make “observe every update” mean “replace every open editor’s current contents.”

Treat window creation as a fallible request

Supporting multiple scenes does not mean a new scene can be created in every current presentation. Apple’s Duo talk recommends handling scene-request errors and using the system UIWindowSceneActivationAction where appropriate because its availability adapts to the current environment.

Do not maintain a device-name allowlist to decide whether the New Window action works. Reevaluate scene availability when the presentation changes, and keep a useful in-place navigation path if the new window cannot open.

This post’s fixture does not call Duo-specific APIs. The new-device UI path still needs the appropriate SDK, presentation, and error handling verified in your app.

Run a two-scene regression with actual edits

Open different documents in A and B. Search and navigate independently. Then open the same document in both, edit A and save, and attempt to save B’s older buffer. The saved document must still contain A’s change, while B must retain its unsaved work and show a conflict.

Close one scene and continue editing the other. Restore a scene after process termination. Repeat with an external keyboard and a narrow window. On Duo-capable test environments, add inner/outer display transitions and a new-window request while availability changes.

September 2026 verification: the actor fixture passed independent selection/search, successful revision advancement, stale-save rejection, and preservation of an unrelated document. It also type-checked for iOS 17 using SDK 27.0. Actual multiwindow UI, restoration, and Duo transitions remain integration checks.