Skip to content

fix: deduplicate URL balloon messages in watch stream#64

Open
lesaai wants to merge 1 commit intosteipete:mainfrom
wipcomputer:lesa/dedup-url-balloon-messages
Open

fix: deduplicate URL balloon messages in watch stream#64
lesaai wants to merge 1 commit intosteipete:mainfrom
wipcomputer:lesa/dedup-url-balloon-messages

Conversation

@lesaai
Copy link

@lesaai lesaai commented Feb 25, 2026

Problem

iMessage writes multiple rows to chat.db for the same URL when the rich link preview resolves. Both rows have balloon_bundle_id set to com.apple.messages.URLBalloonProvider with identical text and sender but different ROWIDs and timestamps (typically 30-65 seconds apart).

This causes downstream consumers (like OpenClaw) to process the same URL message twice, burning tokens and producing duplicate responses.

Evidence from chat.db

4288|https://x.com/jakemclain_|com.apple.messages.URLBalloonProvider|793745478010970112
4290|https://x.com/jakemclain_|com.apple.messages.URLBalloonProvider|793745543638053888

Same sender, same text, same balloon type — two separate ROWIDs.

Fix

In messagesAfter(), add m.balloon_bundle_id to the SELECT query and deduplicate URL balloon messages with the same (sender, text) within a batch. The first occurrence is kept; subsequent duplicates are skipped.

Impact

  • Only affects messagesAfter() (used by watch command)
  • Only deduplicates messages with balloon_bundle_id = 'com.apple.messages.URLBalloonProvider'
  • No impact on non-URL messages
  • Build passes cleanly

iMessage writes multiple rows to chat.db for the same URL when the rich
link preview resolves. Both rows have balloon_bundle_id set to
'com.apple.messages.URLBalloonProvider' with identical text and sender
but different ROWIDs and timestamps.

This causes downstream consumers (like OpenClaw) to process the same
URL message twice, burning tokens and producing duplicate responses.

Fix: in messagesAfter(), track seen (sender, text) pairs for URL balloon
messages and skip duplicates within the same batch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant