fix: 尾部内容也检查时间戳过期 — 修复OCR拼凑历史消息触发查库

问题:OCR读屏文本含多个时间戳(17:49:58, 8:33:06, 21:56:17),
中间碎片因last_ts过期被正确跳过,但尾部(最后时间戳之后的内容)
被无条件放行→历史消息内容绕过时间戳过滤→触发查库→自动回复。

根因:尾部逻辑注释说'可能来自新消息'无条件放行,
但21:56:17清晰可见且已过期(差47min=2820s≥300s),
尾部内容也是历史消息。

修复:尾部增加 last_ts 年龄检查,若最后可见时间戳已过期(≥300s),
尾部内容也跳过不处理。
This commit is contained in:
youpaishidifu
2026-07-30 22:50:33 +08:00
parent 5e86ef3c67
commit 664d02ac55
+5 -4
View File
@@ -1591,10 +1591,11 @@ class MessageMonitor:
else:
buf += part
if buf.strip():
# 尾部不需要检查 last_ts 年龄:尾部是最后一个时间戳之后的内容,
# 它可能来自新消息(时间戳因窗口滚动不可见),
# 不应以前一个消息的时间戳来判断是否过期。
if self._is_markdown_document(buf.strip()):
# 尾部检查:如果最后一个可见时间戳已过期(≥300s),尾部内容也是历史消息
# 注释:21:56:17清晰可见但已过期 → 尾部内容不应被当成新消息
if last_ts and self._is_timestamp_old(last_ts, 300):
logger.debug(f"[ocr] stage[{i}] 尾部时间戳{last_ts}已过期(≥{300}s),跳过尾部: {buf.strip()[:60]!r}")
elif self._is_markdown_document(buf.strip()):
extracted = self._extract_user_text_from_md_fragment(buf.strip())
for e in extracted:
if e: