fix(weixin): wait for gemini tool continuations#1946
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72099cd0e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| stream.finishTimer = setTimeout(() => { | ||
| if (this.activeStreams.get(conversationId) === stream) { | ||
| this.resolveStream(conversationId, stream); |
There was a problem hiding this comment.
Settle superseded streams during continuation wait
When a finish arrives after a tool_group, this path defers resolution for 15s; if another message for the same conversation starts in that window, sendMessage replaces activeStreams with a new entry, and this guard skips resolving the old stream forever. That leaves the first sendMessage() promise permanently pending (no resolve/reject path), which can stall downstream cleanup in callers that still await it (for example, overlapping channel chats with supersede behavior).
Useful? React with 👍 / 👎.
CI 检查未通过以下 job 在本次自动化 review 时未通过,请修复:
本次自动化 review 暂缓,待 CI 全部通过后将重新处理。 |
Code Review:fix(weixin): wait for gemini tool continuations (#1946)变更概述本 PR 修复了 WeChat channel 与 Gemini agent 集成时的一个时序问题:当 Gemini 在 方案评估结论:✅ 方案合理 方案通过跟踪最后一个可见消息类型( 问题清单🔵 LOW — 缺少超时兜底路径的测试覆盖文件: 问题代码: stream.finishTimer = setTimeout(() => {
if (this.activeStreams.get(conversationId) === stream) {
this.resolveStream(conversationId, stream);
}
}, TOOL_CONTINUATION_WAIT_MS);问题说明:Codecov 报告本次 patch 覆盖率为 73.91%(5 行 missing,1 行 partial)。核心场景——当 Gemini 确实在 修复建议:补充一个测试用例,验证超时兜底行为: it('resolves via timeout when no continuation arrives after a tool-only finish', async () => {
const service = new ChannelMessageService() as any;
const resolve = vi.fn();
const reject = vi.fn();
service.activeStreams.set('conv-4', {
msgId: 'msg-4',
callback: vi.fn(),
buffer: '',
resolve,
reject,
turnCount: 0,
finishCount: 0,
lastVisibleMessageType: undefined,
finishTimer: undefined,
});
service.handleAgentMessage({ conversation_id: 'conv-4', type: 'start', msg_id: 'msg-4', data: '' });
service.handleAgentMessage({ conversation_id: 'conv-4', type: 'tool_group', msg_id: 'msg-4', data: [] });
service.handleAgentMessage({ conversation_id: 'conv-4', type: 'finish', msg_id: 'msg-4', data: '' });
expect(resolve).not.toHaveBeenCalled();
await vi.advanceTimersByTimeAsync(15_000);
expect(resolve).toHaveBeenCalledWith('msg-4');
});🔵 LOW —
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🔵 LOW | ChannelMessageService.ts:134-138 |
缺少超时兜底路径的测试覆盖 |
| 2 | 🔵 LOW | ChannelMessageService.ts:40 |
15 秒等待常量对实时消息场景偏长 |
结论
✅ 批准合并 — 无阻塞性问题
方案设计正确,代码质量良好,主要测试场景覆盖到位。两个 LOW 级别问题均不阻塞合并,建议后续跟进补充超时兜底测试。
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
Summary
Testing