Repository navigation
The desktop app shows link previews and sends them, and group links in messages open the group - #188
Merged
Merged
Conversation
…n messages open the group
…views # Conflicts: # core/desktop/src/app/mod.rs
…r preview, and failed pictures aren't drawn
Owner
Author
Review findings and fixesAll fixed on this branch in 9863253. Each test was written first and failed before its fix.
Rulings applied: only group links are clickable, the card sits above the text, and links are underlined in the bubble's text colour (all unchanged). Checks: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
New
app/previews.rsandapp/previews/view.rs, after the Mac app'sLinkPreviewCard(AttachmentViews.swift),PreviewDraftCardandComposerView,AppStore.composerChanged/dismissPreview/send,PreviewLink,MessageText.groupLinksandAppStore.handleLink, and the link-previews spec.Showing
xn--…), 280pt wide plus padding, on a dark 18% fill. Like the Mac's card it has no description. A picture that doesn't decode isn't drawn.files.rs. GPUI'sopen_urlwould log the link when it fails. The link is parsed withurl, the same parser the core uses, and its serialized form is what opens. So the browser goes to the host the card names, and the opened text has no quotes or spaces. On Windows, the opener hands Explorer its target quoted whole (raw_arg). Explorer splits its own command line on,and=, so a,/root,<path>inside a link (or a file name with a comma) could otherwise pick what it opens.details(loaded with reactions and files). The app trusts the core's rules: since A received link preview shows only if its https link is in the message #168 a received preview is kept only when its https link is written whole in the text, and none is kept for view-once. As on the Mac, deleted, view-once and sticker messages show no card. The picture is decrypted in memory by the core and shows once the image has downloaded. Row heights are remeasured when a card comes or goes.Writing
link_preview_for. The draft card appears above the composer, in the accessories panel after the mention picker: picture (44pt), title (or the host), description (two lines), host, and ✕ ("Remove the link preview").send_textonly if its link is still in the message. It doesn't go with files (send_attachmentshas no preview, as on the Mac). If the send fails and the text comes back to the composer, the draft comes back with it.Links in message text
https://signal.group/#…orsgnl://signal.group/#…, the Mac's pattern). They're underlined. A click that selects nothing opens the Join dialog with the link filled in and asks for the group at once (the Mac'sJoinGroupSheet(link:)), so the dialog shows the group's name, members and Join or Ask to Join. Dragging across a link still selects its text. Other links remain plain text, as on the Mac.Selectable(the message text element) takes link ranges. It shows a pointing hand over a link and handles the click on release, the way gpui-base's inline links do.Shortcuts (each has a code comment):
Why
#140: the desktop app showed no link previews, sent none, and group links in messages did nothing.
How it was tested
=,/root,, spaces, and a file path with a comma; refused with a"or a final\xn--…,\@opens the host the card names--features snapshot):Selectableopens it, while a click off it or a drag across it doesn't. Removing either the click handling or the selection check makes this test fail.cargo fmt --check;cargo clippy -p hush-desktop --all-targets -- -D warnings, with and without--features snapshot;cargo test -p hush-desktop(103 pass) and--features snapshot(124 pass), after merging The desktop app sends pictures and files #187.--snapshot, light and dark, newlink-previewscreen: a received card with its picture, title and host above the text; an underlined group link; the draft card with ✕ above a composer holding a link. The other screens are unchanged.x86_64-pc-windows-gnustd in a scratch crate holding the same function. Its argument building is unit-tested on every platform.make check: it needs the signing certificate, which this Mac doesn't have. The live window wasn't opened and no phone was linked. So real fetching, sending and receiving a preview, the pointer cursor over a link, and the browser actually opening on Windows and Linux are checked only by tests and by reading the code. On macOS I checked that/usr/bin/open --takes a URL, using a scheme with no handler so no window opened.One new direct dependency:
url(already in the tree through the core), so the app parses links exactly as the core and browsers do. No core changes.files.rs: its opener takes a link too, quotes its target for Explorer, and says "no app here opens it";thumbnailis shared.Closes #140
Part of #157