Repository navigation
refactor(preload): split bridge API modules - #17612
Conversation
Greptile SummaryThe PR splits the monolithic Electron preload facade into domain-specific bridge modules while retaining the existing public API and IPC wiring.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains in the reviewed follow-up fixes. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/preload/index.ts | Replaces the monolithic bridge implementation with composition of domain-specific API modules while retaining the exposed API boundary. |
| src/preload/preload-runtime-support.ts | Centralizes preload initialization helpers and shared listener state extracted from the former monolithic entry point. |
| src/preload/api/plugins-bridge.ts | Preserves the plugin bridge contract and consolidates its type imports to satisfy validation. |
| src/main/ipc/github-ipc-channel-parity.test.ts | Updates the GitHub IPC census to inspect both bridge-owner modules used by the composed facade. |
| src/renderer/src/runtime/web-session-tabs-sync/active-session-subscription.ts | Records snapshots as accepted only after they pass recovery, freshness, and apply gates. |
| src/renderer/src/runtime/web-session-tabs-sync/global-session-subscription.ts | Wires separate receipt and acceptance callbacks into visibility-resume coordination and resets both during cleanup. |
| config/tsconfig.tc.web.json | Adds the extracted preload support modules to the web typecheck project. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
R[Renderer] --> A[window.api]
A --> I[src/preload/index.ts]
I --> D[Domain bridge modules]
D --> E[Electron ipcRenderer]
E --> M[Main-process IPC handlers]
Reviews (8): Last reviewed commit: "chore(stack): restack preload on rendere..." | Re-trigger Greptile
There was a problem hiding this comment.
Important
The split itself is mechanically faithful — I diffed every ipcRenderer channel and method name against the pre-split index.ts and found zero drift (0 channels added/removed, 84/84 top-level keys, 821/821 method names). One thing needs confirmation first: the refactor silently adds a public method and changes one reload path's runtime behavior (details inline on app-bridge.ts).
Reviewed changes
- Split
src/preload/index.tsinto ~90 domain bridge modules undersrc/preload/api/, each owning its IPC contract;index.tsshrinks from ~5,300 lines to a ~200-line composer. - Split the four oversized namespaces (
browser,gh,pty,ui) across*-part-N.tsfiles merged by object spread. - Extracted preload runtime support (before-unload checkpoint, native file drop, browser find forwarding, updater quit-abort relay) into
preload-runtime-support.ts. - Extended the web typecheck project to cover the extracted preload support modules.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| import { browserApiPart1 } from './browser-bridge-part-1' | ||
| import { browserApiPart2 } from './browser-bridge-part-2' | ||
|
|
||
| export const browserApi = { ...browserApiPart1, ...browserApiPart2 } |
There was a problem hiding this comment.
The spread-merges for browser, gh, and pty have no satisfies PreloadApi['...'] annotation (unlike ui-bridge.ts:14), and the composed api object in index.ts is not asserted against PreloadApi. That means a method dropped or renamed during a future split edit would not be caught at compile time. Adding the same satisfies guard to the three merge files (or asserting the final composed object) would pin the full surface.
17052dd to
3cd043e
Compare
a7461f1 to
bb0b379
Compare
3cd043e to
ce3c952
Compare
531d778 to
21e1bc9
Compare
54e132d to
b4ab76a
Compare
21e1bc9 to
7f45293
Compare
b4ab76a to
32623d7
Compare
7f45293 to
78fa8a4
Compare
32623d7 to
b18ff33
Compare
78fa8a4 to
41f55ee
Compare
f9468aa to
08820a4
Compare
80d2e62 to
473d3a6
Compare
962cbdf to
1cb0bab
Compare
|
Too many files changed for review (274 files, 100 file limit). Bypass the limit by tagging |
Rebased onto current
|
There was a problem hiding this comment.
ℹ️ No new issues in this restack.
Reviewed changes
- Restored
awaitBeforeUnloadCheckpointto a module-private helper —app-bridge.tsno longer exposes it on the publicappbridge; it is passed only as the internal checkpoint argument toprepareAndInvokeAppRestart, so the renderer's optional-chain fallback inlazy-chunk-recovery-reload.tsis a silent no-op again, matching the pre-split contract. - Re-split the bridge over the advanced renderer-stack base — absorbed the base branch's new preload surface (
reportViewportScrollState,onScrollBrowserPage,retryControlConnection/observeOnly/onSharedControlDiagnostics, SSHkeyboard-interactiveprompts, terminal-splitworktreeId/sourceLeafId) and its removal of theagentHooksnamespace, with zero IPC-channel drift. - Pruned the
src/preload/index.tsmax-lines baseline entry — the composer is back under budget.
IPC channel parity against the new base is clean: the only deltas are the pre-existing support-file channels (gitlab:*, updater:*, window:unload-prevented) documented in earlier reviews. The one remaining open suggestion — adding satisfies guards to the browser/gh/pty merge bridges and asserting the composed api — is unchanged by these commits and still tracked on its existing thread.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
473d3a6 to
20204b1
Compare
1cb0bab to
7c86ed1
Compare
20204b1 to
7a188fe
Compare
7c86ed1 to
7641c79
Compare
7a188fe to
6bcdca1
Compare
7641c79 to
b12c4e1
Compare
6bcdca1 to
835f86b
Compare
b12c4e1 to
416c51b
Compare
835f86b to
8fe371f
Compare
416c51b to
98e76c7
Compare
8fe371f to
4f81616
Compare

Summary\n- Split the preload bridge into domain-named API modules under .\n- Keep the public contract and IPC channel wiring intact.\n- Extend the web typecheck project to include the extracted preload support modules.\n\n## Validation\n- Native oxlint, node/CLI typechecks, max-lines ratchet, focused parity tests, and diff checks passed.\n- Web typecheck is blocked only by unrelated untracked browser-pane extraction files left out of this stack.\n\nStacked on the renderer runtime/store refactor (PR #17611).