Skip to content

Commit 801ef73

Browse files
committed
extend to add all reactions to the review context
1 parent 548971f commit 801ef73

3 files changed

Lines changed: 66 additions & 11 deletions

File tree

claudecode/format_pr_comments.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
# Bot comment marker pattern
1515
BOT_COMMENT_MARKER = "🤖 **Code Review Finding:"
1616

17+
# GitHub reaction content to emoji mapping
18+
REACTION_EMOJI_MAP = {
19+
'+1': '👍',
20+
'-1': '👎',
21+
'laugh': '😄',
22+
'confused': '😕',
23+
'heart': '❤️',
24+
'hooray': '🎉',
25+
'rocket': '🚀',
26+
'eyes': '👀',
27+
}
28+
1729

1830
def is_bot_comment(comment: Dict[str, Any]) -> bool:
1931
"""Check if a comment was posted by this bot.
@@ -223,17 +235,11 @@ def _format_threads_for_prompt(threads: List[Dict[str, Any]]) -> str:
223235

224236
# Add user reactions (excluding bot's own reactions)
225237
if reactions:
226-
thumbs_up = reactions.get('+1', 0)
227-
thumbs_down = reactions.get('-1', 0)
228-
other_reactions = {k: v for k, v in reactions.items() if k not in ['+1', '-1']}
229-
230238
reaction_parts = []
231-
if thumbs_up > 0:
232-
reaction_parts.append(f"👍 {thumbs_up}")
233-
if thumbs_down > 0:
234-
reaction_parts.append(f"👎 {thumbs_down}")
235-
for reaction, count in other_reactions.items():
236-
reaction_parts.append(f"{reaction} {count}")
239+
for reaction, count in reactions.items():
240+
if count > 0:
241+
emoji = REACTION_EMOJI_MAP.get(reaction, reaction)
242+
reaction_parts.append(f"{emoji} {count}")
237243

238244
if reaction_parts:
239245
lines.append(f" User Reactions: {', '.join(reaction_parts)}")

claudecode/test_format_pr_comments.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,33 @@ def test_reactions_included(self):
146146
# Should show 2 thumbs down
147147
assert "👎 2" in result
148148

149+
def test_all_reaction_types(self):
150+
"""Test that all GitHub reaction types are converted to emojis."""
151+
bot_comment = _make_bot_comment(1)
152+
reactions = {
153+
'+1': 3,
154+
'-1': 1,
155+
'laugh': 2,
156+
'confused': 1,
157+
'heart': 4,
158+
'hooray': 2,
159+
'rocket': 1,
160+
'eyes': 3,
161+
}
162+
threads = [_make_thread(bot_comment, reactions=reactions)]
163+
164+
result = format_pr_comments_for_prompt(threads)
165+
166+
# All reactions should be converted to emojis
167+
assert "👍 3" in result
168+
assert "👎 1" in result
169+
assert "😄 2" in result
170+
assert "😕 1" in result
171+
assert "❤️ 4" in result
172+
assert "🎉 2" in result
173+
assert "🚀 1" in result
174+
assert "👀 3" in result
175+
149176
def test_truncate_long_replies(self):
150177
"""Test that very long reply threads are truncated."""
151178
bot_comment = _make_bot_comment(1)

claudecode/test_workflow_integration.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_full_workflow_with_real_pr_structure(self, mock_get, mock_run):
159159
}
160160
]
161161

162-
# Reactions response for the bot comment - one +1 from a human
162+
# Reactions response for the bot comment - multiple reactions from humans
163163
reactions_response = Mock()
164164
reactions_response.status_code = 200
165165
reactions_response.json.return_value = [
@@ -173,6 +173,28 @@ def test_full_workflow_with_real_pr_structure(self, mock_get, mock_run):
173173
},
174174
'content': '+1',
175175
'created_at': '2024-01-15T14:00:00Z'
176+
},
177+
{
178+
'id': 2,
179+
'node_id': 'MDg6UmVhY3Rpb24y',
180+
'user': {
181+
'login': 'teammate',
182+
'id': 67890,
183+
'type': 'User'
184+
},
185+
'content': 'eyes',
186+
'created_at': '2024-01-15T14:05:00Z'
187+
},
188+
{
189+
'id': 3,
190+
'node_id': 'MDg6UmVhY3Rpb24z',
191+
'user': {
192+
'login': 'lead',
193+
'id': 11111,
194+
'type': 'User'
195+
},
196+
'content': 'rocket',
197+
'created_at': '2024-01-15T14:10:00Z'
176198
}
177199
]
178200

0 commit comments

Comments
 (0)