Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

Problem\n- After merging the previous PR, follow-up messages in the same thread were skipped as duplicates.\n- Root cause: the idempotency key (root thread_ts) was used to gate all events in the thread, so once a status row existed, later events (including legitimate replies) failed acquisition and were treated as duplicates.\n\nFix\n- Dedupe ONLY the root message (when event.thread_ts is None).\n - Acquire/mark-completed only for the root.\n - While in progress: edits to the root get a polite "still working" note.\n - After completion: duplicate root deliveries are skipped.\n- Replies (messages with event.thread_ts present) are not gated and are processed normally.\n\nNotes\n- Keeps the tiny SQLite status in _internal/thread_status.\n- Minimal changes to api.py; retains the existing user-facing behavior for edit notices.\n- Lint/format pass.\n\nHappy to adjust behavior if you want replies during in-progress to be queued or coalesced instead of processed immediately.

…e try_acquire/mark_completed only when event is the root (no thread_ts)\n- Prevent 'SKIPPED_DUPLICATE' on legitimate follow-ups in the same thread
Copilot AI review requested due to automatic review settings September 10, 2025 15:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where Slack thread replies were incorrectly being treated as duplicates and skipped after the root message was processed. The fix modifies the deduplication logic to only gate root messages while allowing replies to be processed normally.

  • Modified deduplication to only apply to root messages (when event.thread_ts is None)
  • Added conditional logic to only acquire/mark completion for root messages
  • Updated error messages to clarify they apply specifically to root events

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

except Exception:
logger.warning("Failed to mark thread as completed")
# Only mark completion for the root message; do not block replies
if "is_root_message" in locals() and is_root_message:
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'is_root_message' in locals() is fragile and could break if the variable declaration is moved. Consider restructuring the code to avoid this check, perhaps by moving the completion logic inside the if is_root_message: block or using a different approach to track whether completion is needed.

Copilot uses AI. Check for mistakes.
@zzstoatzz zzstoatzz merged commit 05a699a into main Sep 10, 2025
3 checks passed
@zzstoatzz zzstoatzz deleted the fix/slackbot-dedupe-only-root branch September 10, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants