desktop
lobehub/lobehub
Electron desktop development guide for LobeHub — IPC, controllers, preload scripts, and window management.
What is desktop?
A reference guide for building Electron desktop features in LobeHub. Use this when adding new desktop capabilities, setting up IPC communication between main and renderer processes, or managing windows and menus.
- Create controllers in the main process with IPC method decorators
- Define type-safe IPC interfaces for main-renderer communication
- Build renderer services that invoke main process functionality
- Implement store actions for state management
- Configure window and menu behavior
- Write tests for desktop controllers
How to install desktop
npx skills add https://github.com/lobehub/lobehub --skill desktop- Familiarity with Electron architecture (main/renderer processes)
- Understanding of TypeScript and async/await patterns
- Access to LobeHub repository structure
- Node.js development environment
How to use desktop
- 1.Review the architecture overview to understand main process, renderer process, and preload script roles
- 2.Create a new controller class in apps/desktop/src/main/controllers/ extending ControllerModule
- 3.Define IPC types in packages/electron-client-ipc/src/types/ for your feature's parameters and return values
- 4.Register your controller in apps/desktop/src/main/controllers/registry.ts
- 5.Create a renderer service in src/services/electron/ that calls the IPC method
- 6.Implement store actions in src/store/ to manage state from the service
- 7.Write tests in apps/desktop/src/main/controllers/__tests__/ to verify controller behavior
- 8.Reference the detailed guides in references/ for menu configuration, window management, or local tools workflow
Use cases
- Adding a new system feature (file access, notifications, etc.) to the LobeHub desktop app
- Setting up bidirectional communication between Electron main and renderer processes
- Implementing menu items or window controls that require main process access
- Creating a local tool integration that needs system-level permissions
- Testing desktop-specific functionality before deployment
- Electron/desktop developers
- LobeHub contributors extending desktop features
- Full-stack developers building cross-platform apps
- Teams maintaining Electron-based applications
desktop FAQ
System-level code goes in the main process controller (apps/desktop/src/main/controllers/). Use IPC methods to expose it safely to the renderer process.
Define types in packages/electron-client-ipc/src/types/, create a controller with @IpcMethod() decorators, and call it from a renderer service using the ensureElectronIpc() utility.
Preload scripts securely expose main process APIs to the renderer process without exposing the full Electron API, reducing security risks.
Refer to references/menu-config.md for menu configuration and references/window-management.md for window setup and lifecycle management.
Write tests in apps/desktop/src/main/controllers/__tests__/ that verify your controller methods return expected results.
Full instructions (SKILL.md)
Source of truth, from lobehub/lobehub.
name: desktop description: Electron desktop development guide — IPC handlers, controllers, preload scripts, window/menu management. disable-model-invocation: true
Desktop Development Guide
Architecture Overview
LobeHub desktop is built on Electron with main-renderer architecture:
- Main Process (
apps/desktop/src/main): App lifecycle, system APIs, window management - Renderer Process: Reuses web code from
src/ - Preload Scripts (
apps/desktop/src/preload): Securely expose main process to renderer
Adding New Desktop Features
1. Create Controller
Location: apps/desktop/src/main/controllers/
import { ControllerModule, IpcMethod } from '@/controllers';
export default class NewFeatureCtr extends ControllerModule {
static override readonly groupName = 'newFeature';
@IpcMethod()
async doSomething(params: SomeParams): Promise<SomeResult> {
// Implementation
return { success: true };
}
}
Register in apps/desktop/src/main/controllers/registry.ts.
2. Define IPC Types
Location: packages/electron-client-ipc/src/types/<domain>.ts, re-exported from types/index.ts
export interface SomeParams {
/* ... */
}
export interface SomeResult {
success: boolean;
error?: string;
}
3. Create Renderer Service
Location: src/services/electron/
import { ensureElectronIpc } from '@/utils/electron/ipc';
const ipc = ensureElectronIpc();
export const newFeatureService = async (params: SomeParams) => {
return ipc.newFeature.doSomething(params);
};
4. Implement Store Action
Location: src/store/
5. Add Tests
Location: apps/desktop/src/main/controllers/__tests__/
Detailed Guides
See references/ for specific topics:
- Feature implementation:
references/feature-implementation.md - Local tools workflow:
references/local-tools.md - Menu configuration:
references/menu-config.md - Window management:
references/window-management.md
Related skills
More from lobehub/lobehub and the wider catalog.

drizzle
Drizzle ORM schema and query patterns for PostgreSQL databases with type inference.

hotkey
Add and manage keyboard shortcuts with scopes, conflict detection, and i18n support.

i18n
Manage user-facing strings and translations using react-i18next with flat key naming and automated locale generation.

linear
Manage Linear issues, track status, and organize sub-issue trees directly from your coding agent.

microcopy
UI copy and microcopy guidelines for user-facing text, buttons, errors, and onboarding in Chinese and English.

modal
Imperative modal, dialog, and confirmation APIs for LobeHub UI components.