2 KiB
2 KiB
Preload Process
Secure bridge between main and renderer processes via Electron's contextBridge.
Structure
index.ts- ElectronAPI implementationconstants/ipcChannels.ts- IPC channel name constants
ElectronAPI Organization
Groups exposed methods by domain:
Session APIs
getProjects(),getSessions(),getSessionsPaginated()getSessionDetail(),getSessionMetrics(),getWaterfallData()getSessionGroups(),searchSessions(),getAppVersion()
Repository APIs
getRepositoryGroups(),getWorktreeSessions()
Validation APIs
validatePath(),validateMentions()
CLAUDE.md APIs
readClaudeMdFiles(),readDirectoryClaudeMd(),readMentionedFile()
Notifications
notifications.{get,markRead,markAllRead,delete,clear,getUnreadCount}notifications.{onNew,onUpdated,onClicked}- Event listeners
Config API
config.{get,update}- Read/write configconfig.{addTrigger,updateTrigger,removeTrigger,getTriggers,testTrigger}config.{addIgnoreRegex,removeIgnoreRegex,addIgnoreRepository,removeIgnoreRepository}config.{snooze,clearSnooze,selectFolders}config.{openInEditor,pinSession,unpinSession}
Utilities
openPath()- Shell operationsopenExternal()- Open URLs in browseronFileChange()- File watcher eventsgetZoomFactor()- Get current zoom levelonZoomFactorChanged()- Zoom change listenersession.scrollToLine()- Deep link navigation
IPC Pattern
Config operations use IpcResult<T> wrapper pattern:
interface IpcResult<T> {
success: boolean;
data?: T;
error?: string;
}
The invokeIpcWithResult<T>() helper unwraps and throws on failure.
Adding New IPC Methods
- Define channel constant in
constants/ipcChannels.ts - Implement handler in
src/main/ipc/{domain}.ts - Register in
handlers.tsviaregister{Domain}Handlers() - Add method to ElectronAPI in
preload/index.ts - Update
@shared/types/ElectronAPIif cross-process type needed