fix(cli): derive thread root from parent event tags#564
Merged
Conversation
`send-message` and `send-diff-message` previously assigned `--reply-to` to both `root_event_id` and `parent_event_id` of the `ThreadRef`. For any reply below the top level this produces an invalid NIP-10 thread: the relay rejects the event as `root tag does not match thread ancestry`, and replies that do land are flat-threaded off the wrong root. Port `sprout-mcp`'s `resolve_thread_ref` into the CLI: fetch the parent event, read its NIP-10 `e`-tag markers, and derive the thread root. Direct replies still land with `root == parent`; nested replies use the parent's own root marker. `--reply-to` retains its 'immediate parent' semantics, so no flag surface changes. `find_root_from_tags` defensively ignores malformed marker IDs so a bad tag on the parent event can't block a reply. Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
send-messageandsend-diff-messageset bothroot_event_idandparent_event_idof the NIP-10ThreadRefto the value of--reply-to. Any reply below the top level is malformed: the relay rejects it withroot tag does not match thread ancestry, and replies that do land thread off the wrong root.Port
sprout-mcp'sresolve_thread_refinto the CLI.--reply-toretains its 'immediate parent' semantics; the thread root is derived by fetching the parent event and reading its NIP-10e-tag markers. Direct replies still land withroot == parent; nested replies use the parent's own root marker.find_root_from_tagsignores malformed marker IDs so a bad tag on the parent event can't block a reply (fall back toroot == parent).Unit tests cover root/reply marker precedence, reply-only fallback, missing markers, malformed tags, and malformed marker IDs.