34 Commits
Author SHA1 Message Date
moesnow d42e1d1bfb fix(mcp): validate session schema before read-only queries 2026-10-24 16:26:22 +08:00
moesnow eda2694261 fix(mcp): avoid migrations during read-only queries 2026-10-24 16:26:22 +08:00
moesnow 47129958dd fix(mcp): preserve primitive array parameter types 2026-10-21 21:05:50 +08:00
liuyy2 600decf148 test(ai): cover analysis time range precedence 2026-09-21 18:45:55 +08:00
Sanssssssssssssssss f72198f2c5 fix(cli): persist tool history for continuation / 保存工具历史供续聊
CLI dropped completed tool results from replay. Persist bounded results by call ID with error state.
CLI 续聊遗漏已完成的工具结果;按调用 ID 保存限长结果和错误状态。

Add SQLite reload regression for concurrent calls and truncated answers.
新增 SQLite 重载回归,覆盖并行调用与回答截断。
2026-09-21 11:19:53 +08:00
digua db4ce30852 fix(ai): persist truncated turns across chat entry points
Preserve partial output and token usage in CLI turns and edited UI rounds while leaving ordinary failures and cancellation unchanged. Use OutputLimitError across agent runners so incomplete turns remain visibly unsuccessful but can be reloaded and continued.

Cover real stream handling, SQLite persistence, reload, CLI continuation, and unsuccessful one-shot JSON output.
2026-09-18 10:53:06 +08:00
digua a2c4176f89 test(ai): use source imports in root integration test
Reference the shared runtime through its source path, matching the other root integration tests. This fixes workspace dependency validation without adding a root package dependency or changing the test behavior.
2026-09-18 10:53:06 +08:00
digua 1d2eae586c fix(electron): preserve usage on truncated AI responses
Retain cumulative Agent usage from status events and emit it in the terminal done event after an error so truncated Desktop replies keep their token totals.

Cover the real Desktop Agent and stream runner alongside CLI and global entries, including partial output, completion state, and persisted usage.
2026-09-18 10:53:06 +08:00
digua 1388aaccf7 fix(ai): handle model output truncation 2026-09-18 10:53:06 +08:00
digua 59520a2e61 refactor(skills): unify multilingual skill entrypoints 2026-09-06 00:00:36 +08:00
digua e2723cf751 refactor(web): remove Web WASM AI runtime 2026-08-28 14:34:59 +08:00
digua c69a927615 fix(ai): keep global memory always enabled
Remove the proactive-memory preference and its cross-platform runtime plumbing so memory behavior has one clear contract. Normalize away the obsolete setting and keep source type limited to provenance.
2026-08-24 22:35:47 +08:00
digua ed8ab84b4b feat(ai): integrate memory with global agent 2026-08-24 22:35:47 +08:00
digua d53a99359b perf(ai): optimize long conversation rendering 2026-08-19 18:49:20 +08:00
digua 73dca90a51 refactor: inline trivial single-use helpers 2026-08-09 14:04:34 +08:00
digua 2bb5eb3715 test(apps): strengthen application and build verification 2026-08-01 16:41:30 +08:00
digua 7dcf5d9070 feat(web): add Web WASM AI chat 2026-07-27 00:09:33 +08:00
digua cf3fd2ab85 fix(import): enforce reserved system sender contract
Restrict the ChatLab SYSTEM sender to system and recall events, keep bundled validators synchronized, and canonicalize its identity consistently in Node and Browser runtimes. Preserve ordinary participants named SYSTEM in non-ChatLab formats.
2026-07-26 01:43:43 +08:00
digua e5ec60aaaf refactor(format): centralize ChatLab format version 2026-07-19 15:16:29 +08:00
digua 058c3448ca fix(security): harden desktop app lock
Keep the renderer fail-closed until lock state is known, use native modal dialogs without unmounting business state, and coordinate overlapping dialogs while locked. Isolate desktop E2E data from real user settings and keep startup migration inspection read-only.
2026-07-18 11:49:09 +08:00
digua 7d156040f8 fix(runtime): contain and clean temporary workspaces 2026-07-16 20:09:18 +08:00
digua 6dc35722c0 fix(import): disambiguate ChatLab reimports 2026-07-13 01:01:42 +08:00
digua a9a1557867 fix(import): preserve ChatLab owner and aliases
Thread ownerId and member aliases through the TS and native parsers. Persist aliases across full and incremental imports so exported ChatLab JSON retains user identity metadata.
2026-07-12 21:27:39 +08:00
digua 37c446c751 fix(parser): preserve ChatLab members in TS fallback
Stream members and messages in one pass so nested member metadata is parsed structurally. Cover exports whose complete member list exceeds the filtered messages.
2026-07-12 21:27:39 +08:00
digua 96235915b8 fix(export): generate importable ChatLab JSON 2026-07-12 21:27:39 +08:00
digua d3d2661882 fix(relationships): address galaxy review regressions
Bundle relationship worker entries for packaged builds.

Refresh and surface galaxy task failures, clean detached Pixi layers, cap focused neighborhoods, merge owner nodes across platforms, apply manual friend overrides, and track owner group activity.
2026-06-30 14:41:46 +08:00
diguaandClaude Sonnet 4.6 7df673f62f test: add openTestSqliteDatabase helper to fix native binding mismatch
Centralise the better-sqlite3 native-binding selection for tests in
tests/helpers/sqlite.mts so test files consistently use the CLI-side
binding (apps/cli/native/better_sqlite3.node) rather than the default
one, which may be compiled for a different Node.js ABI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 14:18:32 +08:00
digua c2295e317f refactor: align ai chat and segment identifiers 2026-06-07 20:27:27 +08:00
digua 9b1f359699 fix(ai): register chart tool for electron auto skills 2026-06-05 11:12:42 +08:00
digua 296573ed5c refactor(ai): centralize chart runtime policy 2026-06-05 11:12:42 +08:00
CEQ151 15470444e5 feat(ai): improve chart runtime UX 2026-06-05 11:12:42 +08:00
CEQ151 782f67ba63 feat(ai): add slash-activated chart runtime with EChart init fix
- Add ChartSpec validation and chart data normalization (bar/line/pie/heatmap)
- Add render_chart analysis tool with SQL safety (readonly check, outer LIMIT wrapper, CTE write rejection)
- Add chart content block type and ChartBlockRenderer for inline chart rendering
- Add slash menu chart capability activation (single-use per message)
- Add chart payload transport through Electron and CLI Web tool adapters
- Add error block handling for render-only chart tool failures
- Add chart payload persistence through content_blocks JSON storage
- Fix EChart.vue init timing: defer initChart() to nextTick so container
  layout completes before ECharts reads width (was rendering 92px canvases)
- Add comprehensive test coverage: core, integration, agent flow, frontend, smoke
- Add i18n for render_chart and get_schema in 4 locales
- Add project handoff documentation
2026-06-05 11:12:42 +08:00
digua a8c3b032a7 test: add reusable e2e launcher smoke framework and scripts 2026-04-06 22:24:49 +08:00
l17728andClaude Haiku 4.5 b532eeef42 feat: add E2E test framework for Electron applications with robust port management, instance isolation, and safety guards
## 功能
添加 Electron 应用的 E2E 测试启动框架,支持并行实例运行、CDP 调试、独立数据隔离、完善的故障检测和数据保护。

### 核心特性

#### 1. 可靠的端口扫描和预留机制
- 自动查找可用的 TCP 端口(默认从 9222 开始)
- **新增**:保持端口预留直到进程启动,防止 TOCTTOU 竞态
- 修复:递归逻辑中的 null + 1 bug
- 添加最大重试限制(100 次),防止无限递归
- 100ms 超时保护,快速检测端口占用
- 并发安全的 completed 标志和资源清理

#### 2. 正确的 CDP 端口配置
- 使用 --remote-debugging-port=<port> 命令行参数
- 移除无效的 REMOTE_DEBUGGING_PORT 环境变量
- 确保 E2E 客户端能正确连接调试器

#### 3. 完善的启动检测和错误处理
- 验证应用目录和 Electron 可执行文件存在性
- 捕获 spawn 错误事件并提供清晰错误信息
- 检测启动期间的早期退出(非零退出码)
- 检测信号终止的启动失败(SIGKILL、SIGTERM 等)
- 启动后立即抛出错误而不仅记录日志
- 避免连接到死进程,失败诊断清晰

#### 4. 并行实例隔离和数据保护
- 为每个 E2E 实例创建独立的用户数据目录
- 基于端口号生成唯一路径:`/tmp/chatlab-e2e-{port}`
- 通过环境变量 CHATLAB_E2E_USER_DATA_DIR 传递给主进程
- 主进程自动调用 app.setPath('userData', dir) 隔离存储
- **新增**:E2E 模式下跳过遗留数据迁移,保护用户真实数据
- 防止并发进程的状态泄漏、死锁、数据库冲突

#### 5. 优雅且高效的进程管理
- 防止多次调用 close() 导致的事件监听器泄漏
- 检查 proc.exitCode 和 proc.signalCode
- 已退出进程立即返回(无 5s 延迟)
- 使用 SIGTERM 允许进程正常清理资源
- 5 秒超时后强制 SIGKILL 防止僵尸进程
- 使用活力检查(proc.kill(0))替代 proc.killed
- 使用正确的 Node.js API signalCode(不是 signalDescription)
- 强制 SIGKILL 路径对 stubborn 进程有效
- 进程退出时立即清除超时定时器

#### 6. 并行实例支持
- 在主进程添加 TEST_MODE 环境变量检查
- 绕过单实例锁允许多个 Electron 实例
- 跳过遗留迁移保护用户数据
- 每个实例自动分配不同的 CDP 端口和数据目录

### 文件变更
- `electron/main/index.ts`:
  * 添加 TEST_MODE 检查,绕过单实例锁
  * 添加 CHATLAB_E2E_USER_DATA_DIR 读取和隔离
  * **新增**:跳过 E2E 模式下的遗留迁移
- `tests/e2e/helpers/app-launcher.js`: 完整的应用启动管理模块(260+ 行)
  * **新增**:port 预留机制,防止 TOCTTOU 竞态

### 使用示例
```javascript
const { launchApp } = require('./tests/e2e/helpers/app-launcher')

// 启动应用(自动查找可用端口和独立数据目录)
const app = await launchApp()
console.log('CDP 端口:', app.port)

// 运行测试...

// 关闭应用(已退出进程快速返回)
await app.close()
```

### 可配置选项
```javascript
await launchApp({
  port: 9222,                    // 指定端口,默认自动查找(带预留)
  userDataDir: '/custom/path',   // 自定义用户数据目录
  startupWaitTime: 2000          // 启动等待时间(毫秒),默认 2000
})
```

### 并行测试场景
✅ 多个实例同时运行(每个实例独立端口和数据目录)
✅ 自动端口分配(9222, 9223, 9224...)
✅ **端口预留防止竞态**(同时启动无冲突)
✅ 自动数据隔离(/tmp/chatlab-e2e-9222, /tmp/chatlab-e2e-9223...)
✅ 资源正确清理(无泄漏)
✅ 启动失败快速失败(清晰诊断)
✅ 进程强制清理(防止僵尸进程)
✅ 慢速 CI 环境中不挂起
✅ Stubborn 进程能被正确杀死
✅ 已退出进程快速检测和返回
✅ 信号退出的进程也能快速返回
✅ 无共享状态,支持真正的并行测试
✅ 用户数据受保护,不会被测试污染

### 修复的关键问题
**P1 问题:**
- 端口扫描超时导致的无限挂起
- 进程强制杀死被 proc.killed 误导的竞态条件
- 启动期间的早期退出未被检测
- 并行 E2E 实例共享 userData 导致冲突
- **新增**:遗留迁移在 E2E 模式下可能删除用户数据
- **新增**:端口分配 TOCTTOU 竞态导致启动冲突

**P2 问题:**
- 慢速 CI 中的 listen 回调延迟
- close() 对已退出进程的 5 秒不必要延迟
- signalCode API 错误
- 信号终止的启动失败未被检测

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-06 17:37:33 +08:00