Skip to content

fix(desktop): fold kind 40003 edit content into forum posts and comments - #6659

Open
BradGroux wants to merge 2 commits into
block:mainfrom
BradGroux:fix/forum-edit-folding
Open

fix(desktop): fold kind 40003 edit content into forum posts and comments#6659
BradGroux wants to merge 2 commits into
block:mainfrom
BradGroux:fix/forum-edit-folding

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

Note: This is a replacement for PR #6605, which was accidentally closed when branches were force-pushed after a commit identity rewrite. The changes are identical, rebased onto the latest main.

Summary

Desktop already fetches kind:40003 edit events alongside forum posts and thread replies, but only uses them for link-preview suppression. The edit content is never applied to the original message, so users always see the original text even after a successful edit — the relay has the new content, the CLI thread view shows it, but Desktop discards it.

Added fold_edit_content, which finds the latest valid 40003 edit for a given original event and returns its content. A valid edit must be signed by the original author or the author's verified agent owner (same authorization model as the existing link_preview_suppression_targets path). Applied in both get_forum_posts and get_forum_thread so edited content shows in both the channel list and the thread view.

This does not add an edit affordance in the UI — it fixes the data layer so that edits made via CLI or relay are visible in Desktop. The UI edit button is a separate enhancement.

Related issue

Closes #6433

Testing

Six new unit tests in forum.rs:

  • fold_edit_content_applies_author_edit — author signs an edit, content is replaced.
  • fold_edit_content_applies_owner_edit — verified agent owner signs an edit, content is replaced.
  • fold_edit_content_rejects_unauthorized_signer — edit from a random key is ignored.
  • fold_edit_content_latest_edit_wins — among two valid edits, the higher created_at wins.
  • fold_edit_content_ignores_edit_targeting_different_event — edit with an e tag pointing at a different event is ignored.
  • fold_edit_content_no_edits_returns_none — no edits means the original content is used.

The existing suppression_targets_accepts_author_and_verified_owner_only test is unchanged. Cannot run the full cargo test suite from this host (no Rust toolchain). The build and test gate will be verified on CI.

BradGroux and others added 2 commits August 23, 2026 19:58
Desktop already fetches kind:40003 edit events alongside forum posts and
thread replies, but only uses them for link-preview suppression. The
edit content is never applied to the original message, so users always
see the original text even after a successful edit.

Added fold_edit_content, which finds the latest valid 40003 edit for a
given original event and returns its content. A valid edit must be
signed by the original author or the author's verified agent owner
(same authorization as the existing link-preview suppression path).
Applied in both get_forum_posts and get_forum_thread so edited content
shows in both the channel list and the thread view.

Six new unit tests cover: author edit, owner edit, unauthorized
signer rejection, latest-edit-wins ordering, wrong-target rejection,
and the no-edits case.

Closes block#6433

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
The fold_edit_content_ignores_edit_targeting_different_event test created
two events with the same author, kind, content, and timestamp. When
Timestamp::now() returns the same second for both, they produce identical
event ids, so the edit targeting 'other' actually matches 'original' —
the test passes for the wrong reason or fails depending on timing.

Give the second event a distinct created_at so its event id is guaranteed
different.

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
@BradGroux

Copy link
Copy Markdown
Contributor Author

This is a replacement for #6605, which was accidentally closed when branches were force-pushed after a commit identity rewrite. Prior review comments and feedback are preserved on the old PR:

#6605

@Chessing234 Chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner_pubkeys.get(&original_author) == Some(&signer) only works if that map is author→editor. if it's agent→owner, a human post edited by their agent never matches. please pin the map direction with a test for both cases.

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.

Forum posts and comments cannot be edited: Desktop discards the kind:40003 edits the relay already accepts

2 participants