Repository navigation
The desktop app shows formatted text and writes it, with mentions - #186
Conversation
Bubbles and quotes draw bold, italic, strikethrough, monospace and mentions; a spoiler stays covered until its message is clicked. The composer keeps each character's styles beside its text (gpui-component's textarea can't draw them) and previews the styled text above the field; Desktop's shortcuts and a Format menu style the selection or what's typed next. In a group, @ offers its members and a picked one is a mention token. Sending and editing carry the ranges, and messages with styles or mentions can be edited, loading them back into the composer.
…d-text # Conflicts: # core/desktop/src/app/mod.rs # core/desktop/src/app/view.rs # core/desktop/src/main.rs
… mention list closed The format shortcuts are bound as cmd or ctrl per system (KeyBinding::new can't read secondary-), and a test builds every binding the app registers. Esc on the mention list holds until no @word is typed, as on the Mac. Typing where no styles are known is plain instead of panicking; only an input method's whole-text commit is trimmed; an edit keeps a spoiler that runs past the end; a mention not on its placeholder isn't loaded, and its message isn't offered for editing. New unit and window tests cover picking a mention, edits going back with their ranges, styles toggled before typing and how runs join.
Review findings and fixes (commit fa4317a)Every new test was written first. Each test of a bug failed before its fix. Each test of code that was already correct failed against a deliberately broken copy (listed per item), then passed again once restored. Critical
Important Test gaps Suggestions Ruling applied: the "Formatted" preview stays. Atomic mention tokens and Undo not taking back a style toggle are now Checks:
|
What changed
Showing (
text.rs,actions/view.rs), after the Mac app'sMessageText.swift:.help). While it is covered, the text can't be selected, so the hidden words can't be copied; Copy still copies them, as on the Mac (revealSpoilers: true). Quotes keep their spoilers covered. The block is painted over the text, not as a text colour, because emoji ignore text colours. What a covered spoiler hides isn't read out to assistive technology either: the row's label says "■■■■".Writing (new
app/compose.rsandapp/compose/view.rs), afterComposerText.swift,ComposerField.swiftand the compose-formatting and mention-picker specs:send_text/edit, measured in UTF-16. Each mention goes out as U+FFFC under a mention range. The text is trimmed, and touching runs of one style become a single range.MessageActions.canEdit), plus one check the Mac lacks: each mention must sit on its U+FFFC placeholder. The desktop app replies to, reacts to, edits, copies and deletes messages #180 had limited editing to plain text: messages with styles or mentions can now be edited, and ↑ edits the newest one. Starting an edit loads the message's styles and mentions back into the composer (mentions as tokens), and cancelling brings back what was typed before, styles included. Drafts keep only the words, as on the Mac.updateNSViewdoes. Before, it was at the start.The composer can't draw styles: what this does instead (a product question)
gpui-component's
Textareacan't draw styled runs. Only its code editor (EditorState) takes text decorations. Those can't change the font (so no monospace), don't support inline tokens, and bring code-editor behaviour: a two-line minimum height, no auto-grow, indent handling and a monospace default. So the composer stays theTextareaand keeps each byte's styles beside its text. While any of the text is styled, a "Formatted" preview above the field shows it as it will go out (spoilers lightly shaded, as in the Mac's composer). Mentions do show in the field itself, as inline tokens.Other options, if the preview isn't what you want:
EditorStateas the composer: bold, italic, strikethrough and spoiler shading inline, but monospace not shown and mentions as plain text plus a tracked range, with the quirks above to work around.Textarea.Two smaller differences from the Mac:
Why
#139: the desktop app showed only bold mentions, sent no styles or mentions, and couldn't edit styled messages.
How it was tested
text::styled: overlapping styles and UTF-16 offsets, mentions taking the styles around them, spoilers covering mentions and running to the end of the text, revealing, hostile ranges and split emoji.@worddetection and member matching, preview runs.cargo fmt --check;cargo clippy -p hush-desktop --all-targets -- -D warningswith and without--features snapshot;cargo test -p hush-desktopandcargo test -p hush-desktop --features snapshot(91 pass, including window tests of the picker, Esc, edits and toggled styles through the real field).--snapshotscreens, light and dark:chat: every style in bubbles, a covered spoiler, a quote's mention.composescreen: a styled message with a mention token in the field, the preview, and the picker open.replyandsearch-in-chatchecked after merging main.make check(it needs the signing certificate, which this Mac doesn't have). The live window and a linked phone weren't used, so the following are checked by unit tests and code reading only: the shortcuts, the Format menu (native menus don't render offscreen), the picker's keys, and real sending and editing.No new dependencies, and no core changes.
Closes #139
Part of #157