Skip to content

Add typed Electron IPC channel registry#617

Open
kilbot wants to merge 1 commit into
nextfrom
feat/ipc-channel-registry
Open

Add typed Electron IPC channel registry#617
kilbot wants to merge 1 commit into
nextfrom
feat/ipc-channel-registry

Conversation

@kilbot

@kilbot kilbot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a pure @wcpos/printer/ipc-channels registry for Stage 1 Electron IPC channel names and request/response types.
  • Retypes the printer Electron renderer adapters/hooks against TypedIpcRenderer so wrong Stage 1 channel names or payload shapes fail at compile time.
  • Updates the Electron submodule pointer to the companion branch that derives preload allowlists and Stage 1 main handlers from the registry.
  • Removes the dead rxStorage invoke channel from the typed/preload invoke set while preserving the dynamic RxDB channel prefix path.

Design decisions (preserve through rebases)

  • Option A registry import — the registry is authored as .cts so preload can import runtime constants from @wcpos/printer/ipc-channels under the existing plain ts-node preload test.
  • Legacy TS resolution shim — packages/printer/ipc-channels.d.ts keeps Node10-style TypeScript resolution working for packages that import the new subpath directly.
  • No runtime channel renames — existing string literals are centralized byte-for-byte; Stage 1 migration covers print/discovery only.
  • rxStorage removed intentionally — the live RxDB bridge uses dynamic rxdb-ipc-renderer-storage|<key> channels, and the only rxStorage handler is in an uncompiled .bak file.

Companion PRs / cross-repo

Test plan

  • Run pnpm --filter @wcpos/app-electron ts:check from this monorepo worktree.
  • Run pnpm --filter @wcpos/app-electron lint and confirm there are 0 errors (warnings are pre-existing require/no-unused warnings).
  • Run pnpm --filter @wcpos/app-electron test.
  • Run targeted Electron scripts: test:preload, test:printer-discovery, test:serial-printer, test:winspool-printer.
  • Run pnpm --filter @wcpos/printer exec tsc --noEmit -p tsconfig.json.
  • Run pnpm --filter @wcpos/printer exec vitest run.
  • Negative type-safety proof: temporarily change a renderer call to a bad channel (for example print-raw-usbZZ), confirm printer tsc --noEmit fails, then revert before merging.

Known blockers

  • Merge the companion Electron PR before or together with this PR so the submodule pointer resolves cleanly.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@kilbot, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 52 minutes and 2 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ac203203-fe65-449e-8c0c-fd05184b93c9

📥 Commits

Reviewing files that changed from the base of the PR and between e7fc7a1 and 572d844.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • apps/electron
  • packages/printer/ipc-channels.d.ts
  • packages/printer/package.json
  • packages/printer/src/hooks/print-from-url.electron.ts
  • packages/printer/src/hooks/use-printer-discovery.electron.ts
  • packages/printer/src/ipc/channels.cts
  • packages/printer/src/transport/network-adapter.electron.ts
  • packages/printer/src/transport/serial-adapter.electron.ts
  • packages/printer/src/transport/system-print-adapter.electron.ts
  • packages/printer/src/transport/usb-adapter.electron.ts
  • tsconfig.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ipc-channel-registry

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

📊 Test Coverage Report

Package Statements Branches Functions Lines
@wcpos/core 🔴 23.1% 🔴 26.9% 🔴 22.3% 🔴 22.6%
@wcpos/components 🔴 24.6% 🔴 27.3% 🔴 16.8% 🔴 24.3%
@wcpos/database 🟡 60.2% 🔴 55.0% 🟡 62.7% 🔴 59.7%
@wcpos/hooks 🔴 52.4% 🔴 50.1% 🔴 45.0% 🔴 52.4%
@wcpos/utils 🔴 55.9% 🟡 61.5% 🟡 71.4% 🔴 53.8%
@wcpos/query 🟢 83.9% 🟡 76.9% 🟡 77.7% 🟢 84.0%
Average 🔴 50.0% 🔴 49.6% 🔴 49.3% 🔴 49.5%
Coverage Legend
  • 🟢 Good (≥80%)
  • 🟡 Moderate (60-79%)
  • 🔴 Needs improvement (<60%)
  • ⚪ No coverage data
--- 🤖 Updated by GitHub Actions • [View full report](https://github.com/wcpos/monorepo/actions/runs/27711204961)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 572d844a1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +32 to +35
export interface AuthPromptParams {
authUrl: string;
redirectUri: string;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add state to the auth prompt request type

The existing Electron auth caller sends state in the auth:prompt payload for CSRF validation (packages/core/src/hooks/use-wcpos-auth/index.electron.ts:72-75), but this new source-of-truth request type only permits authUrl and redirectUri. When the registry is used to type this channel, the current payload is rejected by excess-property checks or typed code is forced to omit state, which can break auth flows that rely on main-process state validation.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Summary

Item Status
Preview URL https://wcpos--ohwqmk5vv3.expo.app
E2E Tests ✅ Passed
Commit 20f7c19

🔗 Quick Links


🤖 Updated by GitHub Actions

@kilbot kilbot changed the base branch from main to next June 17, 2026 22:05
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