From 03cb5e4123b2347c0de186de0c4676867f669b5e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 10 Jul 2026 20:11:08 +0000 Subject: [PATCH] fix: trim leading/trailing whitespace from composed posts (#349) Trim the composer text once, where it is handed to NewMessageTagger, so every event kind built from tagger.message (short note, poll, zap poll, NIP-29 thread, NIP-22 comment) publishes without stray leading/trailing whitespace and mention rewriting operates on the exact string that gets published. The now-redundant per-call trim on the NIP-29 thread build is removed. Whitespace-only messages are still rejected by the existing isNotBlank gates before a template is ever built. https://github.com/vitorpamplona/amethyst/issues/349 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01K1V6v7aYBE8B5PhNZMNs3o --- .../amethyst/ui/note/nip22Comments/CommentPostViewModel.kt | 2 +- .../ui/screen/loggedIn/home/ShortNotePostViewModel.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt index f680c7183e..d89c1f38fe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt @@ -576,7 +576,7 @@ open class CommentPostViewModel : private suspend fun createTemplate(): EventTemplate? { val tagger = NewMessageTagger( - message = message.text.toString(), + message = message.text.toString().trim(), dao = accountViewModel, ) tagger.run() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index f623c7f489..14a0a740de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -1101,7 +1101,7 @@ open class ShortNotePostViewModel : val tagger = NewMessageTagger( - message.text.toString(), + message.text.toString().trim(), pTags, eTags, accountViewModel, @@ -1126,7 +1126,7 @@ open class ShortNotePostViewModel : // NIP-29 kind-11 group thread. The title is the required subject field (no first-line // fallback); the body is the full message. Scoped to the group by `h`; the host relay // authorizes the write. - ThreadEvent.build(tagger.message.trim(), subjectValue) { + ThreadEvent.build(tagger.message, subjectValue) { hTag(threadTarget.groupId) hashtags(findHashtags(tagger.message))