Skip to content

Signal: bold, italic, strikethrough, monospace and spoiler text are lost both ways - #816

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/747-signal-text-styles
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/747-signal-text-styles

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

Signal messages keep bold, italic, strikethrough, monospace and spoiler in both directions. Composer markdown is sent as body ranges on the plain text, including an edit and a quote, and an incoming range becomes a span even when it overlaps a mention and an emoji. A spoiler reads as the word Spoiler in a row preview, a notification, and a reply snippet.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/signal-text-styles

Lab run: not run

Compatibility

No protocol change. The spans use styles the message model already has. An older client still shows the plain text. A preview that has a spoiler span now says Spoiler instead of the hidden words, on every network that stores those spans.

Risk and rollback

A wrong range can mark the wrong words, or hide a spoiler that should stay visible in the message itself. The message text is unchanged; only the spans and the preview wording move. Revert this commit to undo it.

Release note

Signal keeps bold, italic, strike, monospace and spoiler, and a spoiler stays out of the preview.

Tested

cargo test -p chatd --lib --no-default-features for the style tests, and cargo test -p chatd --test signal --no-default-features for the send, reply snippet, and edit. cargo clippy -p chatd --no-default-features --all-targets.

Not tested: no live Signal account, and the lab was not run. The Signal feature build, which translates protobuf body ranges, was not compiled in this session.

Closes #747

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

🟢 No findings.

The change carries Signal's five body-range styles both ways: incoming UTF-16 ranges are mapped to byte spans during mention substitution, and composer markdown becomes ranges on the plain text sent, including edits and quotes. The offset math in style.rs is careful: every range is bounds-checked, length-zero and off-the-end ranges are dropped, and surrogate-pair starts round down, so no peer-controlled input can panic. I checked the protobuf usage against the pinned presage rev (libsignal-service f4499301): BodyRange.Style has exactly Bold/Italic/Spoiler/Strikethrough/Monospace, both MentionAci string and binary variants are handled, and Quote.bodyRanges exists. Spoilers are hidden in the row preview, the notification preview and the reply snippet; the window already draws Style::Spoiler, messages persist as serde JSON so spans round-trip, no protocol wire field changes, and the parser, mapping and preview have tests plus the required e2e scenario. The design holds; nothing needs to change before merge.

Residual risk

  • The composer's markdown is greedy about asterisks and underscores, so plain prose like 234 sends as 234 with the marks eaten; that is inherent to the feature and matches how Signal's own composer and Discord behave, but users will occasionally lose characters they meant literally.
  • mentions_me is now set only when a mention range actually replaces a U+FFFC placeholder; a malformed incoming message that mentions the user without a placeholder no longer raises the flag, where the old code did.
  • The author's Tested note says the signal-feature build was not compiled in their session. CI's default build compiles it and the proto calls match the pinned dependency, but how real Signal clients style quotes and edits with mentions stays unverified until someone links a live account (the module doc already marks live Signal as untested).
  • The window's spoiler reveal interaction (conversation.rs rich.rs) is pre-existing and untouched here; if its span indexes ever disagreed with chatd's byte offsets, previews would still hide spoilers but the body could misstyle. This diff is the first producer of Signal spoiler spans, so that pairing is only proven by the fake-adapter test.

@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 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.

Signal: bold, italic, strikethrough, monospace and spoiler text are lost both ways

2 participants