feat: offline mode with client-side queue and sync (#138)#154
Merged
feat: offline mode with client-side queue and sync (#138)#154
Conversation
Add getOldestCacheAge() to core cache module, surface it through the page server component, and render CacheAge in the List top bar.
- Fix IDB connection leak: add tx.onerror/tx.onabort handlers - Fix tryOrQueue: wrap all enqueue() calls in try-catch so IDB failures surface as errors instead of silently losing operations - Fix sync replay: wrap state transitions in try-catch so IDB errors don't orphan operations in "syncing" ghost state - Fix useSyncOnReconnect: use callbacksRef to prevent event listener churn, add catch around replayQueue, replace empty catches with console.warn, remove dead onSyncSuccess callback - Fix useOfflineAware: replace empty catch with console.warn - Fix OfflineIndicator: remove dead early-return that hid failure state, wire FailureModal for retry/discard of failed operations, add error handling to handleCancel - Fix FailureModal: add catch in handleRetry - Fix CommentComposer: pass idempotency nonce to addComment - Fix LabelManager: add try-catch around tryOrQueue in startTransition
# Conflicts: # packages/web/app/page.tsx # packages/web/components/list/List.tsx
E2E test DBs use schema v4 which lacks the fetched_at column on the cache table. getOldestCacheAge now catches the SQLite error and returns null gracefully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New files (16)
lib/offline-queue.ts— IndexedDB queue with enqueue/replay/cancellib/tryOrQueue.ts— server action wrapper intercepting network failureslib/sync.ts— replay logic with health checkhooks/useOfflineAware.ts— offline state + action tier lookuphooks/useSyncOnReconnect.ts— sync trigger on online eventcomponents/ui/CacheAge.tsx— relative time badgecomponents/ui/QueueDropdown.tsx— banner dropdown listing pending opscomponents/ui/FailureModal.tsx— retry/discard for failed operationsapp/api/health/route.ts— lightweight connectivity probeModified files (8)
OfflineIndicator.tsx— queue count, responsive text, FailureModal wiringAssignSheet.tsx,CommentComposer.tsx,LabelManager.tsx— wrapped with tryOrQueueIssueActionSheet.tsx— close/reassign disabled when offlinelayout.tsx— OfflineIndicator moved inside ToastProviderpage.tsx+List.tsx— CacheAge badge in dashboard headercore/db/cache.ts— getOldestCacheAge helperTest plan
pnpm turbo typecheck— all 4 tasks pass, 0 errorspnpm turbo test— 424 tests pass (347 core + 77 web)/api/healthreturns{ ok: true }Closes #138