A small draft editing screen saves a local backup copy to file storage and shows the outcome through statusText. After a recent PR, the behavior diverged from the requirements: the UI sometimes reports success too early, and some write errors no longer reach the user.
DraftBackupStore.save(_:) must complete only after the data has actually been written.DraftEditorModel.saveBackup() must show a clear status with the prefix Save failed:.Saved is allowed only after saving has really completed successfully.statusText must happen on MainActor.saveBackup().saveBackup(), check statusText.shouldFailWrite = true and call saveBackup() again.title contains an invalid value "" if your validation treats this as a domain validation error before writing.let okStore = DraftBackupStore(fileClient: FileClient())
let okModel = DraftEditorModel(store: okStore)
okModel.title = "Plan"
await okModel.saveBackup()
let badStore = DraftBackupStore(fileClient: FileClient(shouldFailWrite: true))
let badModel = DraftEditorModel(store: badStore)
badModel.title = "Plan"
await badModel.saveBackup()
await saveBackup(), the successful scenario leaves statusText == "Saved" only if the write really finished without error.statusText as Save failed: ....Swift 6SwiftUI-compatible model, but the exercise is limited to model and store codeDraftEditorModel is marked @MainActorFileClientFileClient.write(_:to:) is async throws; write failure is modeled via shouldFailWriteUse line comments to explain the problem, its impact, the fix and how to test it.