Time Extension

Status: ready

Intent

A timed task warns the user, lets them extend, and keeps their progress where policy allows.

Problem

The assistive path takes longer, and the app expires the session, clears the form or invalidates the code with no way back.

Solution

Verdict: a warning at least 2 minutes before expiry with "Stay signed in", saved draft fields, and a message after expiry that says what was kept. For secure flows, design the recovery with security instead of treating the timeout as untouchable.

Why: the warning gives the slower path the time it needs. A saved draft means a timeout costs one login, not the whole form.

Implementation

Warning with real buttons:

VStack(alignment: .leading, spacing: 12) {
    Text("Your session ends in 2 minutes.")
    Button("Stay signed in") { extendSession() }
    Button("Save and sign out") { saveDraftAndSignOut() }
}
.accessibilityElement(children: .contain)
.onAppear {
    AccessibilityNotification.Announcement("Your session ends in 2 minutes.").post()
}

If the user is in the middle of typing, the announcement is enough. Focus moves to the warning only at the last threshold, when not acting means losing work.

Draft fields after a timeout:

func handleTimeout() {
    draftStore.save(form.nonSensitiveFields)
    showLogin(message: "You were signed out. Your form is saved.")
}

Never card numbers, passwords or one-time codes.

Expired one-time code, with the next step right there:

Text("Code expired.")
Button("Send a new code") { resendCode() }

After resend, focus goes to the code field.

A countdown is a value, updated at thresholds, not every second:

Text("Session ends in \(minutesLeft) min")
    .accessibilityValue("\(minutesLeft) minutes left")

Check

Profile:   VoiceOver
Task:      fill the long form slowly until the warning
Expected:  the warning is announced
           "Stay signed in" is reachable and works
           no field is cleared
Profile:   Switch Control
Task:      let a one-time code expire
Expected:  "Send a new code" is reachable right after the message
           focus moves to the code field after resend
Profile:   security review
Task:      timeout recovery
Expected:  saved fields are listed and allowed by policy
           the message says what was cleared

Pitfalls

  1. Extending a sensitive session silently, without security's agreement. Re-authenticate instead.
  2. A warning in a modal that steals focus from a field mid-typing.
  3. Clearing a draft that policy allows to keep.
  4. Announcing the countdown every second.
  5. "Stay signed in" as a small secondary link.

WCAG mapping

  1. 2.2.1 Timing Adjustable: the user can extend a time limit.
  2. 2.2.6 Timeouts (AAA): the user is warned about data loss.
  3. 3.3.4 Error Prevention: important input can be recovered.
  1. Timeout Pressure
  2. Announcement Spam
  1. Chapter 7
  2. Chapter 9
  3. Chapter 13
  4. Chapter 18

Sources

  1. W3C: Understanding SC 2.2.1 Timing Adjustable
  2. W3C: Understanding SC 2.2.6 Timeouts
  3. Apple Developer: AccessibilityNotification