Repository navigation
fix(hosts): reconnect idle SSH hosts during aggregation - #5099
Conversation
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
commit: |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Requirement or Bug
SSH Host 空闲退出后,跨 Host 的项目列表、会话列表和按 ID 查找可能持续漏掉远端数据。Web 和桌面端依赖代理 WebSocket 唤醒远端,首屏查询可能先返回。只轮询列表的 KAP 客户端会持续拿到部分结果。
Bug Reproduction Steps
GET /api/v1/workspaces?hosts=include与GET /api/v1/sessions?hosts=include。项目列表缺少该 Host 的项目,会话列表把它列入unavailable_hosts,而GET /api/v1/hosts仍报告ready。Root Cause
SSH 以退出码 0 结束后,桥接会清空会话连接并保留
ready,等待有请求时再连接。代理请求能触发连接,聚合查询原先只读取现有连接。修复把聚合也接入按需连接。Code Changes
sequenceDiagram participant API as 跨 Host 查询 participant Fanout as Host 聚合 participant SSH as SSH 桥接 API->>Fanout: 读取项目或会话 Fanout->>SSH: 获取会话连接 alt 已连接 SSH-->>Fanout: 返回现有连接 else 先前连接后正常退出 Fanout->>SSH: 按需唤醒,共享在途连接 alt 2 秒内连接成功 SSH-->>Fanout: 返回恢复的连接 else 等待超时或连接失败 Fanout-->>API: 仅使用可用来源 end endsshKapBridge.ts负责识别正常退出的桥接并复用在途连接。hostFanout.ts限定单次等待时间,超时后在途连接仍可以完成。项目列表、会话列表、按 ID 查询远端会话共用这条路径。Behavior Changes and Affected Users
hosts=include的 KAP 客户端。调用方的超时预算可能受冷启动影响hosts=includeHOST_UNAVAILABLE回归覆盖并发项目与会话查询共用一次 SSH 连接,以及慢启动超时后下一次查询能获取远端数据。验证使用模拟 SSH 进程和真实服务端路由。
验证
kap-server全量 1,420 项测试通过。release/2026-11-19基底上,Host 聚合、SSH 桥接、空闲退出和 API 快照共 80 项测试通过,类型检查及改动文件的 lint 通过。Checklist
gen-changesetsskill, or this PR needs no changeset. 按此次发布安排省略 changeset。gen-docsskill, or this PR needs no doc update.