Open source CapCut alternative.
TypeScript
feat(ios): videos wait for Wi-Fi
David Le3a70621fb9dc
diff --git a/apps/ios/Donkey/DonkeyApp.swift b/apps/ios/Donkey/DonkeyApp.swiftindex 1f9da9b0..0cc17dee 100644--- a/apps/ios/Donkey/DonkeyApp.swift+++ b/apps/ios/Donkey/DonkeyApp.swift@@ -54,6 +54,7 @@ final class AppWiring {journal: store,service: cloud,signedIn: { auth.isSignedIn },+ wiFiOnlyForMedia: { app.mediaOnWiFiOnly },uploadFor: { recording inawait CutCloudClient.uploadPayload(for: recording, media: media)}diff --git a/apps/ios/Donkey/Settings.bundle/Root.plist b/apps/ios/Donkey/Settings.bundle/Root.plistnew file mode 100644index 00000000..79b45d87--- /dev/null+++ b/apps/ios/Donkey/Settings.bundle/Root.plist@@ -0,0 +1,29 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>StringsTable</key>+ <string>Root</string>+ <key>PreferenceSpecifiers</key>+ <array>+ <dict>+ <key>Type</key>+ <string>PSGroupSpecifier</string>+ <key>Title</key>+ <string>Sync</string>+ <key>FooterText</key>+ <string>Notes, folders and saved links move on any connection. Videos wait for Wi-Fi while this is on, and go up as soon as the phone joins a network.</string>+ </dict>+ <dict>+ <key>Type</key>+ <string>PSToggleSwitchSpecifier</string>+ <key>Title</key>+ <string>Videos on Wi-Fi Only</string>+ <key>Key</key>+ <string>mediaOnWiFiOnly</string>+ <key>DefaultValue</key>+ <true/>+ </dict>+ </array>+</dict>+</plist>diff --git a/apps/ios/Donkey/Settings.bundle/en.lproj/Root.strings b/apps/ios/Donkey/Settings.bundle/en.lproj/Root.stringsnew file mode 100644index 00000000..23f7733f--- /dev/null+++ b/apps/ios/Donkey/Settings.bundle/en.lproj/Root.strings@@ -0,0 +1,3 @@+"Sync" = "Sync";+"Videos on Wi-Fi Only" = "Videos on Wi-Fi Only";+"Notes, folders and saved links move on any connection. Videos wait for Wi-Fi while this is on, and go up as soon as the phone joins a network." = "Notes, folders and saved links move on any connection. Videos wait for Wi-Fi while this is on, and go up as soon as the phone joins a network.";diff --git a/apps/ios/Donkey/Support/NetworkMonitor.swift b/apps/ios/Donkey/Support/NetworkMonitor.swiftindex 35bf4a76..e6b27995 100644--- a/apps/ios/Donkey/Support/NetworkMonitor.swift+++ b/apps/ios/Donkey/Support/NetworkMonitor.swift@@ -4,7 +4,8 @@ import Network/// Feeds the sync engine the current network path so policy can decide what/// moves. Cellular and other expensive paths (personal hotspots) both count-/// as cellular: they spend metered data.+/// as cellular: they spend metered data, so the Wi-Fi-only setting holds+/// media back on either.final class NetworkMonitor {private let monitor = NWPathMonitor()diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/AppModel.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/AppModel.swiftindex 1392f972..b31afd52 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/AppModel.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/AppModel.swift@@ -16,6 +16,16 @@ public final class AppModel {didSet { defaults.set(appearance.rawValue, forKey: Self.appearanceKey) }}+ /// Videos ride Wi-Fi only. Notes, folders, deletes and saved links are+ /// small enough to spend cellular data on; a recording is not, so it waits+ /// for Wi-Fi while this holds. The sync engine reads it as policy.+ ///+ /// The switch lives on the app's own page in iOS Settings, which writes+ /// this key; `refreshFromDefaults()` is how the app picks up what it says.+ public var mediaOnWiFiOnly: Bool {+ didSet { defaults.set(mediaOnWiFiOnly, forKey: Self.mediaOnWiFiOnlyKey) }+ }+/// A transient confirmation message ("Note saved"), cleared by the UI.public var toast: String?@@ -24,11 +34,21 @@ public final class AppModel {private let defaults: UserDefaultsprivate static let appearanceKey = "appearancePreference"+ private static let mediaOnWiFiOnlyKey = "mediaOnWiFiOnly"public init(defaults: UserDefaults = .standard) {self.defaults = defaultsappearance = defaults.string(forKey: Self.appearanceKey).flatMap(AppearancePreference.init(rawValue:)) ?? .system+ mediaOnWiFiOnly = defaults.object(forKey: Self.mediaOnWiFiOnlyKey) as? Bool ?? true+ }++ /// Take whatever the defaults hold now. The Settings app writes them+ /// while this app is away, so the shell calls this as it comes forward.+ /// Assigning only on a real change keeps the write-back from looping.+ public func refreshFromDefaults() {+ let stored = defaults.object(forKey: Self.mediaOnWiFiOnlyKey) as? Bool ?? true+ if stored != mediaOnWiFiOnly { mediaOnWiFiOnly = stored }}public func show(toast message: String) {diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/CloudSync.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/CloudSync.swiftindex ff7e9cab..5ddc5a0d 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/CloudSync.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/CloudSync.swift@@ -363,9 +363,11 @@ public protocol CloudProjectsServicing: AnyObject, Sendable {// MARK: - Network policy-/// The connection the sync engine is working over. Whether cellular data may-/// be spent is the system's call: iOS Settings carries the per-app Cellular-/// Data switch, and a request it forbids fails on its own.+/// The connection the sync engine is working over. Notes and other small+/// payloads ride any of them; media waits for `.wifi` while the app's+/// Wi-Fi-only setting holds. Whether the app may touch cellular at all stays+/// the system's call: iOS Settings carries the per-app Cellular Data switch,+/// and a request it forbids fails on its own.nonisolated public enum NetworkPath: Equatable, Sendable {case wificase cellulardiff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/MediaModel.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/MediaModel.swiftindex bfd65282..3eea19d3 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/MediaModel.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/MediaModel.swift@@ -19,6 +19,9 @@ nonisolated public struct Recording: Identifiable, Equatable, Sendable {/// Where a clip's bytes live relative to the cloud.nonisolated public enum RecordingSyncState: Equatable, Sendable {case onDevice+ /// On cellular with the Wi-Fi-only setting on: the clip has somewhere to+ /// go and is waiting for the connection to allow it.+ case waitingForWiFicase uploading(percent: Int)case synced}@@ -60,6 +63,9 @@ public final class MediaModel {/// The cloud is out of room; the Library banner reads this.public var storageFull: Bool { sync?.storageFull ?? false }+ /// Clips are waiting for Wi-Fi; the Library banner reads this too.+ public var waitingForWiFi: Bool { sync?.waitingForWiFi ?? false }+public func ingest(movieAt url: URL, duration: TimeInterval, thumbnail: Data?) {guard let recording = try? store.ingest(movieAt: url, duration: duration, thumbnail: thumbnail) else { return }recordings.insert(recording, at: 0)diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/SyncEngine.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/SyncEngine.swiftindex 5af83c46..7074ccd1 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/SyncEngine.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/SyncEngine.swift@@ -4,8 +4,12 @@ import Foundation// inspiration up, notes both ways, deletes replayed — against a journal the// store persists, so nothing depends on the app staying open: whatever was// mid-flight when the app died is picked up from the journal on the next-// kick. Every byte moves at most once, and it moves on whatever connection-// the phone has: iOS Settings owns the per-app cellular switch.+// kick. Every byte moves at most once.+//+// Two weights of traffic ride different connections. Notes, folders, deletes+// and saved links are small, so they move whenever the phone is online.+// Recordings and inspiration media are not, so they wait for Wi-Fi while the+// app's Wi-Fi-only setting holds.nonisolated public struct SyncTombstone: Equatable, Sendable, Identifiable {nonisolated public enum Kind: String, Sendable {@@ -111,6 +115,9 @@ public final class SyncEngine {public var network: NetworkPath = .offline {didSet { if network != oldValue, network != .offline { kick() } }}+ /// The app's setting: media waits for Wi-Fi. Read on every decision, so+ /// flipping the switch takes effect on the next kick.+ private let wiFiOnlyForMedia: () -> Bool/// Live upload progress per recording, layered over the journal.private var uploadStates: [UUID: RecordingSyncState] = [:]@@ -146,11 +153,13 @@ public final class SyncEngine {journal: any SyncJournalStoring,service: any CloudSyncServicing,signedIn: @escaping () -> Bool,+ wiFiOnlyForMedia: @escaping () -> Bool = { true },uploadFor: @escaping (Recording) async -> LibraryUpload?) {self.journal = journalself.service = serviceself.signedIn = signedIn+ self.wiFiOnlyForMedia = wiFiOnlyForMediaself.uploadFor = uploadFor}@@ -164,11 +173,32 @@ public final class SyncEngine {public func state(for recording: Recording) -> RecordingSyncState {if let live = uploadStates[recording.id] { return live }if syncedIds.contains(recording.id) { return .synced }- if checkedIds.contains(recording.id) { return .onDevice }- checkedIds.insert(recording.id)- guard (try? journal.recordingRemote(recording.id))?.assetId != nil else { return .onDevice }- syncedIds.insert(recording.id)- return .synced+ if !checkedIds.contains(recording.id) {+ checkedIds.insert(recording.id)+ if (try? journal.recordingRemote(recording.id))?.assetId != nil {+ syncedIds.insert(recording.id)+ return .synced+ }+ }+ return heldForWiFi ? .waitingForWiFi : .onDevice+ }++ /// The connection is cellular and the setting says media stays off it.+ /// A clip's badge says so, and the Library banner reads the same policy+ /// once there is something actually waiting on it.+ public var heldForWiFi: Bool {+ network == .cellular && wiFiOnlyForMedia()+ }++ /// Media is held back and there is media to hold: what the Library banner+ /// shows.+ public var waitingForWiFi: Bool {+ heldForWiFi && pendingMedia+ }++ /// Whether media may ride the connection the phone has right now.+ private var mediaAllowed: Bool {+ online && !heldForWiFi}/// How often the phone looks at the cloud on its own. Notes are written@@ -234,7 +264,7 @@ public final class SyncEngine {guard online else { return }await syncLibrary()await refreshStorage()- guard !storageFull else { return }+ guard !storageFull, mediaAllowed else { return }await uploadPendingRecordings()await uploadPendingInspirationMedia()}@@ -259,22 +289,14 @@ public final class SyncEngine {}}- /// Anything the journal still owes the cloud after a pass.+ /// Anything the journal still owes the cloud after a pass. Media held+ /// back for Wi-Fi is not queued work: nothing about waiting is retried on+ /// a clock, and the network change that lifts the hold kicks a pass.private var pendingWork: Bool {if !(((try? journal.tombstones()) ?? []).isEmpty) { return true }if notesPending { return true }- if (media?.recordings ?? []).contains(where: {- !unreadable.contains($0.id) && ((try? journal.recordingRemote($0.id))?.assetId) == nil- }) { return true }- return (ideas?.inspiration ?? []).contains { item in- switch item.kind {- case .link:- ((try? journal.isInspirationLinkSynced(item.id)) ?? true) == false- || ((try? journal.inspirationImportJobId(item.id)) ?? nil) != nil- case .media:- ((try? journal.inspirationRemoteAssetId(item.id)) ?? nil) == nil- }- }+ if linksPending { return true }+ return mediaAllowed && pendingMedia}/// Folders and notes the phone still owes the cloud.@@ -283,6 +305,26 @@ public final class SyncEngine {|| !(((try? journal.dirtyNoteFolders()) ?? []).isEmpty)}+ /// Links the cloud has not been handed, or is still fetching.+ private var linksPending: Bool {+ (ideas?.inspiration ?? []).contains { item in+ guard case .link = item.kind else { return false }+ return ((try? journal.isInspirationLinkSynced(item.id)) ?? true) == false+ || ((try? journal.inspirationImportJobId(item.id)) ?? nil) != nil+ }+ }++ /// Bytes the phone still owes the cloud: clips it shot, media it saved.+ private var pendingMedia: Bool {+ if (media?.recordings ?? []).contains(where: {+ !unreadable.contains($0.id) && ((try? journal.recordingRemote($0.id))?.assetId) == nil+ }) { return true }+ return (ideas?.inspiration ?? []).contains { item in+ guard case .media = item.kind else { return false }+ return ((try? journal.inspirationRemoteAssetId(item.id)) ?? nil) == nil+ }+ }+// MARK: Deletesprivate func replayTombstones() async {@@ -489,7 +531,7 @@ public final class SyncEngine {// MARK: Recordings- /// A finished recording heads for the cloud at once (policy permitting).+ /// A finished recording heads for the cloud at once, or waits for Wi-Fi.public func recordingAdded(_ recording: Recording) {unreadable.removeAll()kick()@@ -497,7 +539,7 @@ public final class SyncEngine {private func uploadPendingRecordings() async {for recording in media?.recordings ?? [] {- guard online, !storageFull else { return }+ guard mediaAllowed, !storageFull else { return }let remote = try? journal.recordingRemote(recording.id)guard remote?.assetId == nil,!uploading.contains(recording.id),@@ -636,7 +678,7 @@ public final class SyncEngine {private func uploadPendingInspirationMedia() async {for item in ideas?.inspiration ?? [] {guard case .media(let fileName, let isVideo) = item.kind else { continue }- guard online, !storageFull else { continue }+ guard mediaAllowed, !storageFull else { continue }guard ((try? journal.inspirationRemoteAssetId(item.id)) ?? nil) == nil else { continue }guard let fileURL = ideas?.mediaURL(fileName: fileName),let bytes = fileURL.fileByteCount else { continue }diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/IdeasScreen.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/IdeasScreen.swiftindex 937808fd..df9ef8de 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/IdeasScreen.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/IdeasScreen.swift@@ -27,6 +27,9 @@ struct IdeasScreen: View {var body: some View {NavigationStack(path: $path) {VStack(spacing: 0) {+ if media.waitingForWiFi {+ WiFiBanner()+ }ScreenHeader(title: "Ideas", app: app, auth: auth)ScrollView {VStack(alignment: .leading, spacing: 18) {diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/MediaScreen.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/MediaScreen.swiftindex 56a81b04..fa4219af 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/MediaScreen.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/MediaScreen.swift@@ -22,6 +22,8 @@ struct MediaScreen: View {VStack(spacing: 0) {if media.storageFull {StorageBanner()+ } else if media.waitingForWiFi {+ WiFiBanner()}ScreenHeader(title: headerTitle, app: app, auth: auth) {if selecting {@@ -199,6 +201,20 @@ struct StorageBanner: View {}}+/// Cellular, with videos set to Wi-Fi only: the clips are on the phone and+/// go up as soon as it joins a network.+struct WiFiBanner: View {+ var body: some View {+ Label("On cellular — videos upload on Wi-Fi", systemImage: "wifi")+ .font(.footnote.weight(.semibold))+ .foregroundStyle(.white)+ .frame(maxWidth: .infinity)+ .padding(.horizontal, 20)+ .padding(.vertical, 8)+ .background(Color(hex: "#3c4043").ignoresSafeArea(edges: [.top, .horizontal]))+ }+}+struct RecordingCard: View {let recording: Recordingvar media: MediaModel@@ -245,22 +261,32 @@ struct RecordingCard: View {}}-/// Shown on a card only while its bytes are on their way up, in the same-/// white-on-scrim overlay the duration reads in. A clip that is settled —-/// on the phone or in the cloud — carries no badge.+/// Shown on a card while its bytes are on their way up, or while they are+/// waiting for Wi-Fi, in the same white-on-scrim overlay the duration reads+/// in. A clip that is settled — on the phone or in the cloud — carries no+/// badge.struct SyncBadge: View {let state: RecordingSyncStatevar body: some View {- if case .uploading = state {- Text("Syncing")- .font(.caption2.weight(.bold))- .foregroundStyle(.white)- .padding(.horizontal, 8)- .padding(.vertical, 3)- .background(.black.opacity(0.65), in: RoundedRectangle(cornerRadius: 8))+ switch state {+ case .uploading:+ scrim { Text("Syncing") }+ case .waitingForWiFi:+ scrim { Label("Wi-Fi", systemImage: "wifi") }+ case .onDevice, .synced:+ EmptyView()}}++ private func scrim(@ViewBuilder _ content: () -> some View) -> some View {+ content()+ .font(.caption2.weight(.bold))+ .foregroundStyle(.white)+ .padding(.horizontal, 8)+ .padding(.vertical, 3)+ .background(.black.opacity(0.65), in: RoundedRectangle(cornerRadius: 8))+ }}struct RecordingPlayerView: View {diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/RootView.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/RootView.swiftindex 1d4d0309..e9e5b7b6 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/RootView.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/RootView.swift@@ -1,4 +1,5 @@#if os(iOS)+import Combineimport SwiftUIimport DonkeyKitModels@@ -86,9 +87,20 @@ public struct RootView<CameraPreview: View>: View {await projects.refresh()}.onChange(of: scenePhase) { _, phase in- if phase == .active, auth.isSignedIn {- media.sync?.kick()- }+ guard phase == .active else { return }+ // The Wi-Fi switch is also on the app's page in iOS Settings,+ // where it may have been flipped while this app was away.+ app.refreshFromDefaults()+ if auth.isSignedIn { media.sync?.kick() }+ }+ // Both apps on screen at once — iPad Split View — so the switch lands+ // without waiting for a trip to the background.+ .onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in+ app.refreshFromDefaults()+ }+ // Letting media onto cellular is a change the queue acts on at once.+ .onChange(of: app.mediaOnWiFiOnly) { _, _ in+ media.sync?.kick()}.onChange(of: auth.isSignedIn) { _, signedIn inguard signedIn else {diff --git a/apps/ios/DonkeyKit/Tests/DonkeyKitModelsTests/DonkeyKitModelsTests.swift b/apps/ios/DonkeyKit/Tests/DonkeyKitModelsTests/DonkeyKitModelsTests.swiftindex 1b38a233..a695a75c 100644--- a/apps/ios/DonkeyKit/Tests/DonkeyKitModelsTests/DonkeyKitModelsTests.swift+++ b/apps/ios/DonkeyKit/Tests/DonkeyKitModelsTests/DonkeyKitModelsTests.swift@@ -325,7 +325,7 @@ import Testinglet engine: SyncEngine}- func makeRig() throws -> Rig {+ func makeRig(wiFiOnlyForMedia: Bool = true) throws -> Rig {let store = try DonkeyStore(inMemory: true)let cloud = FakeCloud()let ideas = IdeasModel(store: store)@@ -334,6 +334,7 @@ import Testingjournal: store,service: cloud,signedIn: { true },+ wiFiOnlyForMedia: { wiFiOnlyForMedia },uploadFor: { recording inLibraryUpload(fileURL: media.movieURL(for: recording),@@ -658,18 +659,52 @@ import Testing#expect(try rig.store.tombstones().isEmpty)}- @Test func cellularMovesEverything() async throws {- // iOS Settings owns the cellular switch, so the engine treats a- // cellular path like any other connection.+ @Test func cellularCarriesNotesAndHoldsVideos() async throws {+ // The default: notes are small enough to spend cellular data on, a+ // clip is not. The clip says so on its card and moves on Wi-Fi.let rig = try makeRig()rig.engine.network = .cellularlet recording = try ingestClip(rig)+ rig.ideas.addInspiration(mediaData: Data(repeating: 3, count: 64), isVideo: true)rig.ideas.openEditor()rig.ideas.draft?.body = "typed on the train"let note = rig.ideas.saveDraft()!await rig.engine.run()- #expect(rig.cloud.uploads == [recording.fileName])+ #expect(rig.cloud.uploads.isEmpty)#expect(rig.cloud.notes[note.id] != nil)+ #expect(rig.engine.state(for: recording) == .waitingForWiFi)+ #expect(rig.engine.waitingForWiFi)++ rig.engine.network = .wifi+ await rig.engine.run()+ #expect(rig.cloud.uploads.count == 2)+ #expect(rig.engine.state(for: recording) == .synced)+ #expect(!rig.engine.waitingForWiFi)+ }++ @Test func cellularMovesVideosWhenTheSettingIsOff() async throws {+ let rig = try makeRig(wiFiOnlyForMedia: false)+ rig.engine.network = .cellular+ let recording = try ingestClip(rig)+ await rig.engine.run()+ #expect(rig.cloud.uploads == [recording.fileName])+ #expect(rig.engine.state(for: recording) == .synced)+ #expect(!rig.engine.waitingForWiFi)+ }++ @Test func cellularStillReplaysDeletesAndLinks() async throws {+ // Everything light keeps moving while media waits: a delete made here+ // reaches the cloud, and a saved link is handed to the worker.+ let rig = try makeRig()+ let recording = try ingestClip(rig)+ await rig.engine.run()+ let assetId = try #require(try rig.store.recordingRemote(recording.id).assetId)+ rig.engine.network = .cellular+ rig.media.delete(recording)+ #expect(rig.ideas.addInspiration(urlText: "https://example.com/clip"))+ await rig.engine.run()+ #expect(rig.cloud.deletedAssets == [assetId])+ #expect(rig.cloud.links.count == 1)}@Test func inspirationMediaUploadsOnce() async throws {@@ -696,6 +731,38 @@ import Testing}}+@Suite struct AppSettingsTests {+ /// A defaults suite of this test's own, thrown away after.+ func makeDefaults() -> UserDefaults {+ let name = "settings-test-\(UUID().uuidString)"+ let defaults = UserDefaults(suiteName: name)!+ defaults.removePersistentDomain(forName: name)+ return defaults+ }++ @Test func videosWaitForWiFiOutOfTheBox() {+ #expect(AppModel(defaults: makeDefaults()).mediaOnWiFiOnly)+ }++ @Test func theSwitchSurvivesALaunch() {+ let defaults = makeDefaults()+ AppModel(defaults: defaults).mediaOnWiFiOnly = false+ #expect(!AppModel(defaults: defaults).mediaOnWiFiOnly)+ }++ @Test func theSettingsAppsWordIsTaken() {+ // What the app's page in iOS Settings writes, under the same key.+ let defaults = makeDefaults()+ let app = AppModel(defaults: defaults)+ defaults.set(false, forKey: "mediaOnWiFiOnly")+ app.refreshFromDefaults()+ #expect(!app.mediaOnWiFiOnly)+ defaults.set(true, forKey: "mediaOnWiFiOnly")+ app.refreshFromDefaults()+ #expect(app.mediaOnWiFiOnly)+ }+}+@Suite struct FileURLTests {/// The app's own container sits under "Application Support", so a path/// with a space in it is the normal case, not the edge one.diff --git a/docs/guides/ios-app.md b/docs/guides/ios-app.mdindex 8ddc8bd1..3a942dd4 100644--- a/docs/guides/ios-app.md+++ b/docs/guides/ios-app.md@@ -14,10 +14,19 @@ kept in the app's SwiftData store, so nothing depends on the app staying open— whatever was mid-flight when the app died is picked up on the next launch,foreground, network change, or edit.-**The one rule on data:** a transfer moves whenever the phone is online. Who-gets to spend cellular data is the system's call — iOS Settings carries the-per-app Cellular Data switch, and a request it forbids fails on its own — so-the app keeps no network preference of its own.+**The one rule on data:** traffic comes in two weights. Notes, folders,+deletes and saved links are small, so they move whenever the phone is online.+Recordings and inspiration media are not, so they ride Wi-Fi. *Videos on Wi-Fi+Only*, on out of the box, is the app's one switch on the matter, and it lives+where the system's own data controls do: the app's page in iOS Settings, from+a Settings bundle that writes the `mediaOnWiFiOnly` default the sync engine+reads. The app takes whatever that key says as it comes forward. While the+switch holds on a cellular connection the clips stay on the phone, each card+says Wi-Fi and the Library and Ideas screens carry a slim banner, and the queue+drains the moment the phone joins a network. Turn it off and media moves on+whatever connection there is. Whether the app may touch cellular at all stays+the system's call: iOS Settings carries the per-app Cellular Data switch, and a+request it forbids fails on its own.Every byte moves at most once. Uploads go straight to storage on presignedURLs; an interrupted upload re-presigns under the name it already claimed, and