Skip to content

refactor: unify preload rpc and renderer service types - #181

Merged
h4yfans merged 4 commits into
mainfrom
memry/rpc-and-type-unification
Apr 8, 2026
Merged

refactor: unify preload rpc and renderer service types#181
h4yfans merged 4 commits into
mainfrom
memry/rpc-and-type-unification

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

What

Unify desktop RPC ownership by introducing a dedicated @memry/rpc package, generating the preload RPC bridge from that catalog, and switching the renderer tasks/notes/inbox services over to canonical RPC and contract types.

Why

The preload layer, contracts, and renderer services were each maintaining overlapping transport and DTO definitions. This phase reduces duplication, makes the IPC boundary explicit in one place, and prepares the architecture reset work to build on generated RPC bindings instead of hand-maintained wrappers.

How

  • Added packages/rpc as the transport catalog for notes, tasks, inbox, and settings domains.
  • Added a generator that emits apps/desktop/src/preload/generated-rpc.ts from the RPC catalog and wired desktop IPC generate/check scripts through it.
  • Replaced the handwritten preload notes/tasks/inbox/settings RPC sections with the generated bridge while preserving existing behavior for special cases like attachment upload serialization, wrapped note position/import payloads, startup theme normalization, and positional inbox suggestion tracking.
  • Updated preload typings so window.api extends the generated RPC surface instead of redeclaring those domains/events separately.
  • Simplified renderer tasks/notes/inbox services into thin wrappers over window.api backed by canonical @memry/rpc / @memry/contracts types.
  • Added/updated tests for the generated RPC bridge and aligned renderer service test fixtures with the new API shape.

Type

  • refactor — restructure without behavior change
  • feat — new feature
  • fix — bug fix
  • style — visual/UI only
  • perf — performance improvement
  • test — adding or updating tests
  • chore — tooling, deps, config
  • docs — documentation only
  • ci — CI/CD changes

Test plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing (describe below)

Manual checks run:

  • node --experimental-strip-types --experimental-transform-types --input-type=module -e "...import generated-rpc.ts and the rewritten service modules..."
  • node --experimental-strip-types --experimental-transform-types --input-type=module - <<'NODE' ... createGeneratedRpcApi smoke checks for uploadAttachment/deleteAttachment/getPositions/importFiles/trackSuggestion/getStartupThemeSync ... NODE
  • node --experimental-strip-types --experimental-transform-types --input-type=module - <<'NODE' ... renderer service smoke checks with mocked window.api ... NODE
  • git diff --check

Blocked:

  • pnpm-based verification is not runnable in this worktree because node_modules is missing; the earlier attempt failed before tests with Cannot find module 'better-sqlite3/package.json'.

Checklist

  • Self-reviewed the diff
  • No hardcoded secrets or credentials
  • Files stay under ~500 LOC
  • Follows immutable data patterns

@h4yfans
h4yfans marked this pull request as ready for review April 8, 2026 22:15
@h4yfans
h4yfans merged commit 22aa2b5 into main Apr 8, 2026
@h4yfans
h4yfans deleted the memry/rpc-and-type-unification branch May 6, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant