Skip to content

Fix shared profile snapshot decoding across app upgrades - #504

Closed
mwd1234 wants to merge 1 commit into
awaseem:mainfrom
mwd1234:codex/fix-shared-profile-snapshots
Closed

mwd1234 wants to merge 1 commit into
awaseem:mainfrom
mwd1234:codex/fix-shared-profile-snapshots

Conversation

@mwd1234

@mwd1234 mwd1234 commented Aug 29, 2026

Copy link
Copy Markdown

Summary

  • Decode shared profile snapshots created before newer profile settings were added.
  • Recover valid snapshots independently when another entry is malformed.
  • Add regression coverage for historical release payloads and mixed valid/invalid collections.

Why

Profile snapshots are stored as JSON in the App Group so widgets and DeviceActivity extensions can resolve profile settings without accessing SwiftData.

ProfileSnapshot gained three non-optional properties after snapshot persistence shipped. Swift's synthesized Decodable does not use property initializers when a key is absent, so snapshots written by older releases fail with keyNotFound.

The current collection decoder converts any entry failure into an empty dictionary. Extensions can then fail to resolve every profile, and a later read-modify-write can replace the derived snapshot map with only the newly written entry. Canonical SwiftData profiles are not deleted.

Compatibility defaults

Missing fields use the same defaults as BlockedProfiles, preserving the behavior users had before each setting was introduced:

  • breakTimeInMinutes: 15
  • enableSafariBlocking: true
  • enableBlockAppInstallation: false

Explicit values in current snapshots remain unchanged.

Tests

  • Decode a v1.24.3-shaped snapshot without any of the three later fields.
  • Decode a v1.25.1-shaped snapshot without Safari or app-install settings.
  • Decode a v1.32.4-shaped snapshot without the app-install setting.
  • Round-trip every field in the current snapshot schema, including explicit non-default values.
  • Keep a valid snapshot when a sibling entry is malformed.
  • Return an empty collection for malformed top-level data.

Scope

This changes only decoding of the derived App Group snapshot data. It does not modify the SwiftData schema or canonical profile records.

Validation

  • make lint (completed; changed files have no format findings)
  • make build
  • make test (53 tests passed)
  • make mac-test (11 tests passed)
  • git diff --check

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T12:01:32.279719Z f418f53 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@awaseem

awaseem commented Sep 12, 2026

Copy link
Copy Markdown
Owner

This seems like AI slop closing

@awaseem awaseem closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants