Files
amethyst/commons
Claude 893a270c65 fix(edits): unlink deleted edits from their message; one collector per row
Audit of the three edit paths (feed 1010 / Buzz 40003 / Concord 3302) found:

1. Bug (feed regression): a deleted edit kept overlaying its message. Edits
   anchor on the target's Note.edits with no `replyTo` back-link, and
   removeNote didn't cover `edits`, so unlinkAndRemove never dropped them — the
   old cache-scan resolver dropped deleted edits for free, Note.edits did not.
   Fix: removeNote now also removeEdit()s, and unlinkAndRemove resolves the
   edit's `e`-tag target and unlinks it there (editedTargetIdOf covers all
   three kinds). New test: deleting an edit un-overlays and unlinks it.

2. Perf: every chat row ran two edits-flow collectors (observeConcordEdit +
   observeBuzzEdit). A message is only ever one kind, so they're merged into a
   single observeChatEdit that resolves latestConcordEdit() ?: latestBuzzEdit()
   — one collector per row, dispatched by the winning edit's event type.

3. Nits: latestBuzzEdit now tie-breaks by idHex (deterministic on same-second
   edits, matching Concord); dropped a redundant takeIf in latestConcordEdit.

The author check stays at read time on purpose: an edit can be consumed before
its target loads (author unknown), so an attach-time gate would wrongly drop
early-arriving legit edits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HdLnAa4Pa1pFV9FTYVTB6
2026-07-24 20:18:53 +00:00
..