Files
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dandTyler Longwell 7d2687b63b perf(desktop): skip pre-send parent fetch on reply when thread root is cached
Every reply paid a full relay round trip before send: resolve_thread_ref
fetched the parent event just to walk its NIP-10 e-tags for the thread
root — data the frontend timeline cache almost always already has.

send_channel_message grows an optional cached_root_event_id. The TS send
mutation resolves the root from the cached timeline via a new
resolveCachedReplyRoot that mirrors the Rust resolver exactly (last root
marker wins, else last reply marker, else parent is root; same parent-kind
allowlist including KIND_HUDDLE_STARTED=48100; self-referential markers
collapse to the parent). Any cache miss or out-of-allowlist kind returns
null and the Rust side falls back to the existing relay resolution —
behavior unchanged.

Correctness: the cached root is used only for tag construction; the relay's
ingest-side ancestry validation (root tag must match thread ancestry)
still rejects any stale/wrong root, so the fast path cannot produce an
accepted-but-misthreaded event. A unit suite pins the TS mirror to the
Rust resolver semantics, including the trap where resolveReplyRootId's
parent-id fallback would mislabel a nested reply as a thread root.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-02 12:31:57 -04:00
..