Skip to content

One IPC channel is declared in six places: generate the two thin clients from a channel table #623

Closed

Description

@currentbits

One IPC channel has to be declared in six places. #622 is what happens when someone declares it in five.

Measured coupling

Every commit touching electron/preload.js since 2026-08-01, and what changed with it:

electron/preload.js       90 commits   (baseline)
electron/ipc.js           86           96%
src/devCoder.ts           70           78%
src/shared/ipc.ts         64           71%
src/wireClient.ts         61           68%
test/support/fakeCoder.ts 52           58%

Six files that change together 58–96% of the time are one concept, not six. The percentages that are not 100% are where the defects live: wireClient.ts and preload.js implement the same CoderApi and co-change only 68% of the time — that 32% is exactly the gap #622 fell into.

Current surface:

handlers in ipc.js              139
bindings in preload.js          137
CoderApi interface (ipc.ts)     894 lines
devCoder.ts                    4618 lines
fakeCoder.ts (140 methods)     1923 lines
wireClient.ts                   562 lines

Every new channel means: a type in ipc.ts, a handler in ipc.js, a binding in preload.js, a call() in wireClient.ts, a fixture in devCoder.ts, a stub in fakeCoder.ts. Five of the six are pure transcription — the same channel name and the same argument, retyped.

What this actually costs

  • Drift that no layer detects. Verify is broken on desktop: threads.setVerifyCommand/runVerify are missing from preload (web and dev have them) #622: verify shipped working in browser dev, working in web mode, and broken in the desktop app for three days. Every layer that had it worked, so nothing failed loudly.
  • A test file that grows one name at a time. ipc-seam.test.js hard-codes spot checks ("preload must expose sourceControl.discover", an explicit createPr/prStatus/prChecks list). Each was added after someone noticed a specific gap.
  • Five-sixths of the transcription is unreviewable. A reviewer cannot tell a correct binding from a missing one by reading the diff; only by reading a different file.

Proposal: one channel table, derive the transcription

A single declarative table — channel name, namespace, method name, arg/return types — from which preload.js and wireClient.ts are generated (or built at runtime by iterating the table). ipc.js keeps the handler bodies, which are the only part with real logic. CoderApi is derived from the table rather than hand-maintained alongside it.

Scope note, deliberately: do not try to generate devCoder.ts or fakeCoder.ts. Those return plausible fixture data, which is real content, not transcription — devCoder.ts's own header says it is "NOT a second implementation" and is allowed to disagree with main. Generating the two thin clients is where the whole defect class lives; the fixtures are a separate, lower-value problem.

Smaller step if the full table is too much at once: keep both clients hand-written but add the reverse seam assertion from #622 (enumerate wireClient.ts's methods, assert each exists on the bridged window.coder). That closes the bug class without a refactor and can ship this week — the table is the answer if the pattern recurs after that.

Why now

The board has #453 (named provider instances), #458 (generic CLI provider), #514 (multi-folder projects), #552 (pane workspace) queued — all of which add channels. The per-channel cost is paid on every one of them, and the drift risk compounds with the number of people and agents editing in parallel.

Related

#622 (the bug this class produced), #418 (Electron architecture umbrella — agent-host utility process; the bridge table belongs in the same conversation), #245 (headless — a third client of the same surface, which makes hand-transcription a three-way sync).

Activity

  1. added
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 20, 2026
  2. currentbits commented on Aug 20, 2026

    @currentbits
    OwnerAuthor

    Implementing the table, not the smaller reverse-seam-only step.

    Approach:

    • src/shared/ipcChannels.ts is the one invoke-channel table (ns + method; channel name is always ns:method).
    • wireClient.ts builds its surface at runtime by iterating the table (bindCoderApi).
    • electron/preload.js cannot require a local module (sandbox: true), so a tiny scripts/sync-ipc-preload.js inlines the same table between markers. --check is wired into typecheck so a stale copy fails CI.
    • Handler bodies stay in electron/ipc.js (IPC_HANDLERS).
    • CoderApi stays the documented type (JSDoc lives there). A compile-time lock in ipcChannels.ts fails tsc if a method exists on one side and not the other.
    • Out of scope, as the issue says: devCoder.ts / fakeCoder.ts.

    Side effect: threads.setVerifyCommand / runVerify join the table, which is the #622 desktop hole.

  3. currentbits commented on Aug 20, 2026

    @currentbits
    OwnerAuthor

    Done in this worktree.

    One table: src/shared/ipcChannels.ts (144 invoke channels). wireClient.ts iterates it at runtime (bindCoderApi). Sandbox preload cannot require a local module, so scripts/sync-ipc-preload.js inlines the same table between markers; --check is part of npm run typecheck / npm run build.

    Not generated, as scoped: devCoder.ts / fakeCoder.ts. CoderApi stays the documented type (JSDoc); IPC_CHANNEL_LOCK fails tsc if a name exists on one side only.

    #622 is fixed as a side effect: threads.setVerifyCommand / runVerify are in the table, so they land on window.coder. The ipc-seam spot-check lists are gone — the test iterates the table in both directions.

    Adding a channel now: handler body in ipc.js, one { ns, method } row, CoderApi JSDoc, run the sync script, fixture only if browser-dev/tests need data.

  4. added
    plan:done
    and removed
    plan:doing
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions