Instruction file imported from Trogon4081/Gulp (
.github/instructions/electron.instructions.md). Copyright stays with the author.
Electron Instructions
Scope
electron
Version
^41.1.0
Conventions
- Main vs. Renderer: Keep main process code in
src/mainand renderer process code insrc/renderer. - IPC: Use
ipcMainandipcRendererfor communication between processes. - Security: Enable
contextIsolationandnodeIntegration: falseinBrowserWindowoptions.
Common Patterns
- Singleton Window: Ensure only one instance of the main window is created.
- Menu Bar: Create a custom menu bar for the application.
Pitfalls
- Blocking the Main Process: Avoid long-running tasks in the main process.
- Insecure Content: Be careful when loading remote content.
Append-Only Updates
- 2026-04-02: For high-throughput proxy/scanner events, keep capture and analysis in main process services and stream compact progress/result events to renderer via preload subscriptions.
- 2026-04-02: Prefer event-driven channels (
ipcMain+webContents.send/ipcRenderer.on) over tight polling loops for live logs. - 2026-04-02: Renderer update cadence should be buffered/throttled at 100-200ms to prevent UI lockups under burst traffic.
- 2026-04-02: IPC payloads should avoid shipping full unbounded datasets; send incremental slices/metadata and retrieve details on demand.