Files
Innei aba9e8150c 👷 build: migrate the test suite to vitest 5 (#19355)
* 👷 build: upgrade vitest to 5.0.0

Bump vitest and @vitest/coverage-v8 to 5.0.0 and migrate the configs for Vitest 4/5: drop the removed coverage.all option and replace poolOptions.forks.singleFork with maxWorkers/isolate.

* 👷 build: shim jest-dom matcher types for vitest 5

Vitest 5 exposes Assertion<R, T> and no longer reads the jest.Matchers augmentation that @testing-library/jest-dom ships, so its matchers vanish from expect(). Re-declare them on the Vitest interface, and replace the removed describe.sequential with { concurrent: false }.

* 👷 build: migrate the test suite to vitest 5

Vitest 5 (and @vitest/coverage-v8) replaces the esbuild dep optimizer with Rolldown, removed environmentMatchGlobs/coverage.all/poolOptions, forwards `new` to mock implementations, requires top-level vi.mock, and no longer resets automocks in restoreAllMocks. Migrate the root config to app/server projects with Rolldown optimizer options, shim the jest-dom matchers on Assertion<R, T>, and update the affected tests (constructor mocks, hoisted mocks, awaited assertions, explicit mock types, per-test mock defaults).

* 👷 build: make the openapi knowledge-base FileService mock constructable

tests/ was outside the per-area sweep; vitest 5 forwards `new` to the mock implementation, so the arrow implementation threw "is not a constructor".

* 👷 build: point the CI blob-report artifacts at the vitest 5 output dir

Vitest 5 writes blob reports to .vitest/blob instead of .vitest-reports, so the sharded jobs uploaded nothing and the merge jobs failed with ENOENT. Track the new directory in .gitignore too.

* 👷 build: refresh the desktop lockfile for vitest 5

apps/desktop/pnpm-lock.yaml is committed and the desktop build action installs with --frozen-lockfile, so the vitest/override change has to be reflected in it.

* 👷 build: keep the pre-vitest-4 coverage exclusions explicit

Vitest 4+ ships an empty coverageConfigDefaults.exclude, so configs that spread it silently lost the default exclusions (node_modules, dist, *.config.*) and counted more files. Inline the previous list.

* 🎨 style: format the migrated vitest configs

* 👷 build: keep canary's new class mocks constructable under vitest 5

exploreGraph/dispatchAuthorization/scopedDevices (canary #19375, #19352) mock classes with arrow implementations; vitest 5 constructs the implementation when the mock is newed, so the arrows throw 'is not a constructor'.
2026-09-10 22:18:49 +08:00
..
…
…

@lobechat/electron-server-ipc

IPC (Inter-Process Communication) module between LobeHub's Electron application and server, providing reliable cross-process communication capabilities.

📝 Introduction

@lobechat/electron-server-ipc is a core component of LobeHub's desktop application, responsible for handling communication between the Electron main process and Next.js server. It provides a simple yet robust API for passing data and executing remote method calls across different processes.

🛠️ Core Features

  • Reliable IPC Communication: Socket-based communication mechanism ensuring stability and reliability of cross-process communication
  • Automatic Reconnection: Client features automatic reconnection functionality to improve application stability
  • Type Safety: Uses TypeScript to provide complete type definitions, ensuring type safety for API calls
  • Cross-Platform Support: Supports Windows, macOS, and Linux platforms

🧩 Core Components

IPC Server (ElectronIPCServer)

Responsible for listening to client requests and responding, typically runs in Electron's main process:

import { ElectronIPCEventHandler, ElectronIPCServer } from '@lobechat/electron-server-ipc';

// Define handler functions
const eventHandler: ElectronIPCEventHandler = {
  getDatabasePath: async () => {
    return '/path/to/database';
  },
  // Other handler functions...
};

// Create and start server
const server = new ElectronIPCServer(eventHandler);
server.start();

IPC Client (ElectronIpcClient)

Responsible for connecting to the server and sending requests, typically used in the server (such as Next.js service):

import { ElectronIPCMethods, ElectronIpcClient } from '@lobechat/electron-server-ipc';

// Create client
const client = new ElectronIpcClient();

// Send request
const dbPath = await client.sendRequest(ElectronIPCMethods.getDatabasePath);

🤝 Contribution

IPC server implementations need to handle various communication scenarios and edge cases. We welcome community contributions to enhance reliability and functionality. You can participate in improvements through:

How to Contribute

  1. Performance Optimization: Improve IPC communication speed and reliability
  2. Error Handling: Enhance error recovery and reconnection mechanisms
  3. New Features: Add support for new IPC methods or communication patterns
  4. Documentation: Improve code documentation and usage examples

Contribution Process

  1. Fork the LobeHub repository
  2. Implement your improvements to the IPC server package
  3. Submit a Pull Request describing:
  • Performance improvements or new features
  • Testing methodology and results
  • Compatibility considerations
  • Usage examples

📌 Note

This is an internal module of LobeHub ("private": true), designed specifically for LobeHub desktop applications and not published as a standalone package.