home / skills / harborgrid-justin / lexiflow-premium / pwa-offline-sync-manager
/frontend/.github-skills/pwa-offline-sync-manager
This skill helps implement offline mutation queuing with Background Sync to replay mutations when connectivity returns, ensuring reliable offline-to-online
npx playbooks add skill harborgrid-justin/lexiflow-premium --skill pwa-offline-sync-managerReview the files below or copy the command above to add this skill to your agents.
---
name: pwa-offline-sync-manager
description: Implement Background Sync API to queue and replay mutations when connectivity is restored.
---
# PWA Offline Sync Manager
## Summary
Implement Background Sync API to queue and replay mutations when connectivity is restored.
## Key Capabilities
- Intercept failed requests.
- Queue mutations in IndexedDB.
- Replay on connection restoral.
## PhD-Level Challenges
- Handle conflict resolution.
- Manage persistent queue order.
- Provide user feedback.
## Acceptance Criteria
- Queue a mutation offline.
- Sync automatically when online.
- Handle a conflict scenario.
This skill implements a PWA Offline Sync Manager that uses the Background Sync API to queue failed mutations and replay them when connectivity is restored. It is designed for apps that must reliably submit legal-management changes from unreliable networks. The skill focuses on queuing, ordering, replay, and conflict handling to ensure data integrity and user transparency.
The service worker intercepts outbound mutation requests and, when a request fails due to network loss, stores a mutation record in IndexedDB with metadata and a deterministic order key. When the Background Sync event fires or connectivity is detected, the manager replays queued mutations in order, applies optimistic UI updates or rollback on conflict, and emits events for user-facing feedback. Conflict resolution hooks let the app decide merge or manual review.
What happens if Background Sync is not supported by the browser?
The skill falls back to connectivity detection and scheduled retries from the service worker or page code; you should provide a fallback polling strategy and manual retry UI.
How are conflicts detected and resolved?
Conflicts are detected by server responses during replay; the manager exposes hooks for merge logic, automatic resolution policies, or enqueuing the mutation for user review.