fix(dm): Wait for msg JSON response and fix unread markers

Monitor: For .msg commands, keep waiting for expected_ack in response
instead of completing on silence timeout. Waits up to half of cmd_timeout
(5s) for the JSON to arrive before giving up.

Unread: Apply 120s time-window dedup to outgoing messages in conversation
listing, so retry messages don't inflate last_message_timestamp and cause
permanent unread markers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-02-25 10:19:28 +01:00
parent 49159a888c
commit c2acbb4ba1
2 changed files with 26 additions and 4 deletions
+14
View File
@@ -582,6 +582,20 @@ def get_dm_conversations(days: Optional[int] = 7) -> List[Dict]:
"""
messages, pubkey_to_name = read_dm_messages(days=days)
# Deduplicate outgoing retry messages: collapse same text+recipient within 120s
deduped = []
seen_outgoing = {} # (recipient, text) -> earliest timestamp
for msg in messages:
if msg.get('direction') == 'outgoing':
key = (msg.get('recipient', ''), msg.get('content', ''))
ts = msg.get('timestamp', 0)
prev_ts = seen_outgoing.get(key)
if prev_ts is not None and abs(ts - prev_ts) < 120:
continue
seen_outgoing[key] = ts
deduped.append(msg)
messages = deduped
# Build reverse mapping: name -> pubkey_prefix
name_to_pubkey = {name: pk for pk, name in pubkey_to_name.items()}