Collaborative Grids Architecture

The Collaborative Grids feature is built on top of CloudKit and Apple's CloudKit Sharing UI. This ensures secure, authenticated, and reliable synchronization across devices.

Network Architecture

Unlike local peer-to-peer solutions, Control It uses a cloud-first approach:

Sync Synchronization

Changes are propagated using CloudKit Subscriptions:

  1. Push: When you make a change, the app uploads the modified `CKRecord`.
  2. Notification: CloudKit sends a silent push notification to all other participants.
  3. Pull: Devices receive the notification and fetch the latest changes in the background.

Conflict Resolution

The system employs a Last Writer Wins (LWW) strategy for conflict resolution.

Scenario

User A and User B edit the same button simultaneously. User A saves first. User B saves milliseconds later.

Outcome

User B's save operation will trigger a "Server Record Changed" error. The app automatically fetches the latest server version (User A's change), re-applies User B's changes on top, and attempts to save again. If the fields overlap, User B's value will persist.

Permissions & Roles

Permissions are managed via the standard CloudKit Share options:

Permission Level Capabilities
Owner Full access. Can add/remove users, stop sharing, and delete the grid.
Can Make Changes Can edit, add, or remove actions. Can invite others if allowed by Owner.
View Only Can use the grid (trigger actions) but cannot modify the layout or settings.

Requirement

iCloud Required: All participants must be signed into iCloud with iCloud Drive enabled to join and sync shared grids.