a digital entity named phi that roams bsky phi.zzstoatzz.io
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fetch thread context for engagement notifications (likes/reposts)

engagement entries were built with empty thread_context, so when the
owner liked a post in a thread about following someone, phi had no way
to connect the like to the pending action. now likes/reposts resolve
thread refs and fetch the full conversation, same as mentions/replies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+28 -4
+28 -4
src/bot/services/message_handler.py
··· 131 131 For these, notification.uri is phi's own post that was engaged with — 132 132 so we fetch it for context but the action target (if phi decides to 133 133 respond) is the engager's profile, not the post. 134 + 135 + Thread context is fetched so phi can understand *what conversation* 136 + the liked post belongs to — a like on an authorization-request post 137 + in a thread about following someone is very different from a like 138 + on a standalone musing. 134 139 """ 135 140 post_uri = notification.uri 136 141 post_text = "" 137 142 cid = "" 143 + root_uri = post_uri 144 + root_cid = "" 145 + thread_uri = post_uri 146 + thread_context = "" 138 147 try: 139 148 posts_resp = await self.client.get_posts([post_uri]) 140 149 if posts_resp.posts: 141 150 p = posts_resp.posts[0] 142 151 post_text = p.record.text if hasattr(p.record, "text") else "" 143 152 cid = p.cid 153 + root_cid = cid 154 + 155 + # resolve thread refs so phi sees the full conversation 156 + if hasattr(p.record, "reply") and p.record.reply: 157 + root_uri = p.record.reply.root.uri 158 + root_cid = p.record.reply.root.cid 159 + thread_uri = root_uri 160 + 161 + try: 162 + thread_data = await self.client.get_thread(thread_uri, depth=100) 163 + thread_context = build_thread_context(thread_data.thread) 164 + except Exception as e: 165 + logger.debug( 166 + f"failed to fetch thread for engaged post {post_uri}: {e}" 167 + ) 144 168 except Exception as e: 145 169 logger.debug(f"failed to fetch engaged post {post_uri}: {e}") 146 170 ··· 153 177 "post_text": post_text, 154 178 "embed_desc": "", 155 179 "image_urls": [], 156 - "root_uri": post_uri, 157 - "root_cid": cid, 158 - "thread_uri": post_uri, 159 - "thread_context": "", 180 + "root_uri": root_uri, 181 + "root_cid": root_cid, 182 + "thread_uri": thread_uri, 183 + "thread_context": thread_context, 160 184 "indexed_at": getattr(notification, "indexed_at", "") or "", 161 185 } 162 186