createEventDeduper (electron/event-dedupe.ts)

alt-glitch/hermes-agent · apps/desktop/electron/event-dedupe.ts · typescript · MIT
voice

Cross-window de-dupe for one-shot side-effects (OS notifications, the turn-end sound, spoken replies). Every desktop window is its own renderer process, so N open windows each independently react to the same backend event. The main process is the one place they all share and it h

// Source: https://github.com/alt-glitch/hermes-agent | License: MIT | Copyright 2025 Nous Research
// Provided via justclaw.it.com; keep this notice with the code.
// Cross-window de-dupe for one-shot side-effects (OS notifications, the turn-end
// sound, spoken replies). Every desktop window is its own renderer process, so N
// open windows each independently react to the same backend event. The main
// process is the one place they all share and it handles IPC serially, so it's
// the race-free owner: the first window to claim a key within the interval wins;
// peers see it's taken and stay quiet. Pure + injectable clock, so it's
// unit-testable without Electron.

const DEDUPE_INTERVAL_MS = 1000

// Returns true when `key` was already claimed within the interval (caller drops
// this o

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key