Skip to content

The desktop app shows polls and lets you vote, and opens view-once photos and videos once - #209

Merged
pitis merged 6 commits into
mainfrom
feat/desktop-polls
Nov 14, 2026
Merged

pitis merged 6 commits into
mainfrom
feat/desktop-polls

Conversation

@pitis

@pitis pitis commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

What changed

The desktop app no longer shows "📊 Poll: …" and "View-once media" placeholders; it does what the Mac app does (PollView.swift, ViewOnce in Placeholder.swift, the view-once spec).

Polls (core/desktop/src/app/polls.rs, polls/view.rs)

  • The bubble shows the question, "Choose one" / "Choose one or more", each option with its count and a bar of its share of the voters, ours ticked, and "N votes" ("· Ended" once ended), read from Client::details.
  • A click votes as PollChoice.after does: single choice → that option (on ours, the vote is taken back); several → toggles it. Ended polls take no votes. Our own open poll has "End poll". Both go through chats::change ("Couldn't vote: …", "Couldn't end the poll: …"), and show once the core reports them sent.
  • Creating polls isn't here: the Mac app can't create them either.

View-once media (core/desktop/src/app/view_once.rs, view_once/view.rs)

  • The bubble shows the Mac's states and words: View photo / View video, Download view-once media, Downloading…, can't be downloaded, Viewed, and ours "View-once media".
  • A photo is read with file_bytes, decoded in memory and shown over the window (Close or Esc). It never enters the files' picture cache (Files.thumbs) and is never written to disk; its pixels are dropped when it closes (drop_image).
  • A video plays in the system's player (GPUI plays no video) from a decrypted, quarantine-marked copy in the data folder's opened-copies folder. The copy is named from its type (video.mp4, .mov, .m4v, .webm or .3gp) and never from the sender's file name; a view-once "video" of any other type is refused before anything is copied. A small "View-once video" window stays up while it plays, and its Close removes the copy. If the player still holds the file (Windows locks it), the app says so. Any copy left behind is removed at quit and at the next launch, as the other opened copies are.
  • As on the Mac, the look is spent (view_once_opened) only once it shows, so a failed open keeps it for another try. A photo for a chat left while it was being prepared shows nothing and spends nothing. A video already handed to the player is always spent. Once shown, a look's button stays waiting for the rest of the run, even if the core couldn't mark it viewed (the Mac's viewOnceOpening). While a look shows, the chat shortcuts wait; switching chats or leaving the chats screen closes it, as the Mac closes Quick Look with its chat. Nothing in the viewer copies, saves or forwards: there is no menu on it, and the message menu has no Copy (the core keeps no caption).

Hooks in shared files are additive: the row's poll and view-once fields plus its words replaced (view.rs), poll details loaded and kept (actions/mod.rs), the module fields and demo screens (mod.rs, main.rs, demo.rs), and a few files.rs helpers made visible (picture, attachments, the copy and open helpers).

How it was tested

  • Unit tests: vote state (single choice, several, changing and taking back a vote, ended polls take none, only the author ends an open one, the summary words, polls loaded from details and dropped with their rows), and the view-once state machine (unopened → viewing → viewed; after a restart the core's "viewed" wins; download, downloading and unavailable states; ours can't open; no Copy).
  • Window tests over a real, unlinked core: a vote and an end reach the core while an ended poll sends nothing; a view-once photo shows from memory, with nothing in the picture cache, on disk or on the clipboard before or after closing and its pixels released on close; the shortcuts wait while it shows, and a second click, even after closing, takes no second look; a photo that doesn't decode, or is for a chat left meanwhile, isn't spent; a video handed to the player is spent, and its copy goes when its window or its chat closes; a video that doesn't copy out leaves nothing; a video copy is never named by the sender, and other "video" types are never copied or opened. I mutated the code to check that these tests fail when the behaviour breaks.
  • Gate: make format, make lint (including clippy with hush-desktop/snapshot), cd core && cargo test --features hush-desktop/snapshot -q: all pass.
  • Snapshots (--snapshot, light and dark): polls (our open poll with End poll, Ana's ended poll with our vote, and Viewed, Download and View photo bubbles) and view-once (the photo viewer over the chat).
  • Swift leg not run: nothing it builds changed (only core/desktop).

Decisions for the owner

  • The desktop has no Quick Look. Photos open in an in-app viewer. Videos open in the system's player, with a "View-once video" window whose Close removes the copy, because the app can't tell when the player closes. On Windows a player still holding the file can block that removal; the copy is then removed at quit or the next launch.
  • Allowed view-once video types: video/mp4, quicktime, x-m4v, webm and 3gpp. Any other video/* type is refused with "Couldn't open the video: it isn't a kind of video Hush plays".

Not verified

  • Windows and Linux: no new platform code. The video path reuses open_with_system and the copy-folder cleanup, which already have their cfgs, but it was built and run on macOS only.
  • The video window wasn't rendered in a snapshot, and no test launched a system player, so a real video wasn't played. I didn't see the live window.

Closes #152

Polls show their options, votes and voters, ours ticked; a click votes
(single or several choices, a click on ours takes it back), and our own
open poll can be ended. View-once photos open once in a viewer over the
window, decoded in memory only; videos play in the system's player from
a copy removed when the viewer closes. Each is spent only once it shows.
A sender's name could make the player's click run a program or a
script; a type that isn't a video a player should open isn't copied
or opened at all.
…h their chat

A video handed to the player counts as shown and is spent even if the
chat changed meanwhile; a photo for a chat left meanwhile isn't. A look
shown keeps its button waiting for the rest of the run, as on the Mac,
and while one shows the chat shortcuts wait. Switching chats or leaving
the chats screen closes the look and removes a video's copy; a copy the
player still holds is said. Photo read errors use the app's words.
# Conflicts:
#	core/desktop/src/app/view.rs
#	core/desktop/src/main.rs
@pitis

pitis commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr: code, error handling, tests, comments) and fixes

Critical, from the orchestrator: a sender could make the video player run a script. The view-once video's copy took the sender's file name (for example run.command sent as video/mp4) and was handed to the system's opener without the openable check. Fixed (3e8809a, then 98ce11c): the copy is named only from its type (video.mp4, .mov, .m4v, .webm, .3gp), in its own folder among the opened copies, and it still carries the quarantine mark. Any other video/* type is refused before anything is copied. Tests: a_videos_copy_is_named_by_its_type_never_by_its_sender checks video_copy_path, which view_once uses; it failed against the old naming. a_video_of_a_kind_no_player_should_open_is_never_copied_or_opened checks the refusal.

Important: fixed in 98ce11c

  1. A video handed to the player could go unspent (code, errors). If the chat changed while the player was starting, the copy was removed and the look wasn't spent. Now, once the player has the file, the look counts as shown and is spent wherever the window is. A photo for a chat left meanwhile still isn't shown or spent. Tests: a_video_handed_to_the_player_is_spent_and_its_copy_goes_with_its_chat and a_photo_for_a_chat_left_meanwhile_isnt_shown_or_spent.
  2. After the viewer closed, the media could be opened again until the core's change came, or for good if the spend failed (code). It now follows the Mac's viewOnceOpening: a look shown keeps its button waiting for the rest of the run. Test: the photo test checks the button after closing and that a click doesn't open it again. This replaces the "Decisions for the owner" item I had listed about this.
  3. The viewer wasn't tied to its chat (code, tests). The shortcuts could switch chats under it, and it stayed over the next chat. Now can_search waits for it, as for dialogs, and switching chats or leaving the chats screen closes it (the Mac closes Quick Look with its chat), removing a video's copy. Tests: the photo test (shortcuts wait) and the handed-video test (switch closes it, copy gone).
  4. A video copy the player still holds was left unsaid (errors). On Windows the player locks the file. remove_copies now reports whether every folder went, and closing says "The view-once video is still on this computer: close it in your video player. Hush removes it when it quits." The window now says "When you're done, close it there, then here".

Tests added from the review: a video that doesn't copy out leaves nothing and isn't spent; the clipboard is empty after closing a photo (⌘C pressed while it showed); the photo that doesn't decode is checked directly as not spent.

Suggestions

  • Fixed: while one look is being prepared or shows, every view-once button waits, not only that message's. Photo read errors use the app's words (describe).
  • Fixed: comment corrections — MessageRow.viewOnce, the module doc (Windows lock, no copy/save/forward from Hush), the VIEWER_PIXELS doc, the has_picture and attachments docs, the Row field comment and the test's copy name.
  • Declined: "View photo" for a Ready file without a path. The core's Ready files always have a path, and the demo relies on Ready without one.
  • Declined: two quick clicks can lose a vote. The Mac app's PollChoice works from the same last-read standing.
  • Declined: a failed spend's error shows under the photo overlay. It is seen once the viewer closes, and the button waits anyway.
  • Declined: Explorer's exit code is ignored, so Windows can spend a look no player opened. This is existing behaviour of open_with_system for every file, and it's in "Not verified".
  • Declined: an end-to-end test of polls_loaded. It needs stored messages, which an unlinked core doesn't have.

Main merged twice (#207 notifications, #208 typing). The conflicts were only in the module, field and demo lists; I kept both sides. After the last merge:

  • make lint passes (including clippy with hush-desktop/snapshot).
  • cd core && cargo test -q --features hush-desktop/snapshot passes: desktop 215, core 537.
  • The polls and view-once snapshots were re-rendered and are unchanged.

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.

The desktop app shows polls and view-once media

1 participant