Open
Conversation
- Remove all Electron dependencies (electron, electron-vite, electron-builder, @electron-toolkit/*, @electron/rebuild) - Add Express, cors, multer and their type definitions - Add concurrently, tsx, vue-tsc as dev dependencies - Create server/index.ts with minimal Express app and /api/health endpoint - Create server/index.test.ts with node:test health endpoint test - Create vite.config.ts with Vue, TailwindCSS, Nuxt UI plugins and path aliases - Create tsconfig.server.json targeting Node/ESNext - Update tsconfig.json, tsconfig.node.json, tsconfig.web.json to remove Electron references - Update scripts: dev (concurrently), build (tsc + vite), test, start - Remove electron-builder.yml
- Created server/services/db-pool.ts with database connection pool management (cached read-only, writable, time-filter/system-filter utilities) - Created server/services/import.ts with chat import database utilities (schema creation, indexing, dedup keys, temp database management) - Created server/services/queries.ts as barrel re-export module - Created server/services/queries/ with 11 sub-modules: basic.ts, sessions.ts, messages.ts, sql.ts, advanced.ts, session-index.ts, ai-tools.ts, filter.ts, export.ts, types.ts, helpers.ts - All query functions accept sessionId and return same data shapes - No worker_threads or electron imports in server/services/ - Added closeAllDatabases to queries.ts re-exports - 24 tests covering getMemberActivity, getHourlyActivity, getTimeRange, plus getDailyActivity, getAvailableYears, getMessageTypeDistribution, getMessageLengthDistribution, getMembers, getMemberNameHistory, and no-worker_threads/no-electron import verification
- Created server/routes/chat.ts with Express Router for all session endpoints
- GET /api/sessions - list all sessions (returns AnalysisSession array)
- GET /api/sessions/:id - get single session (404 if not found)
- DELETE /api/sessions/:id - delete session (returns { success })
- PATCH /api/sessions/:id - rename session ({ name }) and/or update ownerId ({ ownerId })
- GET /api/sessions/:id/years - available years
- GET /api/sessions/:id/time-range - message time range
- GET /api/sessions/:id/schema - database schema
- POST /api/sessions/:id/sql - execute SQL query (returns { columns, rows, rowCount, duration, limited })
- Wired routes into server/index.ts via app.use('/api/sessions', chatRoutes)
- Added comprehensive tests in server/routes/chat.test.ts (18 tests)
- Copy parser module from electron/main/parser/ to server/parser/ - Fix relative import paths for server directory structure - Fix stream-chain/stream-json CJS-to-ESM import compatibility - Fix LogLevel type to include 'debug' - Fix null/undefined type mismatch in discord exporter - Create server/routes/import.ts with all import endpoints: - POST /api/import (upload and import chat file) - POST /api/import/detect-format (detect file format) - POST /api/import/scan-multi-chat (scan multi-chat file) - POST /api/import/with-options (import with format options) - POST /api/sessions/:id/incremental-import - POST /api/sessions/:id/analyze-incremental - Use multer for multipart file upload handling - Mount import routes in server/index.ts - Write comprehensive tests (10 test cases covering all endpoints) - All 82 tests pass, typecheck clean, build succeeds
…HTTP API client - Rename src/api/ to src/services/ to fix Vite proxy conflict (imports from @/api resolved to /api/*.ts URLs which matched the Vite proxy rule "/api" → Express backend, causing 404s) - Replace all window.chatApi references with imported chatApi from @/services - Replace all window.mergeApi references with imported mergeApi from @/services - Replace all window.sessionApi, window.aiApi, window.llmApi, window.agentApi, window.embeddingApi, window.nlpApi, window.networkApi, window.cacheApi references with imported modules from @/services - Replace window.api.app, window.api.dialog, window.api.clipboard with new appApi, dialogApi, clipboardApi modules in src/services/app.ts - Replace window.electron?.ipcRenderer calls with no-ops (web app) - Replace window.electron?.webUtils in FileDropZone with browser File API - Update src/stores/session.ts to use HTTP API client for all operations - Update src/stores/llm.ts, embedding.ts, settings.ts, prompt.ts - Replace @electron/preload/index and @electron/shared/types imports with @/services/* type imports - Update ImportArea.vue to use File objects (browser File API) instead of Electron file paths - Update IncrementalImportModal.vue to use File-based import - Update ChatSelector.vue to accept File prop instead of filePath - Add appApi.ts for web-compatible replacements of Electron app APIs - Add mergeApi.parseServerFile() for server-side temp file parsing - Update test glob in package.json to include __tests__/ directories - Add 23 tests for session store API integration (all pass) - All 399 tests pass, typecheck passes (pre-existing SessionTimeline.vue errors excluded)
- Updated server/index.ts to serve Vite build output (dist/client/) in production mode with SPA fallback for non-API routes - Updated start script to set NODE_ENV=production via cross-env - Updated README.md with web app setup, dev/build/start instructions, removed all Electron references and architecture docs - Updated README.zh-CN.md with matching Chinese web app documentation - Added 25 integration tests in server/integration.test.ts: - Health check (status, content type) - Session list (returns array) - Import flow (requires file upload) - LLM config (configs object, has-config boolean) - Cache info (info object, data-dir path) - Migration check (needsMigration boolean) - Embedding config, NLP pos-tags - Static file serving and SPA fallback - CORS headers - Package scripts (dev, start, build, no electron deps) - Vite config (proxy, build output) - No Electron references (directory, README) - Chart packages (exist, have Vue components, no Electron APIs) - All 541 tests pass, build passes, typecheck passes
The app was stuck on 'Initializing...' because settingsStore.initLocale() calls ensureDesensitizeRules() which hits GET /api/agent/desensitize-rules. This route was missing, causing a 404 that prevented loadSessions() from running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor: ChatLab Electron → Web Application
This PR refactors ChatLab from an Electron desktop app into a standard web application with an Express backend and Vue 3 + Vite frontend.
Motivation
Remove the Electron dependency so ChatLab can run as a web app — deployable anywhere, no desktop install required.
Architecture Changes
Before: Electron main process ↔ IPC ↔ Renderer (Vue)
After: Express server (API) ↔ HTTP ↔ Vue 3 SPA (Vite)
What Changed
285 files changed — 21,988 insertions, 22,397 deletions
🗄️ Server (new
server/directory)All Electron main process logic moved to an Express server:
server/database/core.tsserver/services//api/chat/*/api/import/*/api/analysis/*/api/members/*/api/messages/*/api/nlp/*/api/llm/*/api/agent/*/api/ai-conversations/*/api/embedding/*/api/cache/*/api/network/*/api/session-index/*/api/merge/*/api/migration/*🖥️ Frontend (
src/)src/api/client layer — HTTP client replacingwindow.*preload APIswindow.chatApi,window.mergeApi,window.aiApi,window.agentApicalls replaced with HTTP API clientwindow.*Electron API calls replaced/api→ Express backend)🗑️ Removed
electron/directory (main process, preload scripts, IPC handlers)electron-builder.ymlelectron.vite.config.tselectron/preload/apis/*files✅ Tests
server/integration.test.ts)src/api/__tests__/)How to Run
Stories Implemented
Built via antfarm multi-agent workflow (feature-dev pipeline)