Repository navigation
Conversation
Tiny Code Reviewthe AI provider rate-limited the request This is advice, not a gate. Re-run with the |
unRekable
left a comment
There was a problem hiding this comment.
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.
…spoiler out of the preview. Closes #747
eb3b8c5 to
8c723ad
Compare
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
Platforms
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-featuresfor the style tests, andcargo test -p chatd --test signal --no-default-featuresfor 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