Skip to content

fix(acp): anchor DM thread replies to the thread root, not the latest message#2778

Open
webdevtodayjason wants to merge 1 commit into
block:mainfrom
webdevtodayjason:fix/acp-dm-reply-anchor
Open

fix(acp): anchor DM thread replies to the thread root, not the latest message#2778
webdevtodayjason wants to merge 1 commit into
block:mainfrom
webdevtodayjason:fix/acp-dm-reply-anchor

Conversation

@webdevtodayjason

Copy link
Copy Markdown

Closes #2748.

Problem

In a 1:1 DM with a managed agent, once a thread existed every agent reply anchored to the human's latest comment instead of the thread root — so each exchange nested one level deeper and the user had to click-expand a sub-thread of a sub-thread to follow a simple back-and-forth.

The reply-anchor logic in queue.rs documents the intended rule directly above the code ("in a thread → anchor to the thread ROOT, no depth-2 nesting") and the group-channel path (resolve_reply_anchor) implements it — but the DM branch contradicted it, anchoring to last_event.event.id (the newest message) rather than the thread root.

Fix

One-line root cause: in the is_dm branch, anchor to thread_tags.root_event_id when inside a thread — matching the documented layer-1 rule and the group-channel behavior. Top-level DM exchanges stay flat (anchor to the triggering event as before).

Tests

  • A DM reply inside a thread now anchors to root_event_id, not the latest event id (new regression test).
  • Corrected one pre-existing test that pinned the old buggy behavior; added coverage for the top-level (flat) case.
  • Full gate green: cargo test -p buzz-acp → all pass, clippy → 0 warnings.

Sibling PR: the DM mention-gate fix (#2747) is up alongside this.

Checklist

  • cargo test -p buzz-acp + clippy green
  • Bug fix includes regression tests
  • No new unwrap() in production paths
  • No new unsafe

… message

In a 1:1 DM, once a thread existed every agent reply anchored to the
human's latest comment (`last_event.event.id`) instead of the thread
root, so each exchange nested one level deeper — the user had to
expand a sub-thread of a sub-thread to follow a simple back-and-forth.

`resolve_reply_anchor` already implements the documented layer-1 rule
for group channels (in a thread → anchor to the ROOT). Apply the same
rule to DMs by anchoring to `thread_tags.root_event_id`, which is
`Some` only inside a thread — so top-level DM exchanges stay flat,
preserving existing behaviour.

Also corrects `test_reply_instruction_present_for_dm_thread_reply`,
which pinned the old anchor-to-latest behaviour, and adds regression
coverage for both the in-thread (root-anchored) and top-level (flat)
DM cases.

Fixes block#2748.

Signed-off-by: webdevtodayjason <jason@webdevtoday.com>
@webdevtodayjason
webdevtodayjason requested a review from a team as a code owner July 24, 2026 22:37
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.

buzz-acp: DM replies anchor to the latest message instead of the thread root — every exchange nests one level deeper

1 participant