- Add "type": "module" to all workspace package.json files
- Replace __dirname with import.meta.url-based resolveCliPath() helper
- Convert stream-json/stream-chain CJS named imports to default + destructure
for ESM compatibility
- Use createRequire() for @node-rs/jieba native module loading in ESM context
Co-authored-by: Cursor <cursoragent@cursor.com>
CLI Web was missing chatApi.exportSessionsToTempFiles,
chatApi.cleanupTempExportFiles and the entire mergeApi shim,
causing "not a function" errors when merging sessions in
Settings > Data Management.
Co-authored-by: Cursor <cursoragent@cursor.com>
The unified directory migration (needsUnifiedDirMigration) would
re-trigger after a user changed their data directory, overwriting
config.toml back to the old Electron path.
Root cause: no persistent flag tracking whether the migration had
already completed. If old databases remained (cleanup failure or
timing), it would re-detect and re-run.
Fix:
- Add `electron_migration_done` flag to config.toml [data] section
- Set flag after migrateToUnifiedDirs succeeds and in setCustomDataDir
- Check flag at start of needsUnifiedDirMigration to skip if done
- Add "migrate to default" button when data is at non-default path
- Fix NLP directory path: move from userDataDir to systemDir (~/.chatlab/nlp)
Co-authored-by: Cursor <cursoragent@cursor.com>
CLI Web's Settings > Storage Management was completely non-functional
(stub cacheApi returning empty data). This adds real HTTP endpoints
and wires the frontend to use them.
Backend (cache.ts):
- GET /_web/cache/info — scan databases/ai/cache/logs directory sizes
- POST /_web/cache/clear — clear cache or logs directory (allowlist)
- POST /_web/cache/open-dir — open directory in system file manager
- GET /_web/cache/data-dir — return current data directory path
- GET /_web/cache/latest-import-log — find latest import log file
Frontend:
- Replace cacheApi stubs with real HTTP calls in registry.ts
- Hide data directory migration UI in CLI Web (IS_ELECTRON guard)
- Add "Open Root Dir" button for ~/.chatlab/ in header area
Co-authored-by: Cursor <cursoragent@cursor.com>
Move auto-close logic from finally to success path so the modal
remains open for retry when generate() fails in force mode.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
P1: Small terminal pages with hasMore=false were incorrectly treated as
empty based on file size alone, causing valid messages to be silently
dropped. Now checks actual message content via fileContainsMessages().
P1: Retry import results were not validated, so import failures (including
needFullResync) were masked as success. Now properly handles all failure
cases and tracks retryHasMore to exit the retry loop correctly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace UButton :loading with animate-spin on the arrow-path icon itself.
The sync button's icon now rotates when syncing, and the button is disabled.
The "sync all" button is also disabled when any session is syncing.
50 pages (50k messages) was too low for groups with 100k+ messages.
Raise to 5000 pages (5M messages) as a safety valve while allowing
full-sync to complete in a single pull cycle for most conversations.
After pull-sync imports new messages, generate session index incrementally
instead of full regeneration. This preserves existing sessions and their
summaries, only processing newly imported (unindexed) messages.
Adds generateIncremental method across the full stack:
- core: already had generateIncrementalSessionIndex
- node-runtime: expose generateIncrementalIndex
- CLI: add POST /_web/sessions/:id/generate-incremental-index route
- Electron: add session:generateIncremental IPC handler
- Frontend: add generateIncremental to SessionIndexAdapter interface
After importing messages via pull sync, automatically generate session
index for the affected sessions. This ensures the timeline and session
overview are immediately available without manual index generation.
After a sync finishes (triggerPull/triggerPullAll/onPullResult), reload the
session list so newly imported chats appear in the sidebar immediately.
Also refresh after removing a subscription with deleteData=true so the
deleted session disappears from the sidebar.
When the remote server doesn't return a `page` field and the result count
equals the requested limit, automatically re-fetch with limit=5000 to get
the complete session list instead of showing truncated results.
- Show confirmation dialog with two choices: keep data or delete imported chats
- Backend supports deleteData param across CLI routes and Electron IPC
- DataSourceManager.removeSession now returns the removed session info
- Add i18n strings for the delete confirmation dialog (zh-CN/en-US/ja-JP/zh-TW)
- Add multi-retry (3 attempts, 2s/3s/5s delays) for cold-start empty responses
- Remove unused offset/end parameters from fetch URL construction
- Fix Accept header to application/json only (avoids content negotiation issues)
- Add PullProgress type and progress tracking in PullEngine
- Export progress via getProgress() for frontend polling
sessionExists() previously only checked file existence, causing pull sync
to enter incremental import path on invalid/empty DB files. Now validates
that the message table exists, and maps schema errors to needFullResync
as a safety fallback.
Add a hover-triggered CaptureButton to each expanded changelog entry so
users can screenshot individual version notes. Make the @zumer/snapdom
markdown list compatibility fix opt-in via a new `markdownFix` option
(default false), so custom-styled lists like changelog bullets are no
longer disrupted during capture.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract version/tag/prerelease detection into a shared prepare_release job,
split CLI packaging into its own build-cli artifact, switch publish-cli to
download the pre-built artifact instead of rebuilding inline, pin pnpm install
with --frozen-lockfile, and fix changelog summary lookup to match by version
instead of always selecting the first entry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a pullAllSessions was already running, the reloadTimer triggered
by adding sessions would be skipped by the source-level concurrency
lock, causing newly added sessions to wait until the next scheduled
interval (up to 60 minutes) before syncing.
Fix: trigger individual per-session pulls via triggerPull(sourceId,
sessionId) which bypasses the source-level lock, ensuring immediate
sync for newly added sessions regardless of concurrent pulls.
Also includes: connection pre-check on data source add, removal of
duplicate "browse remote sessions" button, hiding "other" session
types, and full resync fix for deleted local sessions.
Co-authored-by: Cursor <cursoragent@cursor.com>
Extract shared business logic from monolithic web.ts into reusable
services in @openchatlab/node-runtime (session, member, index, summary,
export), using SessionRuntimeAdapter to abstract platform differences.
Split web.ts into 12 domain-specific route modules under routes/web/.
Co-authored-by: Cursor <cursoragent@cursor.com>
MiniMax models embed thinking content as <think> tags in the content
field rather than using a separate reasoning field. Add a streaming
think-tag parser that detects these tags in real-time during streaming
and routes them to the thinking UI instead of displaying raw tags.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add directory import support for multi-file formats (e.g. shuakami chunked-jsonl).
Users can select or drag-and-drop a directory via the "Import Folder" checkbox.
- Add `findEntryFileInDirectory()` to parser layer for format-agnostic entry file discovery
- Add `importDirectory` method to ImportAdapter interface
- Implement FetchImportAdapter.importDirectory with multi-file FormData upload
- Add `POST /_web/import-directory` CLI route with directory reconstruction
- Add `chat:importDirectory` IPC handler in Electron main process
- Enhance FileDropZone with `directory` prop and drag-and-drop directory support
- Refactor FetchImportAdapter to extract reusable `consumeSseStream` helper
Co-authored-by: Cursor <cursoragent@cursor.com>
The IncrementalImportModal was Electron-only: showOpenDialog returned
canceled in web mode and FetchImportAdapter threw notSupported for both
analyzeIncrementalImport and incrementalImport despite CLI routes
already existing. Fix by using FileDropZone's built-in file input for
file selection and implementing the two fetch adapter methods via
FormData upload + SSE streaming.
Co-authored-by: Cursor <cursoragent@cursor.com>
The MCP entry was loading better-sqlite3 from node_modules which may
have been compiled for a different Node.js ABI. Now passes the
pre-built native binding from apps/cli/native/ (maintained by
ensure-native.mjs), matching how other CLI commands handle this.
Co-authored-by: Cursor <cursoragent@cursor.com>
- Expand MCP_TOOL_REGISTRY from 8 to 33 tools by including all
AGENT_TOOL_REGISTRY tools (analytics, deep search, conversation, etc.)
- Add format=text|json parameter to all MCP tools (default: text for
most, json for SQL tools) for token-efficient LLM consumption
- Create format.ts: message filtering, consecutive-sender merging,
content truncation, and compact text output
- Inspired by community chatlab-mcp-server project
Co-authored-by: Cursor <cursoragent@cursor.com>
Move MCP Server logic (tool registration, resource registration, schema
conversion) from apps/cli/src/mcp.ts to packages/mcp-server so both CLI
and Desktop can share the same MCP implementation.
- New package: chatlab-mcp (packages/mcp-server) with McpDatabaseManager
interface abstraction
- CLI mcp.ts slimmed to thin entry (~37 lines) calling startMcpServer()
- Desktop helper prototype at apps/desktop/helper/mcp.ts for dev-time
MCP without GUI
- All 8 MCP tools and 3 resources unchanged
Co-authored-by: Cursor <cursoragent@cursor.com>