Skip to content

fix(cli): derive thread root from parent event tags#564

Merged
tlongwell-block merged 1 commit into
mainfrom
fix/cli-thread-root-derivation
May 13, 2026
Merged

fix(cli): derive thread root from parent event tags#564
tlongwell-block merged 1 commit into
mainfrom
fix/cli-thread-root-derivation

Conversation

@tlongwell-block
Copy link
Copy Markdown
Collaborator

send-message and send-diff-message set both root_event_id and parent_event_id of the NIP-10 ThreadRef to the value of --reply-to. Any reply below the top level is malformed: the relay rejects it with root tag does not match thread ancestry, and replies that do land thread off the wrong root.

Port sprout-mcp's resolve_thread_ref into the CLI. --reply-to retains its 'immediate parent' semantics; the thread root is derived by fetching the parent event and reading its NIP-10 e-tag markers. Direct replies still land with root == parent; nested replies use the parent's own root marker.

find_root_from_tags ignores malformed marker IDs so a bad tag on the parent event can't block a reply (fall back to root == parent).

Unit tests cover root/reply marker precedence, reply-only fallback, missing markers, malformed tags, and malformed marker IDs.

`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>
@tlongwell-block tlongwell-block merged commit e427581 into main May 13, 2026
15 checks passed
@tlongwell-block tlongwell-block deleted the fix/cli-thread-root-derivation branch May 13, 2026 13:54
tlongwell-block added a commit that referenced this pull request May 13, 2026
* origin/main:
  chore(acp): raise default idle timeout from 320s to 620s (#566)
  fix(cli): derive thread root from parent event tags (#564)
  fix: skip empty assistant turns instead of placeholder space (#560)

Signed-off-by: Tyler Longwell <109685178+tlongwell-block@users.noreply.github.com>
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.

1 participant