digua
53208de60e
feat: 实验室新增基础工具用于调试
2026-04-07 23:43:01 +08:00
digua
fa3282f625
feat: 移除旧版提示词
2026-04-07 23:43:01 +08:00
digua
7919929b94
feat: 增加查询缓存以加速访问
2026-04-07 23:43:01 +08:00
digua
d49a094164
feat: 搜索工具自动携带上下文消息
2026-04-07 23:43:01 +08:00
digua
3189de3a6e
style: 代码格式优化
2026-04-06 22:24:49 +08:00
digua
bfc96a723d
fix: 完善AI对话报错信息
2026-04-06 22:24:49 +08:00
digua
a8c3b032a7
test: add reusable e2e launcher smoke framework and scripts
2026-04-06 22:24:49 +08:00
l17728
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
digua
59e6bdb9cb
feat: 精简部分工具的搜索参数以节省token
2026-04-06 14:04:31 +08:00
digua
0a81238a0a
feat: 支持 FTS5 全文搜索,并新增快速搜索工具
2026-04-06 14:04:31 +08:00
digua
88f1af08dd
feat: 优化SQL对话模块交互逻辑
2026-04-02 23:29:06 +08:00
digua
da3d7bccb4
feat: 新增部分AI工具
2026-04-02 23:29:06 +08:00
digua
346a38da5a
feat: 重构 AI 工具分类体系
2026-04-02 23:29:06 +08:00
digua
e099dde435
feat: 新增获取聊天概览工具
2026-04-02 23:29:06 +08:00
digua
211a8110b0
feat: 新增对话数据缓存管理模块,优化统计数据读取性能
2026-04-02 23:29:06 +08:00
digua
bfca7ff133
fix: SQL Lab 和摘要生成的 AI 错误静默吞没问题
...
- llm:chatStream:正确处理 error/done 事件,防止终态重复发送
- llmComplete:检测 completeSimple 返回的 error stopReason 并抛出异常
- SessionTimeline:摘要生成失败时显示 toast 提示替代 console.log
Made-with: Cursor
2026-04-02 23:29:06 +08:00
digua
b3d1171f71
feat: 废弃部分AI工具
2026-04-02 23:29:06 +08:00
digua
792cb0e1ee
feat: API服务 UI优化
2026-03-28 00:10:29 +08:00
digua
7ce50eab7c
feat: 支持API导入
2026-03-28 00:10:29 +08:00
digua
6d5e6f6e7a
feat: 支持API导出
2026-03-28 00:10:29 +08:00
xind
6d90552b9b
fix: 修复消息去重误判并统一空字符串去重语义
2026-03-27 14:28:36 +08:00
digua
7eaba396ec
refactor: 清理 parser worker rag merger 的历史类型问题
2026-03-25 22:43:12 +08:00
digua
b6fdc3887e
fix: 修复 AI 会话链路与前端 type-check 错误
2026-03-25 22:42:31 +08:00
digua
39b06523d4
fix: 增加默认assistant兜底
2026-03-25 22:10:44 +08:00
digua
8f080910d4
fix: 修复Gemini API配置问题 ( fix #97 )
2026-03-16 23:39:49 +08:00
digua
9e8f9e8678
feat: 完成助手市场和技能市场
2026-03-16 23:39:49 +08:00
digua
4b10cf21dd
feat: 移除旧版提示词系统
2026-03-16 00:27:55 +08:00
digua
c26594d8af
feat: 调用模型的时候,切换页面不再终止进程 resolve #14
2026-03-16 00:27:55 +08:00
digua
3ab730baae
fix: 修复nlp停用词调用顺序问题导致的报错
2026-03-16 00:27:55 +08:00
digua
db9b67071c
feat: 支持@选择成员
2026-03-16 00:27:55 +08:00
digua
7a1a9fc2b1
feat: 聊天对话支持使用技能
2026-03-16 00:27:55 +08:00
digua
a633b4f326
feat: 支持繁体中文和日语国际化
2026-03-16 00:27:55 +08:00
digua
e7f2ee7db7
style: format and lint codebase
2026-03-16 00:27:55 +08:00
digua
ebff151d36
feat: 提升导出聊天记录的展示位置
2026-03-10 23:42:44 +08:00
digua
6edb3e3b95
feat: 优化助手逻辑
2026-03-10 21:35:53 +08:00
digua
60be78b767
feat: 完善助手功能,新增分析tools
2026-03-10 20:42:25 +08:00
digua
f36623d72e
feat: 完成助手模式初版
2026-03-02 01:19:54 +08:00
digua
9ce333afe3
feat(ai): 增加 DEBUG 模式与 AI 日志增强
...
- 设置>关于 新增 DEBUG 模式开关,开启后日志记录完整消息不截断
- aiLogger 支持 debugMode 控制截断行为
- Agent 执行前在 DEBUG 模式下记录完整 System Prompt 和消息历史
- INFO 日志增强:记录模型/Provider/API地址、上下文配置、预处理开关
- 工具调用日志升级:记录完整参数(tool_start)
- 预处理管道统计提升至 INFO 级别
2026-02-28 00:02:12 +08:00
digua
c36878c58d
feat(ai): 实现聊天记录预处理管道
...
- 新增 preprocessor 模块:数据清洗(XML卡片)、黑名单过滤、智能去噪、连续发言合并、数据脱敏
- 内置多国脱敏规则(中国手机号/身份证、美国SSN、日韩号码等)+ 自定义规则支持
- 工具层统一 wrapWithPreprocessing 包装,自动对 rawMessages 执行预处理+格式化
- 昵称匿名化:用 U{id} 替代真实昵称,跨工具调用一致
- SQL 查询补充 senderId/senderPlatformId
- PreprocessConfig 类型定义(preload + 主进程)
2026-02-28 00:02:08 +08:00
digua
1823042fad
style: auto-format code (eslint --fix)
...
Formatting-only changes from ESLint auto-fix, no logic changes.
Made-with: Cursor
2026-02-27 20:22:18 +08:00
digua
07fffb0112
refactor: data flow inversion, IPC contract fixes, and frontend adaptation
...
Data flow inversion:
- Add getHistoryForAgent() in conversations.ts — Agent now reads
history directly from SQLite instead of receiving it from frontend
- Remove historyMessages parameter from agent:runStream IPC chain,
add maxHistoryRounds for configurable context window
- Frontend (useAIChat.ts) pre-creates conversation before Agent call,
removes history message collection logic
IPC fixes:
- Restore llm:chat and llm:chatStream handlers using pi-ai's
completeSimple/streamSimple (P0-1: SQLLab compatibility)
- Send agent:complete with aborted flag in all abort paths to prevent
hanging Promises in renderer (P0-2)
- Fix createConversation parameter order to match preload/data layer
contract: (sessionId, title?) instead of (title, sessionId?) (P1)
Preload/frontend:
- Update preload API signatures and type declarations
- Use shared types for TokenUsage and AgentRuntimeStatus
2026-02-26 21:06:27 +08:00
digua
e6849af698
refactor(agent): split monolithic Agent into modular architecture
...
- Delete monolithic agent.ts (−1464 lines)
- Add agent/index.ts: Agent orchestrator class with runAgent/runAgentStream
- Add agent/types.ts: AgentConfig, AgentStreamChunk, AgentResult, PromptConfig
- Add agent/prompt-builder.ts: system prompt construction with i18n
- Add agent/content-parser.ts: thinking tag and tool call tag parsing
- Add agent/event-handler.ts: runtime state, event mapping, token estimation
2026-02-26 21:05:50 +08:00
digua
f7c427df50
refactor(tools): modularize tool system with AgentTool + TypeBox + i18n
...
- Delete monolithic registry.ts (−1185 lines)
- Add tools/definitions/ with 12 individual tool files + index.ts,
each using AgentTool interface and TypeBox schemas
- Add tools/utils/ with shared helpers (format.ts, schemas.ts, time-params.ts)
- Rewrite tools/index.ts to provide getAllTools() factory
- Clean up tools/types.ts, keep only ToolContext and OwnerInfo
- Use i18n keys for tool descriptions, preserve Chinese as comments
2026-02-26 21:05:39 +08:00
digua
90afe5f087
refactor(llm): unify LLM access layer via pi-ai
...
- Refactor llm/index.ts: remove chat()/chatStream() wrappers, inline
provider info from deleted service files, add buildPiModel() for
direct pi-ai model construction
- Migrate summary/index.ts to use pi-ai's completeSimple directly
- Migrate rag/pipeline/semantic.ts to use pi-ai's completeSimple directly
2026-02-26 21:05:28 +08:00
digua
da3d2531f5
chore: remove over-engineered sessionLog module
...
Delete sessionLog.ts and its test — this module was never used in production
and added unnecessary complexity to the context system.
2026-02-26 21:05:17 +08:00
digua
b9daae8cb4
chore: remove @ai-sdk dependencies and legacy LLM service implementations
...
- Remove @ai-sdk/google, @ai-sdk/openai, ai packages from dependencies
- Delete SDK-based service files: gemini.ts, openai-compatible.ts, sdkUtils.ts
- Clean up unused types from llm/types.ts (ChatMessage, ChatOptions, LLMConfig, ILLMService, etc.)
2026-02-26 21:05:08 +08:00
n-WN
284118ca21
feat(agent): add session-based context timeline and runtime status
2026-02-23 19:17:25 +08:00
digua
8a12aa5c1b
refactor: 重构部分图表为插件形式
2026-02-19 22:56:41 +08:00
digua
90e4502e1d
fix: Windows 上动态更新 overlay 颜色以匹配主题
2026-02-16 17:14:23 +08:00
digua
89b479e292
feat: 优化聊天记录嗅探层,支持轮询检测和fallback
2026-02-13 17:11:55 +08:00