fix: prevent parallel OpenCode conversations from hanging

Starting another conversation could replace a busy local OpenCode server
after a brief health-check failure, leaving the existing conversation
reconnecting to a dead endpoint.

Keep active conversations and native Compact operations on their current
server. Propagate server exit and shutdown to bound requests and cancel
event-stream retry waits so failures are explicit instead of hanging.
Do not automatically replay commands.

Release note: 修复同时使用多个本机 OpenCode 会话时旧会话可能一直等待的问题。服务异常退出时会明确提示失败,不会自动重复执行命令。
This commit is contained in:
mesalogo
2026-09-08 21:10:35 +08:00
parent 28de0c45ba
commit c1f4fd0580
3 changed files with 246 additions and 6 deletions
+7 -3
View File
@@ -46,9 +46,13 @@
## 2026-09-08 OpenCode 复用与原生控件恢复
- `OpenCodeRuntime` 复用缓存的 embedded server 前执行有超时的健康检查;健康则保留
client,检查失败、抛错或超时则清除 client、会话映射、会话初始化及待答问题,关闭旧
server 后重建。并发调用共享检查与重建,调用方取消只结束自身等待。
- `OpenCodeRuntime` 仅在没有活动请求时探测缓存的 embedded server;活动对话或
Compact 期间直接复用服务,避免新会话的一次短探测失败关闭其他会话正在使用的进程。
空闲探测失败时仍清除旧 client 和会话映射并重建;并发调用共享检查与重建。
进程退出或服务关闭会中止绑定它的对话与 Compact,事件流重连等待也可立即取消,
请求明确报错,不自动重放已执行命令。本次修复后的真实模型验证共 6 次:正常并发、
已复现场景下的共享服务保护均正常完成;主动结束测试进程后旧请求明确失败,新请求
在替换服务上完成。此前“新会话完成、旧会话持续等待”的故障不再出现。
- 请求级 MCP 注册与断开通过实例内 `mutateMcp` 队列串行执行。仅实际发出 `mcp.add`
的名称进入清理列表;注册尚在排队时取消不追加断开。断开的 1 秒超时从出队后开始。
- `App` 按本机/远程、连接方式、项目和 Runtime 选择组成 scope 缓存原生清单,用请求