refactor: centralize sync dispatch via adapter registry (Phase 5) - #188
Merged
Conversation
Centralize all domain sync dispatch behind enqueueLocalSyncCreate/Update/Delete. Each domain type registers a local sync adapter with online/offline fallback, replacing scattered direct sync service calls across runtime-effects modules.
…istry Replace direct sync service calls and offline clock fallbacks in all runtime-effects modules, vault watcher, filing, and IPC handlers with unified enqueueLocalSyncCreate/Update/Delete calls. Removes db parameter from sync effect function signatures.
…g in inbox handlers Revert premature domain extraction: inline capture logic back into IPC handlers with fixes from review. Add insertItemWithTags transactional helper, normalizeBinaryInput shared buffer helper, CaptureVoiceSchema validation at IPC boundary, and withErrorHandler on convertToNote/ convertToTask/linkToNote. Update test mocks for transaction support.
Re-add has, ownKeys, and getOwnPropertyDescriptor traps removed during prior simplification. Without these, 'in' operator, Object.keys(), and JSON.stringify return incorrect results. Restore deleted test file.
…ty-array refs Restore void on tasksService.reorder() and setProjects in handleDragEnd deps removed during prior refactor. Add module-level EMPTY_TASKS/ EMPTY_PROJECTS constants in useTaskWorkspaceData to prevent unstable array references triggering unnecessary TasksProvider re-renders.
Add blocked-pattern rules for direct IPC sync-module imports. Mark Phase 5 sync adapter gate items complete, revert premature Phase 3 checkmarks.
…re-phase-5 # Conflicts: # CHANGELOG.md # apps/desktop/src/main/ipc/generated-ipc-invoke-map.ts # apps/desktop/src/main/ipc/inbox-handlers.ts # apps/desktop/src/main/vault/watcher.ts # apps/desktop/src/renderer/src/services/window-api-forwarder.test.ts
Restore our branch's config deletions that the merge with origin/main re-added. Removes @memry/domain-inbox package files and all references from vitest, vite, package.json, and tsconfig files.
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.
What
Centralize all domain sync dispatch behind a local-mutations adapter registry, replacing scattered direct sync service calls across 12+ runtime-effects modules.
Why
Phase 5 of the architecture reset plan: make sync adapter-driven instead of feature-driven. Direct
getTaskSyncService()/getInboxSyncService()calls were scattered across every runtime-effects module, each with duplicated online/offline fallback logic. This also reverts the premature@memry/domain-inboxextraction from Phase 3 — the domain boundary wasn't ready, and the extraction dropped transaction atomicity, Zod validation, and error handling at the IPC trust boundary.How
local-mutations.ts: Adapter registry usingcreateSyncAdapterRegistryfrom@memry/sync-core. Each domain type registers a local sync adapter withenqueueCreate/Update/Deletethat handles online service dispatch with offline clock fallback.enqueueLocalSyncCreate/Update/Deleteinstead of direct sync services. Removesdbparameter from sync effect signatures.insertItemWithTagstransactional helper, addednormalizeBinaryInputshared buffer helper, addedCaptureVoiceSchemaZod validation, wrappedconvertToNote/convertToTask/linkToNotewithwithErrorHandler.enqueueLocalSyncCreatebehind snapshot existence check in rename/merge to prevent orphan sync entries.has/ownKeys/getOwnPropertyDescriptortraps removed in prior simplification.voidprefix on floating promise,setProjectsin deps array, stable empty-array refs preventing unnecessary re-renders.Type
feat— new featurefix— bug fixrefactor— restructure without behavior changestyle— visual/UI onlyperf— performance improvementtest— adding or updating testschore— tooling, deps, configdocs— documentation onlyci— CI/CD changesTest plan
local-mutations.test.tscovers adapter routing, offline fallbacks, note sync removal, and settings field update.window-api-forwarder.test.tsrestored with 6 tests for proxy trap behavior.inbox-handlers.test.tsupdated with transaction mock support. Full suite: 254 files, 5521 tests pass.pnpm typecheck,pnpm lint(0 errors),pnpm ipc:checkall green.Checklist