Files
Jack Kavanagh b34241613d chore: isolate gRPC proto file preparation behind IPC boundary (#9828)
* chore: isolate gRPC proto file preparation behind IPC boundary

Move proto temp-file creation out of the renderer by adding a
grpc.writeProtoFile IPC handler (main process) and wiring it up
in the preload bridge. The renderer's ProtoFilesModal previously
called writeProtoFile() directly, pulling node:fs / node:os /
node:path into the renderer bundle. It now calls
window.main.grpc.writeProtoFile(protoFile._id) instead.

Changes:
- src/main/ipc/electron.ts: add 'grpc.writeProtoFile' to HandleChannels
- src/main/ipc/grpc.ts: export writeProtoFileById helper, add to
  gRPCBridgeAPI, register ipcMainHandle('grpc.writeProtoFile')
- src/entry.preload.ts: wire grpc.writeProtoFile via ipcRenderer.invoke
- src/ui/components/modals/proto-files-modal.tsx: remove direct
  write-proto-file import; use window.main.grpc.writeProtoFile in
  the directory-import validation loop
- config/renderer-node-import-baseline.json: remove 5 stale/resolved
  baseline entries (proto-directory-loader.tsx x2 already gone;
  write-proto-file.ts fs/os/path x3 now main-process-only)
- src/main/ipc/__tests__/grpc.test.ts: add writeProtoFileById unit
  tests as contract coverage for the new privileged bridge path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: validate proto syntax in writeProtoFileById IPC handler

The directory-import validation loop relied on writeProtoFile for proto
content validation, but writeProtoFile only writes the temp file without
parsing. Add a protoLoader.load call inside writeProtoFileById so invalid
proto syntax throws before the result is returned to the renderer.

Also update the test to mock @grpc/proto-loader.load and assert it is
called with the correct file path and includeDirs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-17 08:09:47 +00:00
..