Skip to content

The desktop app shows a contact's safety number to verify - #234

Merged
pitis merged 2 commits into
mainfrom
feat/desktop-safety-number
Nov 28, 2026
Merged

pitis merged 2 commits into
mainfrom
feat/desktop-safety-number

Conversation

@pitis

@pitis pitis commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • The safety number sheet (src/app/safety.rs, the Mac app's SafetyNumberView): "Safety Number with {name}", a spinner while the core reads it, then the QR code their phone scans, the 60 digits in 3 rows of 4 groups of 5 (monospace, selectable and copyable, read digit by digit to a screen reader) and the explanation; "There's no safety number with {name} yet: there is one once you've exchanged messages." when there is no session yet; "Couldn't read the safety number: …" (or "Not linked yet.") in red when the read fails; Done, Enter or Esc closes it and gives the keys back to the composer; opening a chat (from a notification or the tray) closes it too. An answer for a sheet closed or reopened for someone else meanwhile is dropped.
  • Chat Options ▸ View Safety Number… in a contact's chat only: not groups, Note to Self or phone-number chats (contactAci), named as the chat's title.
  • View Safety Number under "Your safety number with X changed" in the timeline, for whom the event is about (in a group, its author).
  • qr::code takes bytes as well as text (a safety number's code is libsignal's scannable bytes); the link screen's call is unchanged.
  • While the sheet is open, the chat's shortcuts (search, attach, navigation), Settings and Stories wait, as they do for Group Info; leaving the chats screen closes it.
  • --snapshot renders a new safety-number screen (Ana's chat with a made-up number).

Why

Desktop parity (#157): the core already had Client::safety_number and the event text already showed; the desktop app had no way to see the number. Every claim in the issue checked out against the code; nothing was dropped.

How it was tested

  • Test-first, each failed against a stub before the code:
    • safety::tests::the_digits_show_in_three_rows_of_four_groups_of_five (and the spoken form)
    • options::tests::a_contacts_chat_offers_their_safety_number (not Note to Self, phone-number chats or groups)
    • events::window_tests::a_safety_number_change_offers_the_number_with_whom_it_is_about (direct chat and group)
    • safety::window_tests::the_sheet_says_why_the_core_couldnt_read_it_and_closes (no core: "Not linked yet."; an unlinked core: "Couldn't read the safety number: …"; the chat shortcuts and Settings wait, checked with real keystrokes; Esc closes and the composer has the keys)
    • safety::window_tests::a_chat_opened_from_a_notification_closes_the_sheet (review fix)
  • Gate, from core/: cargo fmt --check pass; cargo clippy --all-targets -q -- -D warnings pass; cargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warnings pass; cargo test --features hush-desktop/snapshot -q pass (desktop 278, sig-core 537), after the review fixes too.
  • The Swift leg (xcodebuild) wasn't run: nothing under app/ or core/sig-core changes.
  • Snapshots looked at, light and dark: safety-number (the sheet with its code, digits and explanation, matching the Mac app's layout) and events (View Safety Number under the safety number change, in the accent like Reset Secure Session…). The Chat Options menu isn't in a snapshot (a gpui-kit dropdown can't be opened without a click), and the live window wasn't run (the desktop app isn't linked on this Mac), so a real number from the core was not seen on screen.

Closes #223

Chat Options > View Safety Number... in a contact's chat, and View Safety Number under
"Your safety number with ... changed", open the Mac app's sheet: the QR code, the 60 digits in
3 rows of 4 groups of 5 (selectable), the explanation, the no-number-yet and failure states, Done.
…er sheet

Review fixes: the sheet closes when a chat is selected, so the keys never go to a composer under
it; its window test also checks that the keys return to the composer, and that Settings and the
chat shortcuts wait while it's open.
@pitis

pitis commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr on git diff origin/main...HEAD)

Four reviewers ran: code, tests, silent failures, comments. None found a Critical issue.

Important, fixed

  1. A notification or tray click left the sheet open, with the keys moved behind it. select() focused the composer under the sheet. Esc and Enter then no longer closed the sheet, and Enter would send what was typed. Fix: select() closes the sheet first (mod.rs). This is the same reason switch() already closes the stories window. New test a_chat_opened_from_a_notification_closes_the_sheet covers the chat already open and another one; it failed before the fix.
  2. Nothing checked that the keys go back to the composer after closing. Fix: the sheet's window test now asserts the composer is focused after Esc. I checked that it fails with the refocus line removed.
  3. Nothing checked that Settings waits while the sheet is open. Fix: the window test now sends real keystrokes (alt-down secondary-,) with the sheet open and asserts the chat didn't change and Settings didn't open. I checked that it fails with the guard removed.

Suggestions, taken

  • The test also asserts can_attach() is off while the sheet is open.
  • Two comments corrected: the close doc now names Return, and the unlinked-core test comment says the core refuses.

Suggestions, declined

  • Log a failed read, as the Mac does: declined. The error is shown in the sheet. The desktop's sibling reads (Group Info's read_group) don't log failures they show; the desktop uses tracing only for failures that leave nothing on screen.
  • A test for the dropped stale answer: declined. The core's actor answers in order, so a deterministic test can't tell whether the guard is there (the test reviewer agreed).
  • A test for the sheet closing when the screen leaves the chats: declined. It's a one-line reset in a block whose other resets (dialog, Group Info, stories) are untested the same way, and the render also checks the screen.
  • Leave out the QR code silently when it can't be encoded: kept as is. A real code is about 74 bytes, far under a QR code's limit, and the Mac's if let image does the same.
  • Split the doc comment on Sheet's aci/name fields: kept as is.

For the owner (outside this PR)

  • Group Info has the same notification-click gap: a click from a notification or the tray focuses the composer under its panel. Not changed here, since it's out of scope.
  • The core wraps actor errors as Storage: Client::safety_number turns every actor error into CoreError::Storage. A rare not-linked or fingerprint error therefore reads "Hush couldn't open its data: …". The Mac shares this; a core fix would be its own issue.

Checks after the fixes

From core/, all pass: cargo fmt --check, cargo clippy --all-targets -q -- -D warnings, cargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warnings, cargo test --features hush-desktop/snapshot -q (desktop 278, sig-core 537).

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 a contact's safety number to verify

1 participant