π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
Desktop Feature Implementation Guide
Architecture Overview
Main Process Renderer Process
ββββββββββββββββββββ ββββββββββββββββββββ
β Controller ββββIPCββββΊβ Service Layer β
β (IPC Handler) β β β
ββββββββββββββββββββ ββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β System APIs β β Store Actions β
β (fs, network) β β (UI State) β
ββββββββββββββββββββ ββββββββββββββββββββ
Step-by-Step Implementation
1. Create Controller
// apps/desktop/src/main/controllers/NotificationCtr.ts
import type {
ShowDesktopNotificationParams,
DesktopNotificationResult,
} from '@lobechat/electron-client-ipc';
import { Notification } from 'electron';
import { ControllerModule, IpcMethod } from '@/controllers';
export default class NotificationCtr extends ControllerModule {
static override readonly groupName = 'notification';
@IpcMethod()
async showDesktopNotification(
params: ShowDesktopNotificationParams,
): Promise<DesktopNotificationResult> {
if (!Notification.isSupported()) {
return { error: 'Notifications not supported', success: false };
}
try {
const notification = new Notification({ body: params.body, title: params.title });
notification.show();
return { success: true };
} catch (error) {
console.error('[NotificationCtr] Failed:', error);
return { error: error instanceof Error ? error.message : 'Unknown error', success: false };
}
}
}
2. Define IPC Types
// packages/electron-client-ipc/src/types/notification.ts (re-exported from types/index.ts)
export interface ShowDesktopNotificationParams {
title: string;
body: string;
}
export interface DesktopNotificationResult {
success: boolean;
error?: string;
}
3. Create Service Layer
// src/services/electron/desktopNotification.ts
import type { ShowDesktopNotificationParams } from '@lobechat/electron-client-ipc';
import { ensureElectronIpc } from '@/utils/electron/ipc';
export class DesktopNotificationService {
async showNotification(params: ShowDesktopNotificationParams) {
return ensureElectronIpc().notification.showDesktopNotification(params);
}
}
export const desktopNotificationService = new DesktopNotificationService();
4. Implement Store Action
// src/store/.../actions.ts
showNotification: async (title: string, body: string) => {
if (!isElectron) return;
const result = await desktopNotificationService.showNotification({ title, body });
if (!result.success) {
console.error('Notification failed:', result.error);
}
},