跳到主要内容

Electron IPC Communication

Inter-process communication between Electron main and renderer processes.

Overview

The Gauzy desktop app uses Electron's IPC (Inter-Process Communication) for:

  • Timer controls from renderer → main
  • Screenshot capture from main → renderer
  • Activity data collection
  • Settings synchronization

Architecture

Common IPC Channels

ChannelDirectionDescription
timer:startRenderer → MainStart timer
timer:stopRenderer → MainStop timer
timer:statusMain → RendererTimer state update
screenshot:takenMain → RendererScreenshot captured
settings:updateBothSettings changed
app:minimizeRenderer → MainMinimize to tray

Renderer → Main

// In Angular component/service
const { ipcRenderer } = window.require("electron");

ipcRenderer.send("timer:start", {
projectId: "uuid",
taskId: "uuid",
});

ipcRenderer.on("timer:status", (event, data) => {
// Update UI with timer state
});

Main → Renderer

// In Electron main process
ipcMain.on("timer:start", (event, data) => {
timerService.start(data);
// Send status back
mainWindow.webContents.send("timer:status", { running: true });
});