import { IMPOSSIBLE, VersionInfo } from '@start9labs/start-sdk'

/**
 * v1.2.0:2 — Login/signup first-tap retry on Safari (2026-06-15).
 *
 * Fixes a long-standing "first Sign In fails with 'An unexpected error
 * occurred', second works" report from iOS Safari. The error string is
 * the client-side catch in LoginForm/SignupForm — i.e. the server-action
 * POST itself rejected at the transport layer, not any login-logic path
 * (those return a clean { error }). Cause: iOS Safari reuses a keep-alive
 * socket the server closed while the form sat idle during typing, so the
 * first POST dies instantly with NSURLErrorNetworkConnectionLost ("The
 * network connection was lost"); a retry lands on a fresh connection.
 *
 * Fix is client-only: a shared retryOnTransportError() helper retries the
 * action ONCE when the call throws (a returned { error } is a real result
 * and passes straight through). A stale-socket POST never reached the
 * server, so the retry is safe.
 *
 * App-code only — no schema, no API contract change, no data migration.
 */
export const v_1_2_0_2 = VersionInfo.of({
  version: '1.2.0:2',
  releaseNotes: {
    en_US:
      'Fixes the occasional "An unexpected error occurred" on the first Sign In / Create account tap (most common in Safari on iPhone/iPad) — the form now retries automatically, so logging in works on the first try. No data changes.',
  },
  migrations: {
    up: async () => {},
    down: IMPOSSIBLE,
  },
})
