Fix/pi typeahead busy#235
Open
Hellovolcanoone wants to merge 8 commits into
Open
Conversation
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.
◆ 修复描述
修复新版 Pi 在 botmux 中偶发卡在 Pi is busy 的问题。
新版 Pi 在完成一轮回复后,botmux 的 idle/prompt 检测可能没有识别到它已经回到可输入状态,导致后续飞书消息虽然已经被 botmux 收到并路由到同一个 session,但一直停留在 pending queue
中,日志表现为:
Queued message (...) — Pi is busy
本次将 Pi adapter 标记为支持 type-ahead:
supportsTypeAhead: true
这样当 botmux 没有及时识别到 Pi idle 时,仍可把后续消息写入 Pi TUI,由 Pi 自己排队处理,避免消息长期卡住。
同时补充了 write-input 单测:
将 Pi 纳入 paste-buffer 输入路径覆盖
断言 Pi adapter 的 supportsTypeAhead 为 true
验证:
pnpm vitest run test/write-input.test.ts 通过
pnpm build 通过
本地安装并重启 botmux 后,运行态日志确认后续 PI 消息已进入 Writing to PTY / Writing to PTY (flush),不再卡在 Pi is busy 队列中。
新增优化逻辑:
如果消息还没有被 flush 到 PTY,且此时 CLI 仍 busy / still booting,新来的增量消息会合并到 pending queue 尾部。
等后续 flush 时,只写一次 PTY,内容用空行拼接。
正在 flush 或可以立即写入 PTY 的场景保持原行为,不合并,避免影响正在发送中的输入。
验证已通过:
pnpm vitest run test/worker-queue-merge.test.ts test/input-gate.test.ts test/write-input.test.ts
pnpm build