fix: 日报日期属性移到标题下引用行

This commit is contained in:
Benature
2026-11-22 22:26:31 +08:00
parent 2de88ec003
commit f48ae4f809
3 changed files with 16 additions and 7 deletions

View File

@ -1 +1 @@
0.2.3 0.2.4

View File

@ -1066,7 +1066,10 @@ def summarize_messages(
] ]
day_context = _day_context(target_day) day_context = _day_context(target_day)
if not rows and not calendar_events: if not rows and not calendar_events:
return f"# {target_day.isoformat()} 工作总结({day_context})\n\n本日未收到消息。\n" return (
f"# {target_day.isoformat()} 工作总结\n\n"
f"> {day_context}\n\n本日未收到消息。\n"
)
messages = [serialize_message(row, tz) for row in rows] messages = [serialize_message(row, tz) for row in rows]
groups: dict[str, list[dict[str, Any]]] = {} groups: dict[str, list[dict[str, Any]]] = {}
for message in messages: for message in messages:
@ -1278,13 +1281,17 @@ def summarize_messages(
content = sanitize_wikilink_pipes( content = sanitize_wikilink_pipes(
drop_casual_content(format_followup_checkboxes(shorten_headings(content))) drop_casual_content(format_followup_checkboxes(shorten_headings(content)))
) )
# Prepend day context to the title # Keep day context out of the heading so calendar metadata is easy to hide.
if content.startswith("# "): if content.startswith(f"# {target_day.isoformat()}"):
content = content.replace( lines = content.splitlines()
lines[0] = re.sub(
rf"^# {re.escape(target_day.isoformat())}([^)]*)",
f"# {target_day.isoformat()}", f"# {target_day.isoformat()}",
f"# {target_day.isoformat()}({day_context})", lines[0],
1,
) )
lines.insert(1, "")
lines.insert(2, f"> {day_context}")
content = "\n".join(lines) + ("\n" if content.endswith("\n") else "")
return content return content

View File

@ -140,6 +140,8 @@ def test_system_only_private_chat_does_not_require_a_person_name():
) )
assert "本日未收到消息" in result assert "本日未收到消息" in result
assert result.startswith("# 2026-11-03 工作总结\n\n> 周二,工作日,交易日\n")
assert "工作总结(" not in result
assert session.post_calls == [] assert session.post_calls == []