Offline-First PWA
Aura keeps working when the network doesn’t. Two mechanisms cooperate
(public/sw.js + src/lib/offline-sync.ts):
Service Worker caching
The Service Worker caches the application shell and static assets, so the workspace loads and runs fully offline.
IndexedDB mutation queue
Writes that would normally hit Firestore are enqueued while offline:
src/lib/offline-sync.ts
export interface PendingMutation {
// collection, operation, payload …
attempts: number // number of sync attempts
// createdAt, lastAttempt timestamps
}
export type SyncStatus = 'idle' | 'syncing' | 'error' | 'offline'
export async function enqueueMutation(m: Omit<PendingMutation, 'id' | 'createdAt' | 'attempts'>): Promise<string>When connectivity returns, background sync drains the queue, emitting SyncEvents
(sync-start, sync-complete, sync-error, mutation-queued, online, offline) that the UI
surfaces as a sync status indicator.
Division of labor
| Data | Offline strategy |
|---|---|
| App shell & assets | Service Worker cache |
| Project CRDT state | y-indexeddb — merges on reconnect |
| Firestore documents | IndexedDB mutation queue + background sync |
| Task state | IndexedDB task persistence (src/lib/task-persistence.ts) |