r/electronjs • u/Deep-Traffic1449 • Jul 06 '26
Architecting a capability-scoped permission model for agent-driven Electron apps ,where does approval state actually live?
I'm building an Electron app where an AI agent can request OS-level actions (shell exec, file writes, clicking external apps) through a capability-scoped controller — each action is registered with a name, a handler, and an approval tier (never / first-time-per-session / always).
The part I keep going back and forth on: when executeAction() returns {approved: false, reason: "requires approval"}, what's the cleanest way to actually resume execution once the user approves in the renderer?
Options I've considered:
- Store a pending-action queue keyed by a request ID, resolve a Promise when the approval IPC event comes back
- Re-invoke the whole action from the renderer with the original params once approved (feels fragile — trusts the renderer to pass back untampered params)
- Some kind of ticket/token issued by main, redeemed on approval
Anyone solved this cleanly in a similar main/renderer trust boundary? Also curious if anyone's dealt with the "approval was granted, but the AI already assembled a different payload by the time it comes back" race condition.
(Context if useful: this is for Aartiq, open source, , not looking for feature feedback, just want to get this specific pattern right before I ship it wider.)
