1. Describe the transition, not just the final screen
“The toggle is broken” leaves too much open. A useful reproduction says: open item A, enable its flag, navigate back, sort the list, reopen A, and observe that B now appears enabled. Record the item identifiers and expected values at each step. Repeat once without sorting to separate identity problems from persistence problems.
For a value that resets, specify the boundary: a parent refresh, navigation, sheet dismissal, backgrounding or a full relaunch. These are different lifetimes. The first task for ChatGPT is to map the relevant files and events, not to rewrite the screen.
2. Draw a small ownership map
Apple’s SwiftUI explanation connects identity, lifetime and dependencies. [1] Use those concepts to ask concrete questions about this bug. For each affected value, record its owner, readers, writers and intended reset point. Check whether a child keeps a separate editable copy when the interface expects a shared value.
| Value | Question to answer |
|---|---|
| Item identifier | Does it stay stable through sorting and reloads? |
| Favorite flag | Which model is authoritative for both screens? |
| Editor draft | When should a local copy commit or be discarded? |
| Loaded result | Can an older asynchronous result overwrite newer state? |
3. Test identity and ownership separately
Here is an illustrative identity trap. A computed identifier that creates a new UUID on access cannot provide a stable identity for the same logical item:
// Illustrative model fragment — unstable identity
var id: UUID { UUID() }
// A stored ID is stable for this instance
let id: UUIDThe stored form is not a complete persistence design. If you rebuild every item with a new identifier after loading, the logical record still loses continuity. Use the identity already defined by your data model and check how it survives refreshes.
For ownership, read the existing observation architecture before changing wrappers. Apple documents State as a source of truth managed by SwiftUI. [2] That does not mean every model or child input should become its own @State.
4. Give Pro a hypothesis-driven debugging task
Ask for two or three plausible causes and a distinguishing observation for each. Use targeted logs or debugger observations for identity, writes and event order. Avoid logging private record contents when identifiers and timestamps are sufficient. A useful result explains why the failure occurs at a particular transition.
Investigate this SwiftUI state bug before editing. Expected/actual: [difference]. Reproduction: [ordered steps]. Affected records and reset boundary: [details]. Map owners, readers, writers and stable identities. Rank plausible causes and give an observation that confirms or rejects each. Preserve the existing observation architecture unless evidence requires a change. Verify the original sequence and one counterexample.
5. Replay the original path and a counterexample
Repeat the exact failing sequence after the repair. Then test a nearby path that could expose an overcorrection: sort differently, cancel the editor, leave and return, or deliver responses out of order where your test setup supports it. For persistence requirements, include relaunch rather than merely redrawing the view.
Remove temporary diagnostic output and inspect the final diff. A successful repair should explain both the old failure and the new behavior. If the bug is intermittent and has not been reproduced after the change, describe the observations and remaining uncertainty instead of claiming proof from one quiet run.
Common questions
Can I fix a stale view by adding a changing .id()?
It may force a new identity and hide the symptom while resetting local state. First explain why the expected dependency did not update the view.
Is every reset a persistence bug?
No. A reset during navigation can involve ownership or identity before storage is involved. Test the specific lifetime boundary where it happens.
Sources and next steps
Technical references below were checked on October 9, 2026. The diagnostic sequence, prompts and acceptance criteria are Relayard editorial guidance. Scenarios illustrate a method; they are not reported project test results. Available tools depend on the actual client and setup.