From fef5ae7626d848d21c14f07598b21713011ba8c5 Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Wed, 8 Jul 2026 14:33:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20P0=20=E7=BA=A7?= =?UTF-8?q?=E6=8A=80=E6=9C=AF=E5=80=BA=EF=BC=88useEffect=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E9=A1=B9=E7=BC=BA=E5=A4=B1=20+=20prompt=20=E6=B3=A8?= =?UTF-8?q?=E5=85=A5=E5=90=9E=E9=94=99=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P0-1: web/src/App.tsx 话题刷新 useEffect 依赖项不完整 - 原依赖数组仅 [topicRefreshTrigger],但 effect 体内使用了 status/handleCommand/sendMessage/requestTopicList - 导致断线重连后 status 从 disconnected→connected 时 effect 不会重新运行,话题刷新被静默丢失(stale closure bug) - 补全依赖数组为 [topicRefreshTrigger, status, handleCommand, sendMessage, requestTopicList],与同文件 200-208 行 effect 风格一致 P0-2: src/gateway/agent_prompt_provider.rs 静默吞错 - record_injection 中 let _ = repository.mark_agent_prompt_reinjected(...) 丢弃了 Result 错误 - 失败时 Agent prompt 注入计数错乱且无任何日志 - 改为 if let Err(e) = ... { tracing::warn!(...) } 记录 session_id 和 error --- src/gateway/agent_prompt_provider.rs | 8 +++++++- web/src/App.tsx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gateway/agent_prompt_provider.rs b/src/gateway/agent_prompt_provider.rs index 3aee796..a678f3e 100644 --- a/src/gateway/agent_prompt_provider.rs +++ b/src/gateway/agent_prompt_provider.rs @@ -43,7 +43,13 @@ impl AgentPromptProvider { /// 记录注入事件 fn record_injection(&self, context: &SystemPromptContext) { if let Some(session_id) = &context.session_id { - let _ = self.repository.mark_agent_prompt_reinjected(session_id); + if let Err(e) = self.repository.mark_agent_prompt_reinjected(session_id) { + tracing::warn!( + session_id = ?session_id, + error = %e, + "Failed to mark agent prompt reinjected; injection counter may be inaccurate" + ); + } } } } diff --git a/web/src/App.tsx b/web/src/App.tsx index 2d85860..a9f9c46 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -220,7 +220,7 @@ function App() { }, 500) return () => clearTimeout(timer) - }, [topicRefreshTrigger]) + }, [topicRefreshTrigger, status, handleCommand, sendMessage, requestTopicList]) // Topics 加载后,自动选择第一个(仅当用户尚未手动选择 topic 时) useEffect(() => {