fix: track original message for quick-complete, not bot reply#11
fix: track original message for quick-complete, not bot reply#11devonjones merged 1 commit intomainfrom
Conversation
Users expect to click the ✅ that's already on their original message (which the bot adds), not on the bot's confirmation reply. Changes: - Track original user message ID instead of bot reply message ID - Remove restriction that reactions must be on bot messages - Simplified logic - no need to fetch referenced message - Only allow message author to quick-complete their own captures UX improvement: More intuitive - click the check on your message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary of ChangesHello @devonjones, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the user experience for the quick-complete feature by shifting the interaction point from the bot's confirmation message to the user's original message. This change streamlines the process, making it more natural for users to complete their captures by reacting to their own content. It also simplifies the underlying code by removing unnecessary message reference lookups and clarifies permissions by ensuring only the message author can trigger a quick-complete. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the user experience for the quick-complete feature by tracking the original user message instead of the bot's reply. The changes simplify the logic, remove the need to fetch message references, and enhance code clarity. The implementation is solid and correctly achieves its goal. I have one suggestion to further improve the robustness of the reaction handling logic by making an implicit assumption explicit.
| if entry_id: | ||
| # Only handle ✅ for quick-complete on capture messages | ||
| if emoji != "✅": | ||
| logger.debug(f"Ignoring {emoji} on capture message (only ✅ supported)") | ||
| return | ||
|
|
||
| # Get the original message to verify the user is the author | ||
| try: | ||
| # The capture confirmation is a reply, so we can get the referenced message | ||
| if not reaction.message.reference or not reaction.message.reference.message_id: | ||
| logger.warning(f"Capture message {message_id} has no reference to original") | ||
| return | ||
|
|
||
| original_message = await reaction.message.channel.fetch_message( | ||
| reaction.message.reference.message_id | ||
| # Only allow the original message author to quick-complete | ||
| if user.id != reaction.message.author.id: | ||
| logger.debug( | ||
| f"User {user} tried to complete entry {entry_id} but is not original author" | ||
| ) | ||
| return | ||
|
|
||
| # Only allow the original author to quick-complete | ||
| if user.id != original_message.author.id: | ||
| logger.debug( | ||
| f"User {user} tried to complete entry {entry_id} but is not original author" | ||
| ) | ||
| return | ||
|
|
||
| logger.info( | ||
| f"Quick-complete: {user} archiving entry {entry_id} (message {message_id})" | ||
| ) | ||
| logger.info( | ||
| f"Quick-complete: {user} archiving entry {entry_id} (message {message_id})" | ||
| ) | ||
|
|
||
| try: | ||
| # Archive the entry using shared handler | ||
| await self.handle_archive_entry(reaction, user, entry_id, source="capture") | ||
|
|
||
| except discord.NotFound: | ||
| logger.warning(f"Could not find original message for capture confirmation {message_id}") | ||
| except Exception as e: | ||
| logger.error(f"Error handling quick-complete: {e}", exc_info=True) | ||
| ERRORS.labels(service="reflex", error_type="reaction_handler").inc() |
There was a problem hiding this comment.
For improved robustness, it would be beneficial to add a guard clause here to ensure that messages being processed as 'captures' are not from the bot itself. While other parts of the code currently prevent bot message IDs from being added to capture_message_to_entry, making this assumption explicit within this handler makes the function more self-contained and resilient to future changes. This also makes the separation of concerns between handling digest reactions (on bot messages) and capture reactions (on user messages) clearer.
if entry_id:
# This logic is for user messages. A bot message should not be in capture tracking.
if reaction.message.author == self.user:
logger.warning(f"Bot message {message_id} incorrectly found in capture tracking.")
return
# Only handle ✅ for quick-complete on capture messages
if emoji != "✅":
logger.debug(f"Ignoring {emoji} on capture message (only ✅ supported)")
return
# Only allow the original message author to quick-complete
if user.id != reaction.message.author.id:
logger.debug(
f"User {user} tried to complete entry {entry_id} but is not original author"
)
return
logger.info(
f"Quick-complete: {user} archiving entry {entry_id} (message {message_id})"
)
try:
# Archive the entry using shared handler
await self.handle_archive_entry(reaction, user, entry_id, source="capture")
except Exception as e:
logger.error(f"Error handling quick-complete: {e}", exc_info=True)
ERRORS.labels(service="reflex", error_type="reaction_handler").inc()
Fixes the UX for quick-complete feature - users now click ✅ on their own message (where the bot already added the reaction) instead of on the bot's reply.
Changes:
UX improvement: More intuitive - click the checkmark that's already on your message.