fix: preserve text in Lark mixed messages (#9841)

Copy non-empty buffered text elements before clearing them when an image is inserted, and avoid emitting empty blocks for image-first messages.

Co-authored-by: liruihan <liruihan@example.com>
This commit is contained in:
Ruihan Li
2026-08-31 09:16:49 +08:00
committed by GitHub
co-authored by liruihan
parent b0f2f90a83
commit e17f5688f4
@@ -239,9 +239,10 @@ class LarkMessageEvent(AstrMessageEvent):
image_key = response.data.image_key
logger.debug(image_key)
ret.append(_stage)
if _stage:
ret.append(_stage.copy())
_stage.clear()
ret.append([{"tag": "img", "image_key": image_key}])
_stage.clear()
elif isinstance(comp, File):
# 文件将通过 _send_file_message 方法单独发送,这里跳过
logger.debug("[Lark] 检测到文件组件,将单独发送")