Skip to content

How does the page see the renderer bridge's type? #228

Closed

Description

@jtklein-agents

Question

Does the page get one renderer bridge type derived from the preload plus a Window declaration, replacing the rule that a .ts page file casts window through unknown? Or does the cast stay? Where does the type live so the page still does not import the preload's channel strings?

Activity

  1. added
    wayfinder:grilling
    on Nov 16, 2026
  2. jtklein-agents commented on Nov 16, 2026

    @jtklein-agents
    OwnerAuthor

    Resolution

    The page sees the renderer bridge through one declared interface and a Window declaration. No cast.

    • Declared, not derived. One RendererBridge interface in src/common/rendererBridge.ts, types only. The preload's object is checked against it (satisfies). It is not derived with typeof from the preload, because ipcRenderer.invoke types every result as any.
    • Reached through Window. A global Window declaration adds rendererBridge, so a page file reads window.rendererBridge with no cast. This replaces the tracker rule that a .ts page file casts window through unknown.
    • Call sites keep their shape. const { rendererBridge } = window; stays inside each method with only the cast removed. Tests replace window.rendererBridge between cases, so it is not read once at module load.
    • Crossing payloads are typed once, in main. Main owns the type in both directions: what the page sends, what main returns, and the events main emits. Main exports the types it already declares beside its handlers (StartRunPayload, ModelSelectionPayload, AstralPayload, AlignmentParseResult, CheckOutputResult, SelectedAlignment), and the bridge type file imports them with type-only imports. This is additive exports only, no main behaviour change, and an exception to the coding standard's "inject types stay module-local" for crossing types.
    • Event payloads have no named type in main today (they go through the send helper in src/main/processHelpers.ts). The leaf that first needs one adds it in main.
    • The interface grows leaf by leaf. The first leaf names every member and gives it the types that are free: plain parameters and results main already declares. Each later page leaf tightens the members that file calls. The finished interface is the sum of the leaves; it is not written complete on day one.
    • First leaf. One leaf, before any page file: the bridge type file, src/preload/index.js renamed to .ts and checked against it, the Window declaration, and the cast removed from src/app/bootstrap.ts. Still-JavaScript page files keep their @type {any} cast until their own leaf.
    • Jest stand-ins stay untyped. jest/setup.js, jest/storeBridge.js and the test files are JavaScript with @ts-nocheck.

    For the spec: the leaf updates the Renderer bridge cast rule in docs/agents/issue-tracker.md and notes the crossing-types exception under TypeScript renames in CODING_STANDARDS.md. No glossary change; no ADR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions