Commit Graph

283 Commits

Author SHA1 Message Date
8d5a034c70 fix(chat): recover assistant placeholder after stop and switch 2026-04-04 19:47:03 +08:00
0296418cff fix(task): stop canceled runs and clear stale task events 2026-04-04 19:46:56 +08:00
b9df354808 fix: 修复极简模式思考内容与SVG图标对齐问题
- 使用相对单位调整思考内容的垂直对齐
- 添加负margin-top让第一行文字中心与SVG图标中心对齐
- 计算公式:(1em - 1.7em) / 2,基于line-height自动适配
- 不影响工具步骤的对齐(工具header的line-height为1)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 16:38:56 +08:00
c26cd3d3fd fix: 修复极简模式多个问题并恢复偏好设置自动应用
- 修复极简模式下步骤竖线距离SVG不均匀的问题
  - 使用flex布局让竖线自动填充空间
  - 添加负margin让竖线延伸到下一个步骤
  - 确保竖线上下距离SVG图标相等

- 修复SVG图标颜色问题
  - 统一使用灰色(--claude-text-tertiary)
  - 不再受颜色模式影响

- 修复思考内容自动滚动问题
  - 添加registerThinkingRef和handleThinkingScroll支持
  - 移除导致滚动异常的伪元素负margin
  - 实现与堆叠模式一致的自动滚动行为

- 修复轮询改造后偏好设置不自动应用的问题
  - 在loadInitialData中应用默认模型和运行模式
  - 在createNewConversation前应用偏好设置
  - 在loadConversation前应用偏好设置
  - 确保新建或切换对话时使用用户设置的默认值

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 16:18:15 +08:00
a030ff954b fix: 修复工具增强显示的多个问题
1. read_file 工具支持三种模式显示
   - read 模式:显示完整文件内容
   - search 模式:显示搜索匹配项和行号
   - extract 模式:显示提取的多个片段

2. edit_file 工具兼容新旧数据格式
   - 支持 old_string/new_string 格式(当前后端使用)
   - 支持 replacements 数组格式(为未来扩展预留)

3. write_file 工具显示写入内容
   - 显示完整的写入内容
   - 使用绿色+号样式(与 edit_file 一致)
   - 支持显示追加模式标识

4. 极简模式工具图标匹配修复
   - 修复所有工具图标都显示为 run_command 的问题
   - 使用与堆叠块模式相同的图标获取逻辑
   - 正确显示每个工具对应的图标

5. 新增样式支持
   - 搜索匹配项样式
   - 提取片段样式
   - 移除彩色侧边框,保持简洁

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 15:37:38 +08:00
6697da9581 fix: 修复轮询机制下对话标题不自动更新的问题
- 后端:在标题生成后将 conversation_changed 事件添加到任务事件流
- 前端:在 taskPolling 中添加 conversation_changed 事件处理
- 前端:同步更新当前对话标题和对话列表中的标题
- 兼容:保留 WebSocket 的标题更新逻辑以向后兼容

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 15:12:18 +08:00
321818f7ef feat: 新增极简模式(Minimal Mode)
新增了一个全新的消息显示模式,提供更简洁的对话体验。

主要功能:
- 新增 MinimalBlocks.vue 组件,实现极简风格的消息块展示
- 在 ChatArea.vue 中集成极简模式渲染逻辑
- 在个性化设置中添加"极简模式"选项(blockDisplayMode)
- 支持三种显示模式:堆叠模式、极简模式、传统模式

技术实现:
- 使用 personalization store 管理显示模式状态
- 通过 computed 属性动态切换渲染组件
- 保持与现有堆叠模式和传统模式的兼容性

用户体验:
- 更清爽的界面布局
- 减少视觉干扰
- 适合快速浏览对话内容

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 14:47:45 +08:00
b474a69b3b fix: 修复停止按钮点击后不恢复为发送按钮的bug
修复了运行期间点击停止按钮后,按钮状态无法恢复的问题。

问题原因:
- stopTask() 方法中 stopRequested 被设置为 true 但未重置
- composerBusy 计算属性依赖 stopRequested 状态
- 导致按钮持续显示停止图标,需要刷新页面才能恢复

修复方案:
- 在 stopTask() 的 finally 块中重置 stopRequested 为 false
- 确保无论成功或失败,状态都能正确恢复

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 14:47:36 +08:00
aeb782d479 refactor: 清理WebSocket遗留代码,标记为废弃
Phase 2 WebSocket代码清理:

前端 (useLegacySocket.ts):
1. 添加文件头注释说明架构变更
   - 聊天流式事件已废弃,改用 REST API 轮询
   - 保留系统事件、配额事件、对话事件、子智能体事件
   - 标记待清理的流式处理代码

2. 简化 ai_message_start 事件处理器
   - 只保留子智能体模式的处理
   - 删除复杂的流式状态管理逻辑

3. 保留备份文件 useLegacySocket.ts.backup
   - 用于紧急回退

后端 (socket_handlers.py):
1. 标记 handle_message 为废弃
   - 添加废弃警告和迁移指南
   - 返回错误提示引导用户使用 REST API
   - 保留原代码用于紧急回退(注释掉)

2. 说明新架构优势
   - 支持分布式部署
   - 更好的错误恢复
   - 减少 WebSocket 连接压力

注意:
- 未删除大量流式处理代码,只添加注释标记
- 保留向后兼容性,避免破坏现有功能
- 后续可逐步清理标记为废弃的代码

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 01:15:31 +08:00
7912d3fd64 fix: 修复页面初始化时对话列表不加载的bug
问题描述:
- 页面刷新后对话列表显示"暂无对话记录"
- 必须创建新对话才会触发列表加载
- 用户体验很差

根本原因:
- loadInitialData() 方法中缺少 loadConversationsList() 调用
- 对话列表只在创建新对话时才会刷新(createNewConversation 第383行)
- 导致页面初始化时 conversations 数组为空

修复方案:
- 在 loadInitialData() 末尾添加对话列表加载
- 重置 conversationsOffset 为 0 确保从头加载
- 在其他初始化任务完成后执行,避免阻塞

测试:
1. 刷新页面,对话列表应立即显示
2. 创建新对话,列表应正常更新
3. 切换对话,列表应保持正常

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 01:08:13 +08:00
8d6c59deed feat: 优化轮询机制(重试、清理、错误提示)
Phase 3 轮询优化:

1. 添加重试机制(task.ts)
   - 新增 pollingErrorCount 状态字段
   - 添加 5 秒超时(AbortSignal.timeout)
   - 连续失败 5 次后停止轮询并通知用户
   - 成功后重置错误计数

2. 改进错误提示(taskPolling.ts)
   - 根据 error_type 提供友好提示
   - 支持 api_error、timeout、quota_exceeded 等类型
   - 延长错误提示显示时间(8秒)

3. 添加任务清理机制(tasks.py)
   - 新增 cleanup_old_tasks() 方法
   - 清理超过 1 小时的已完成任务
   - 启动后台定时器(每 10 分钟清理一次)
   - 减少内存占用,支持长期运行

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 01:04:35 +08:00
de82a37958 fix: 修复代码块复制、事件去重、任务结束、停止按钮bug
Phase 1 关键Bug修复:

1. 代码块复制功能
   - 删除 index.html 中的全局事件监听(47-53行)
   - 避免与 Vue 方法的双重监听冲突

2. 事件去重机制
   - 在 handleTaskEvent() 添加基于 idx 的去重检查
   - 使用 Set 存储已处理的事件索引(最多1000个)
   - 在 restoreTaskState() 时清理已处理事件

3. 任务结束逻辑
   - 修复 handleTaskComplete() 异步状态清理问题
   - 新增 clearTaskState() 统一清理方法
   - 在 stopPolling() 中清除 currentTaskId

4. 停止按钮状态同步
   - 改进 stopTask() 错误处理
   - 添加后端确认等待(300ms)
   - 确保失败时也清理前端状态
   - 添加 finally 块清除 dropToolEvents

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 01:03:06 +08:00
ce02ea21fb fix(stream): prevent tool-call argument leakage into text chunks 2026-04-03 16:09:29 +08:00
494edc53e9 docs(skill): document blocking and background sub-agent modes 2026-04-03 11:35:00 +08:00
21d1a14fea fix(core): extend sleep wait cap to one hour 2026-04-03 11:34:54 +08:00
860fa7b539 feat(web): remove socket dependency from main chat flow 2026-04-03 11:34:42 +08:00
7ae29180b6 chore: ignore log files 2026-03-17 22:49:08 +08:00
5f6622a212 chore: add docs and remove sub_agent 2026-03-17 22:46:43 +08:00
12c7a4bdd9 fix: remove legacy file edit tags 2026-03-17 22:43:51 +08:00
5ab3acef9c feat: 添加 terminal-guide 和 sub-agent-guide skills
- 新增 terminal-guide skill: 持久化终端使用指南
- 新增 sub-agent-guide skill: 子智能体使用指南
- 优化终端工具定义和执行逻辑
- 更新系统提示词以引用新 skills
- 添加 utils/__init__.py 模块初始化文件

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-16 21:17:02 +08:00
b6462ff1e2 fix: skip sub-agent notify for blocking run 2026-03-14 21:35:47 +08:00
96d0e68347 fix: run sub-agent tools inside container 2026-03-14 21:13:27 +08:00
f3179e2a97 feat: 优化滚动锁定和个性化称呼功能
滚动锁定优化:
- 滚动锁定默认始终启用,不再根据输出状态自动解锁
- 深色模式下锁定图标显示为白色,与箭头图标保持一致

个性化称呼功能:
- AI 助手名称根据个性化设置中的"自称"动态显示
- 用户名称根据个性化设置中的"称呼"动态显示
- 页面初始化时自动加载个性化设置,无需打开个人空间
- 在"模型行为"中新增"使用自定义称呼"开关
- 开关关闭时显示默认的"AI Assistant"和"用户"
- 修复保存后开关状态被重置的问题

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-13 12:10:08 +08:00
bd863f6d38 feat: 优化图片/视频上传和显示功能
- 支持从本地一次选择多个文件上传
- 图片选择器上传完成后自动关闭
- 输入框和用户消息块显示缩略图(60x60px)而非文件名
- 输入框缩略图悬停时显示删除按钮(右上角 × 符号)
- 统一图片/视频预览样式,提升用户体验

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-13 11:40:54 +08:00
cd3f07bcc8 fix: enrich sub-agent results 2026-03-11 18:05:01 +08:00
ed82fc966e fix: improve sub-agent ui and state 2026-03-11 15:40:28 +08:00
f09621fd86 feat: 为子智能体添加思考模式参数
- 新增 thinking_mode 参数(fast/thinking),支持根据任务复杂度选择模式
- 优化子智能体工具说明,提供详细的使用场景示例
- 增强子智能体状态展示,添加统计信息摘要
- 完善交付目录验证,要求必须为不存在的新目录
- 优化子智能体完成/超时/失败的消息格式
- 同步更新前端和批处理相关代码

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-11 03:34:20 +08:00
b68dee9d98 chore: snapshot current changes 2026-03-10 23:48:40 +08:00
e395c82a9f fix: 优化对话压缩和复制功能
- 隐藏前端系统消息块显示
- 修复压缩对话后自动跳转到新对话
- 压缩对话标题改为"原标题 压缩后"
- 复制对话标题改为"原标题 的副本"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-09 17:59:53 +08:00
bc9a0ed2d7 chore: 添加 .venv 到 .gitignore 2026-03-09 17:00:43 +08:00
a4d3160b0a fix: 修复页面加载时出现两次动画的问题
问题原因:
- Socket 事件(conversation_changed, status_update 等)在初始化期间与 bootstrapRoute 并发执行
- loadConversationsList 在初始化期间自动加载第一个对话
- 导致 currentConversationId 被多次设置,触发多次历史加载和动画

解决方案:
- 在 Socket 事件处理中添加 initialRouteResolved 检查
- 初始化完成前,Socket 事件不修改 currentConversationId
- loadConversationsList 在初始化完成前不自动加载对话
- 确保所有数据(历史、文件树、思考模式等)在同一时间加载完成

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-09 16:59:56 +08:00
cd68812743 fix: 修复页面刷新时思考块自动展开的问题
- 在历史加载时给思考块设置 collapsed: true 默认折叠
- 在任务恢复时跳过思考块的展开/折叠动画
- 延迟清除 _rebuildingFromScratch 标记,确保所有历史事件处理完毕
- 删除过早清除重建标记的逻辑,避免后续思考块被展开

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-09 16:31:00 +08:00
d71525a3c6 feat: add personal usage stats 2026-03-09 12:03:47 +08:00
77b96623ac feat: 优化手机端UI布局和样式
- 手机端对话内容左右边距减小,AI消息更贴近屏幕边缘
- 修复工具intent文本溢出显示省略号,保持箭头和图标位置不变
- 重构手机端左上角菜单为纵向下拉样式,新增"新建对话"选项
- 统一菜单图标大小和线条粗细,支持亮色/暗色主题自动适配
- 修复个人空间弹窗顶部被状态栏遮挡问题

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-09 00:20:47 +08:00
43409c523e fix: 移除错误的对话切换跳转逻辑并修复工具执行返回值问题
主要修复:
1. 移除前端"取消跳转到正在运行的对话"的错误逻辑
   - 删除 switchConversation 中的任务检查和确认提示
   - 删除 createNewConversation 中的跳转回运行对话逻辑
   - 删除 loadConversation 中对未定义变量 hasActiveTask 的引用

2. 修复后端工具执行返回值问题
   - 修复 execute_tool_calls 在用户停止时返回 None 的 bug
   - 确保所有返回路径都返回包含 stopped 和 last_tool_call_time 的字典

3. 其他改进
   - 添加代码复制功能 (handleCopyCodeClick)
   - 移除 FocusPanel 相关代码
   - 更新个性化配置 (enhanced_tool_display)
   - 样式和主题优化

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 17:42:07 +08:00
5ce21eb280 修复手机端个人空间选项卡滑动问题
- 为选项卡容器添加 width: 100% 和 max-width: 100% 限制宽度
- 添加 -webkit-overflow-scrolling: touch 启用 iOS 平滑滚动
- 添加 touch-action: pan-x 明确允许横向触摸滚动
- 添加 scroll-behavior: smooth 实现平滑滚动效果
- 添加 overscroll-behavior-x: contain 防止滚动溢出

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 04:52:30 +08:00
823b1e105e feat: implement graceful tool cancellation on stop request
- Add stop flag monitoring loop (checks every 100ms during tool execution)
- Cancel tool task immediately when stop flag is detected
- Return cancellation message to conversation history with role=tool
- Save cancellation result: '命令执行被用户取消'
- Clean up pending tasks to prevent 'Task was destroyed but it is pending' warnings
- Fix terminal_ops.py to properly cancel stdout/stderr read tasks

Known issue: Tool result display in frontend still shows arguments instead of cancellation message when expanded

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 04:12:50 +08:00
07be7a1061 feat: gracefully stop tool execution on user request
- Remove direct task.cancel() calls, use stop flag instead
- Monitor stop flag every 100ms during tool execution
- Cancel tool task immediately when stop flag is detected
- Return "命令执行被用户取消" as tool result with role=tool
- Save cancellation result to conversation history
- Prevent abrupt task termination, allow graceful shutdown

Changes:
- server/socket_handlers.py: Comment out pending_task.cancel()
- server/tasks.py: Comment out entry['task'].cancel()
- server/chat_flow_tool_loop.py: Add stop flag monitoring loop

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 03:50:34 +08:00
141f6116fd perf: increase conversation search batch size
- Increase initial search batch from 100 to 5000
- Increase load more batch from 50 to 200
- Raise backend API limit from 100 to 10000
- Improve search performance for large conversation lists

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 03:32:43 +08:00
0e4f625338 feat: add task confirmation when switching conversations
- Prompt user to confirm when switching/creating conversation with active task
- Automatically stop running task after user confirmation
- Filter out events from previous conversation to prevent cross-talk
- Show toast notification after task is stopped

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 03:32:35 +08:00
801d20591c feat: 实现 REST API + 轮询模式,支持页面刷新后任务继续执行
主要改进:
- 新增 REST API 任务管理接口 (/api/tasks)
- 实现 150ms 轮询机制,提供流畅的流式输出体验
- 支持页面刷新后自动恢复任务状态
- WebSocket 断开时检测 REST API 任务,避免误停止
- 修复堆叠块融合问题,刷新后内容正确合并
- 修复思考块展开/折叠逻辑,只展开正在流式输出的块
- 修复工具块重复显示问题,通过注册机制实现状态更新
- 修复历史不完整导致内容丢失的问题
- 新增 tool_intent 事件处理,支持打字机效果显示
- 修复对话列表排序时 None 值比较错误

技术细节:
- 前端:新增 taskPolling.ts 和 task store 处理轮询逻辑
- 后端:TaskManager 管理任务生命周期和事件存储
- 状态恢复:智能判断是否需要从头重建,避免内容重复
- 工具块注册:恢复时注册到 toolActionIndex,支持状态更新
- Intent 显示:0.5-1秒打字机效果,历史加载直接显示

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 03:12:46 +08:00
463d89f295 fix: review filename sanitize and tool output 2026-03-08 00:03:28 +08:00
66b846ee37 refactor: split frontend app modules 2026-03-08 00:03:14 +08:00
5e768a9e41 refactor: split chat flow streaming loop 2026-03-07 21:21:14 +08:00
7f6a8d8511 refactor: extract tool execution loop from chat task main 2026-03-07 20:41:10 +08:00
3402375710 refactor: split pending writes and task support from chat task main 2026-03-07 20:37:58 +08:00
8ecfac0c06 refactor: isolate chat task main pipeline module 2026-03-07 20:32:02 +08:00
63e367a996 refactor: further split runner and tools mixins 2026-03-07 20:25:58 +08:00
067500b163 chore: remove obsolete segmented server snapshot files 2026-03-07 18:45:45 +08:00
5c92f93e8c chore: add smoke checks and refactor notes 2026-03-07 18:42:25 +08:00