How valuecell-ai/clawx works
1. What this repository is
ClawX is a cross-platform Electron desktop app that wraps the OpenClaw AI runtime in a graphical UI. The architecture is split into three main runtime surfaces: Electron Main, the React renderer, and a separate OpenClaw Gateway process.
2. Renderer/UI layer
The src/ tree is the user-facing app: React 19 + TypeScript, styled with Tailwind/shadcn. Major screens are Setup, Chat, Channels, Cron, Models, Skills, and Settings. UI state is organized with Zustand stores under src/stores/, while src/i18n/ provides localized strings for English, Japanese, Russian, and Chinese.
3. Frontend data boundary
The renderer does not talk directly to the gateway. It uses src/lib/host-api.ts, api-client.ts, and gateway-client.ts as the single abstraction for all backend interactions. This is an important diagram boundary: the UI calls a stable client API, not transport-specific code.
4. Electron Main as control plane
electron/main/ owns app lifecycle concerns: window creation, tray behavior, quit/focus handling, launch-at-startup, single-instance protection, and update orchestration. It also hosts the preload bridge and IPC handlers, which is where the renderer’s safe access to system capabilities is mediated.
5. Main-side API router
electron/api/ is the main-process API surface. It exposes route modules for agents, app, channels, cron, diagnostics, files, gateway, logs, providers, sessions, settings, skills, and usage. This layer is the bridge between renderer requests and local services/gateway operations.
6. Gateway process as runtime engine
electron/gateway/ manages the OpenClaw Gateway as a separate process with its own lifecycle, restart/reload/recovery policies, health monitoring, request store, and WebSocket client. It is the execution engine for agents, channels, and skill/plugin activity, isolated from the UI process for responsiveness and fault containment.
7. Transport and recovery model
ClawX uses a main-owned transport strategy: WebSocket first, HTTP next, and IPC fallback when needed. That design is reinforced by connection monitoring, startup orchestration, recovery controllers, and restart governors in electron/gateway/. This is the critical path for how UI actions reach the AI runtime and how runtime events come back.
8. Providers and secrets
Provider configuration is handled by electron/services/providers/ and shared provider types in electron/shared/providers/. This subsystem validates providers, migrates configs, syncs runtime models, and persists provider accounts. Sensitive credentials are stored through electron/services/secrets/ using the OS keychain, not plain files.
9. Channels, auth, and local integration
Channel and provider helpers in electron/utils/ handle config, aliases, status, proxying, OAuth flows, and device/browser login for specific providers. This includes OpenAI/Codex-style auth helpers, proxy propagation, and platform-specific shell/network utilities. These utilities sit below the API layer and above the gateway/runtime.
10. Skills and extensions
ClawX has an extension system in both electron/extensions/ and src/extensions/. Built-in extensions include diagnostics and marketplace integration, and skills are bundled from resources/skills/ via manifests and packaging scripts. The Skills page is backed by discovery across managed, workspace, and extra skill directories.
11. Product workflows reflected in the architecture
The main app flows map directly to subsystems: Setup initializes language/provider/skill state; Chat routes conversations and supports @agent targeting; Channels manages multi-account/channel bindings; Cron schedules automation and delivery targets; Models/Settings expose provider and runtime control. These are not separate apps—they are different views over the same gateway-backed domain model.
12. Packaging and runtime assets
electron-builder.yml, vite.config.ts, and the scripts/ directory define build/package behavior. The repo bundles CLI assets, preinstalled skills, icons, and platform-specific wrappers under resources/. On Windows, the packaged CLI is run through shipped node/entrypoint assets to keep terminal behavior stable.
13. Quality and operational boundaries
tests/unit/ covers stores, gateway policies, providers, auth, and UI logic; tests/e2e/ validates Electron-level flows like setup, navigation, provider lifecycle, and gateway behavior. The scripts/comms/ suite is specifically for regression checking message/transport scenarios, which reflects how central the gateway communication boundary is to the system.
Main entry points: App.tsx App shell · host-api.ts Host API · manager.ts Gateway manager · index.ts Main process
Components 24
Renderer UI
React frontend, screens, stores, and client boundary.
- App shell · Top-level renderer app entry and composition.
src/App.tsx - Chat · Conversation UI, execution views, and task visualization.
src/pages/Chat/index.tsx - Channels · Multi-account channel bindings and status management.
src/pages/Channels/index.tsx - Setup · Initial onboarding and runtime initialization flows.
src/pages/Setup/index.tsx - Settings · Runtime, proxy, and provider configuration surfaces.
src/pages/Settings/index.tsx - Skills · Discovery and management of installed and workspace skills.
src/pages/Skills/index.tsx - Models · Provider model views and usage history.
src/pages/Models/index.tsx - Cron · Scheduled automation and delivery workflows.
src/pages/Cron/index.tsx - Stores · Zustand state for chat, gateway, providers, skills, and settings.
src/stores - Host API · Stable renderer-side API over host, IPC, and gateway transport.
src/lib/host-api.ts
Electron Main
Lifecycle, IPC, windowing, and local control plane.
- Main process · App lifecycle, tray, focus, quit, startup, and updates.
electron/main/index.ts - IPC bridge · Preload and IPC handlers mediating safe renderer access.
electron/preload/index.ts - API routes · Main-process route modules for app, agents, channels, cron, files, providers, sessions, settings, skills, and usage.
electron/api/server.ts
OpenClaw Gateway
Separate process runtime, transport, and recovery.
- Gateway manager · Owns gateway process lifecycle, health, and recovery policies.
electron/gateway/manager.ts - Transport · WebSocket-first transport with HTTP and IPC fallback.
electron/gateway/client.ts - Recovery · Startup orchestration, restart governor, and reload/recovery controls.
electron/gateway/startup-orchestrator.ts
Provider & Secrets
Provider persistence, validation, and secure storage.
Extensions
Built-in and app-side extension system.
- Extensions · Built-in extension loading and registry management.
electron/extensions/index.ts - UI extensions · Renderer-side extension registry and loading.
src/extensions/index.ts
Packaging & Assets
Build, bundle, and shipped runtime assets.
- Skill packs · Preinstalled skill manifests and bundled skill resources.
resources/skills/preinstalled-manifest.json - Bundle scripts · Packaging and bundling scripts for CLI, plugins, icons, and skills.
scripts/bundle-openclaw.mjs
Quality
Representative test and regression coverage.
- Unit tests · Representative coverage for stores, gateway policies, providers, auth, and UI logic.
tests/unit - E2E tests · Electron-level flows for setup, navigation, provider lifecycle, and gateway behavior.
tests/e2e
Connections 33
- App shell → Setup: routes to
- App shell → Chat: routes to
- App shell → Channels: routes to
- App shell → Cron: routes to
- App shell → Models: routes to
- App shell → Skills: routes to
- App shell → Settings: routes to
- App shell → Stores: uses state
- Chat → Host API: calls
- Channels → Host API: calls
- Settings → Host API: calls
- Models → Host API: calls
- Skills → Host API: calls
- Cron → Host API: calls
- Host API → IPC bridge: bridges through
- IPC bridge → API routes: dispatches to
- API routes → Gateway manager: controls
- API routes → Providers: uses
- Providers → Secrets: stores creds
- Gateway manager → Transport: communicates via
- Gateway manager → Recovery: restarts/reloads
- Main process → IPC bridge: hosts
- Main process → API routes: serves
- Main process → Gateway manager: supervises
- Extensions → Skill packs: loads packs
- UI extensions → Extensions: mirrors
- Bundle scripts → Skill packs: packages
- Unit tests → Host API: verifies
- Unit tests → Gateway manager: verifies
- Unit tests → Providers: verifies
- E2E tests → App shell: exercises
- E2E tests → Main process: exercises
- E2E tests → Gateway manager: exercises