# Implement Desktop Features with Electron

Add new features to an Electron desktop application by creating controllers, defining IPC types, and implementing renderer services. The process includes logging, testing, and referencing detailed guides for specific tasks.

**Canonical URL:** https://skillshunter.net/skills/github-lobehub-lobehub-agents-skills-desktop-959257c80f46

**JSON URL:** https://skillshunter.net/api/public/v1/skills/github-lobehub-lobehub-agents-skills-desktop-959257c80f46

**Markdown URL:** https://skillshunter.net/skills/github-lobehub-lobehub-agents-skills-desktop-959257c80f46.md

**Instructions download URL:** https://skillshunter.net/skills/github-lobehub-lobehub-agents-skills-desktop-959257c80f46/download

**Category:** Software & Development

**Source URL:** https://github.com/lobehub/lobehub/blob/54382b5c8e81544da454fa6d7b50f461a562c1ee/.agents/skills/desktop/SKILL.md

**Source commit:** 54382b5c8e81544da454fa6d7b50f461a562c1ee

**Listing approved at:** 2026-11-22

**Created at:** 2026-11-21T11:11:18.000000Z

**Updated at:** 2026-11-22T11:17:05.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's note

Ensure the Electron environment is set up with TypeScript support. Create a controller in `apps/desktop/src/main/controllers/`, define IPC types in `packages/electron-client-ipc/src/types/`, and implement a renderer service in `src/services/electron/`. The first deliverable is a registered controller with an IPC method.

### When to use it

- Adding a new feature to the Electron desktop application
- Creating an IPC handler for communication between main and renderer processes
- Implementing a renderer service for Electron desktop functionality

## Skill instructions

---
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:

1. **Main Process** (`apps/desktop/src/main`): App lifecycle, system APIs, window management
2. **Renderer Process**: Reuses web code from `src/`
3. **Preload Scripts** (`apps/desktop/src/preload`): Securely expose main process to renderer

Both processes log to `<userData>/logs/{main,renderer}.jsonl` in dev and packaged
builds (`apps/desktop/src/main/utils/structuredLog/`); read them with
`pnpm --dir apps/desktop logs list|query|follow` (filters: `--level`, `--since`,
`--operation op_…`, `--topic tpc_…`) instead of `tail`ing files.

## Adding New Desktop Features

### 1. Create Controller

Location: `apps/desktop/src/main/controllers/`

```typescript
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`

```typescript
export interface SomeParams {
  /* ... */
}
export interface SomeResult {
  success: boolean;
  error?: string;
}
```

### 3. Create Renderer Service

Location: `src/services/electron/`

```typescript
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: beside the controller, `apps/desktop/src/main/controllers/<Name>Ctr.test.ts` (`source-layout` §2)

## 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`

