Skip to content

fix: stop mention insert from breaking compose cursor and keyboard#485

Merged
barrydeen merged 1 commit intomainfrom
fix/compose-mention-ux
Apr 23, 2026
Merged

fix: stop mention insert from breaking compose cursor and keyboard#485
barrydeen merged 1 commit intomainfrom
fix/compose-mention-ux

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • Mentions are now stored directly as @Name in the compose text field; ranges are tracked out-of-band in ComposeViewModel and spliced back to nostr:nprofile… URIs at publish and draft-save time
  • Fixes cursor jumps / keyboard desync (identity offset mapping), removes the forced trailing space so @alice's works, and stops backspace from silently wiping an entire mention — one backspace deletes one char and the mention is dropped when its range is broken
  • MentionOutputTransformation loses its npub1/nprofile1 branches (no longer needed); note1/nevent1 chips stay for pasted quote URIs

Test plan

  • Type @ali, pick a candidate → cursor sits immediately after @Alice, no trailing space
  • Type 's thoughts right after → reads @Alice's thoughts, mention tag fires on publish
  • Publish and inspect: content contains nostr:nprofile1…, a p tag is present
  • Backspace once from end of @Alice → deletes e, mention is dropped, no atomic wipe
  • Two mentions in a row (@Alice and @Bob) → both publish correctly with two p tags
  • Rapid typing after a mention — cursor stable, no IME glitching
  • Rotate / process death → draft text and mention list restored from savedStateHandle
  • Save draft with a mention, reload it → draft restores as nostr:nprofile… URI (still publishable)

Mentions used to be stored in the text field as raw nostr:nprofile URIs
rendered as @name via an OutputTransformation. The visual/underlying
offset mismatch made the cursor jump, the IME desync on rapid typing,
forced a trailing space after every mention (so '@name's' was impossible),
and turned a single backspace into a silent delete of the whole mention.

Store '@name' directly in the text field and track mention ranges
out-of-band in the ViewModel; splice nostr:nprofile URIs back in at
publish time. Editing is now plain text — identity offset mapping, no
forced space, and breaking a mention drops only that mention, not the
surrounding text.
@barrydeen barrydeen merged commit b0455b1 into main Apr 23, 2026
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