NayukiChiba
c93bedf04d
fix: unify handling of whitespace in streamed message segments and ensure trailing buffers are stripped before sending. (#9029)
* perf(streaming): 将流式消息分段发送的空白过滤逻辑前移至核心方法
- 在 AstrMessageEvent 的 process_buffer 中统一进行 strip 并跳过空段,移除各平台子类的重复处理
- aiocqhttp 平台回退尾部 buffer 直接使用核心逻辑过滤,避免自身再次判断空白
- 简化流式消息发送链路,提升代码可维护性与执行效率
* test(strip-stream): 添加流式消息分段空白过滤的单元测试
- 新增 CollectingMessageEvent 与 CollectingAiocqhttpMessageEvent 辅助类,模拟消息发送与断言
- 覆盖 AstrMessageEvent.process_buffer 对段落前导空白行的 strip 和空段跳过逻辑
- 覆盖 AiocqhttpMessageEvent.send_streaming 回退缓冲区的空白过滤,确保跨平台行为一致
* fix(streaming): 调整流式消息分段发送限速等待位置
- 将限速等待(sleep)从循环末尾移动至消息发送成功后立即执行
- 仅在成功发送文本片段时才进行等待,避免无实际发送时的无谓延迟
- 修复因等待时机不当可能导致的流式消息发送频率异常问题
* test(strip-stream): 添加空白分段时跳过睡眠的单元测试
- 新增测试用例,验证当分段为空时不调用睡眠函数
- 确保处理缓冲区时正确剥离空白字符
- 测试通过验证发送消息的行为
* Delete tests/test_streaming_segment_strip.py
---------
Co-authored-by: Weilong Liao <37870767+Soulter@users.noreply.github.com>
2026-06-26 22:11:31 +08:00
..
2026-06-24 22:44:45 +08:00
2026-06-10 16:51:29 +08:00
2026-06-17 22:25:51 +09:00
2026-06-24 23:44:15 +08:00
2026-06-24 16:22:58 +08:00
2026-06-17 11:08:46 +08:00
2026-06-07 10:50:33 +08:00
2026-06-15 08:44:23 +08:00
2026-06-25 16:17:07 +08:00
2026-06-26 22:11:31 +08:00
2026-06-25 16:18:04 +08:00
2026-06-19 12:03:07 +08:00
2026-06-16 12:37:50 +08:00
2026-06-24 15:53:47 +08:00
2026-06-26 11:27:32 +08:00
2026-03-11 14:21:55 +09:00
2026-06-07 12:23:03 +08:00
2026-06-14 10:37:16 +08:00
2026-06-18 23:15:25 +08:00
2026-05-03 14:37:37 +08:00
2026-06-24 15:53:47 +08:00
2026-06-08 11:00:26 +08:00
2026-06-07 10:52:11 +08:00
2026-04-14 16:27:06 +08:00
2026-06-14 10:37:16 +08:00
2026-05-05 21:16:53 +08:00
2026-04-22 11:51:12 +08:00
2026-03-17 15:42:15 +08:00
2026-06-05 19:09:48 +08:00
2026-03-16 12:34:21 +08:00
2026-06-19 12:44:31 +08:00
2026-05-14 00:40:24 +08:00