fix: 灵感助手 AI 断连/报错时增加错误感知与自动重试 - #174
Open
zhiwu215 wants to merge 1 commit into
Open
Conversation
- 新增流停滞看门狗,超时无输出自动中止并通知 - 错误卡片 UI 展示失败原因,支持一键重试 - LLM 连接级自动重试(网络抖动/5xx 等瞬时错误) - 失败时播放降调提示音,与完成音区分 - 桌面通知策略改为三档(关闭/仅失败/全部)
Owner
|
感谢贡献,这个改动比较多,晚点我再看看 |
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.
Related #171
改动概述
文件改动说明
后端
backend/app/services/ai/core/chat_model_factory.py— 新增LLM_CONNECT_MAX_RETRIES常量定义(唯一来源);build_chat_model系列函数新增max_retries参数透传backend/app/services/ai/assistant/assistant_service.py— 删除本地重复常量,改为从chat_model_factoryimport;stream_chat_plain传入max_retriesbackend/app/services/ai/core/react_text_agent.py— 同上,删除重复常量;stream_chat_with_react_protocol传入max_retriesbackend/app/services/ai/core/tool_agent_stream.py— 同上,删除重复常量;stream_agent_with_tools传入max_retries前端 — 核心逻辑
frontend/.../utils/taskDoneNotifier.ts— 共享 AudioContext 避免重复创建;新增失败降调提示音;抽取_dispatchNotification消除notifyTaskDone/notifyTaskFailed重复逻辑;新增DesktopNotificationMode三档类型;删除冗余TaskFailedNotifyOptions别名frontend/.../composables/useAgentPreferences.ts— 新增taskDoneDesktopNotificationMode偏好项(none/failed_only/all)及其读写/持久化逻辑,兼容旧taskDoneDesktopNotificationEnabled布尔值frontend/.../composables/useAssistantStreamMessageOps.ts—error事件处理改为设置msg.error字段(取代toolsInProgress拼接 emoji);重新生成时清除errorfrontend/.../composables/agentChatEvents.ts— 工具调用进度文本移除 emoji 前缀前端 — 组件
frontend/.../components/assistants/AssistantPanel.vue— 新增流停滞看门狗(armStreamStallWatchdog/disarmStreamStallWatchdog);新增handleStreamFailure统一错误处理;提取buildNotifyOptions辅助函数精简通知传参;onClose 区分完成/失败通知frontend/.../components/shared/AgentMessageList.vue— 新增错误卡片 UI(.msg-error-card)含失败原因与重试按钮;空内容失败消息保留操作栏;工具状态文本移除 emojifrontend/.../components/setting/AssistantSettings.vue— 桌面通知设置从开关改为三档 radio-group;提示音说明文案补充失败场景frontend/.../components/editors/CodeMirrorEditor.vue— 通知调用补充desktopNotificationMode参数前端 — 类型
frontend/.../types/agentChat.ts—AgentChatMessage新增error?: string字段frontend/.../types/assistantPanel.ts—AssistantPanelMessage新增error?: string字段验证