fix(settings): 统一模型路由连通性检查状态管理,消除重复探针 - #142
Open
hllshiro wants to merge 2 commits into
Open
Conversation
…ntroller 统一状态机(idle/running/done),single-flight 并发去重, 配置指纹缓存(force 可绕过),全失败不更新指纹 - connectivity.ts:抽取导出 runModelRoutesProbe,testModelRoutes 保留为兼容薄封装 - 路由:POST /model-routes/connectivity 接受 { force },新增 GET .../status - 前端:useModelRouteCheck 统一 Hook(进入页面零探针,running 轮询 2s); ModelRoutesPage / SettingsOverviewPage 接入;ReadinessCard 增加未检测状态
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.
摘要
修复模型路由连通性检查(model route connectivity check)在页面挂载时被过度触发的问题。引入统一状态管理:后端 single-flight 状态机 + 配置指纹缓存,前端统一 Hook,消除对本地推理服务的"探针风暴"。
问题背景
进入
/settings或/settings/models页面时,连通性检查被重复触发,对本地推理服务(如 LM Studio)产生大量探针请求:ModelRoutesPage.tsx的 React Query 查询未设置staleTime(默认 0),每次组件挂载都会全量重取;testModelRoutes()每次请求都执行全部路由 ×(普通 + 结构化)探针,单次全量检查受推理模型响应速度影响,耗时可达 100 秒以上。方案设计
统一状态管理,满足三条约束:
force参数);完全失败的结果不写入缓存。改动内容
后端(server)
src/llm/checkController.ts(新增)idle → running → done);single-flight 并发去重;配置指纹缓存(force可绕过,全部失败不更新指纹);进程重启状态重置src/llm/connectivity.tsrunModelRoutesProbe;testModelRoutes保留为兼容薄封装src/routes/llm.ts/model-routes/connectivity接受{ force };新增 GET/model-routes/connectivity/status前端(client)
src/hooks/useModelRouteCheck.ts(新增)running时 2s 轮询src/api/settings.tstestModelRouteConnectivity({ force })与getModelRouteConnectivityStatus()src/pages/settings/ModelRoutesPage.tsxsrc/pages/settings/views/SettingsOverviewPage.tsxsrc/pages/settings/components/SettingsReadinessCard.tsx行为变化
/settings或/settings/modelstaskId,不重复执行cached: true)force)验证
tsc --noEmit+vite build通过;后端tsc --noEmit零新增错误(仅剩上游基线自带 4 处 pre-existing 类型错误);idle(零探针);触发返回running+taskId;并发 /force重复触发返回同一taskId;11 条路由检测完成(全部成功)后再次触发返回cached: true复用结果。关联文档
docs/plans/model-route-connectivity-check-unified-state-plan.md