Skip to content

The desktop app makes and answers voice calls - #312

Merged
pitis merged 3 commits into
mainfrom
feat/voice-calls
Nov 30, 2026
Merged

pitis merged 3 commits into
mainfrom
feat/voice-calls

Conversation

@pitis

@pitis pitis commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

What changed

The desktop app makes and answers 1:1 voice calls on the core's call engine (Client::start_call, accept_call, hangup_call, set_call_muted, call_audio_devices, set_call_audio_input/output, CoreEvent::CallChanged). No video and no camera, as the owner asked ("calls yes, video calls, no").

  • Voice Call in a person's chat toolbar, before ⓘ (not in groups, phone-number chats, Note to Self, blocked chats or requests; the Mac app's canCall). Disabled until Hush is connected, as on the Mac.
  • The call's panel (core/desktop/src/app/calls.rs, calls/view.rs): avatar, name and a state line.
    • Outgoing: Calling… / Ringing… / Connecting…
    • Incoming: "Incoming voice call…" with Decline and Accept. Accept stays offered through Ringing: RingRTC takes an accept only once the call rings here.
    • In the call: the duration (m:ss, redrawn every second), mute, menus for the speaker and the microphone with the device in use ticked, and Hang Up.
    • Over: "Call over — hung up / busy / no answer / answered on your phone / declined on your phone / the call failed" for 3 s, with Close, then the panel goes.
  • Notifications, through the existing paths on each system:
    • The ring ("Incoming voice call") shows while the window isn't in front. It is taken back once the call connects, is declined, or ends.
    • The missed-call notification follows the Mac app's rule: a call we never answered that the caller gave up on (remote hang-up, no answer, failed). A call we declined, one our phone took or declined, or one that connected is not missed. Like the Mac's, it shows even while the window is in front.
    • Both follow Settings › Notification content: "Hush" as the title when names are hidden, and none when notifications are off.
    • A click opens Hush on the caller's chat, with the panel.
  • Bringing the call back: the panel's minimize-2 button hides it mid-call, and the call goes on. While a call is up, every chat's toolbar shows Show the Call (phone-call), which brings the panel back. When a hidden call ends, the panel comes back for its 3 s so the end is seen.
  • A second call while one is up says "You're already in a call." A hang-up the core never confirms ends the call after 5 s anyway ("The call didn't end; the call engine may have stopped."), as on the Mac.
  • macOS microphone: scripts/bundle.sh adds NSMicrophoneUsageDescription ("Hush uses the microphone for voice calls.") to Info.plist, and signs with the com.apple.security.device.audio-input entitlement and no other: the Swift app's project.yml setting. Without them a hardened Hush.app can't open the microphone.
  • Core (sig-core), what the desktop app needed:
    • sig_core::CallEnd is now exported. CallChanged.reason carried it, but the app couldn't name it to say why a call ended.
    • A start the call engine refuses now ends the call with CallChanged { phase: Ended, reason: Failed } as well as the error, so "Calling…" doesn't stay up. This covers three cases: the engine didn't start, "already in a call", and RingRTC refused the call. Added after review.
    • A mute set before the relays arrive is kept: the relays' proceed used to turn the microphone back on. Added after review; it can't be exercised without placing a call.
  • A call the core goes on with after this app ended it (ended here after the 5 s grace, say) is hung up in the core when its next state arrives. The grace path asks the core to hang up once more too. Added after review.
  • DESIGN.md describes the panel and the button. The M3 calls spec notes how the desktop app differs.

Departures from the Mac app, and why

  • A panel in the window, not a call window. The desktop app is built around one GPUI window:

    • closing it hides or quits Hush through running;
    • the rule that notifications stay quiet in front, the caret blink and the drawables all follow that window;
    • the snapshots and window tests render it.

    The stories "window" is already a panel over the chats for the same reason. Unlike a dialog, the call panel lays nothing over the chats, which stay usable during a call. It sits under every dialog.

  • Hiding the panel keeps the call. The Mac's call window hung up when closed. The ticket asks that a closed panel can be brought back, so hiding only hides it.

  • No Accept or Decline on the ring notification (// shortcut: in notifications.rs). A click brings the call up instead. Buttons would need new code in each of the three systems' notification code (Notification Center, Windows toasts, freedesktop), and two of them can't be tried here.

  • The device menus tick the device just chosen; the Mac's kept the tick on the one read at the start.

Checked against the issue

  • Missed calls before this PR: the desktop timeline already shows them (events.rs; A missed call shows at the time of the call, not when Hush got its message #274 fixed their times), but no notification was posted. This PR adds the notification only. The timeline is unchanged.
  • Windows and Linux: no new cfg-gated code. The call UI and notifications go through the same code as messages. RingRTC's audio on Windows and Linux has never been tried; the release workflow's builds are the first check there. Neither system needs a permission entry for the microphone: Windows asks through its privacy settings, Linux doesn't ask.

How it was tested

No call was placed: no live app, no network, none of the owner's data.

  • Unit tests (app::calls::tests, 7) cover the call's states:

    • ring, connect, end;
    • answerable while ringing;
    • a new call never inherits an ended one;
    • the missed rule for every CallEnd;
    • stale and other-chat events;
    • the panel's wording and the duration;
    • who can be called.
  • Window tests (app::calls::window_tests, 8), with made-up CallChanged events and, where a core is needed, an unlinked one:

    • each phase's buttons;
    • hiding, then Show the Call from a group chat;
    • the ended state lingers 3 s, and Close;
    • the duration redraws each second;
    • "You're already in a call.", "That call is over." and "Hush isn't running.";
    • an unconfirmed hang-up ends after 5 s;
    • mute and device choices;
    • the ring and its removal on connect or decline;
    • the missed-call notification in front, none for an answered or declined call;
    • the notification-content setting.
  • All 13 first tests failed against the logic stubbed out before passing. The review's fixes came with tests that failed first:

    • a late hang-up check ending the next call with the same person;
    • a stray connect being hung up;
    • the core's a_call_that_fails_to_start_is_reported now expects Ended(Failed).
  • Gate:

    • cargo fmt --check: pass
    • cargo clippy --all-targets -D warnings: pass
    • cargo clippy --all-targets --features hush-desktop/snapshot -D warnings: pass
    • cargo clippy -p hush-desktop -D warnings: pass
    • cargo test --features hush-desktop/snapshot: pass (desktop 421 passed, 1 ignored; core 554 passed, 4 ignored)
  • Snapshots looked at, light and dark: new demo screens call-incoming, call-ringing, call-connected (2:05, muted) and call-ended (no answer), over Ana's chat.

  • Bundle: scripts/bundle.sh built and signed (ad-hoc here) core/target/bundle.noindex/Hush.app. Its outputs:

    • codesign -d --entitlements - lists only com.apple.security.device.audio-input = true;
    • codesign -dv shows flags=0x10002(adhoc,runtime);
    • plutil -p shows "NSMicrophoneUsageDescription" => "Hush uses the microphone for voice calls.".

    The app was not installed or opened.

Closes #149

@pitis

pitis commented Nov 30, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr: code, tests, silent failures, comments) and what was done

The fixes are in 3964a06. The gate passed again: fmt, the three clippy runs, and cargo test --features hush-desktop/snapshot (desktop 421 passed, core 554 passed).

Critical

  1. The 5 s hang-up check could end the next call with the same person. If you hung up and redialled, or they called back, within 5 s, the timer ended the new call here. The core kept that call with a live microphone and no panel. (Found by the code, test and silent-failure reviews.)
    Fixed: each call is numbered (Call.n, Calls::begin), and the timer acts only on its own call. Two ended calls no longer compare equal, so the 3 s linger can't cut another call short either. Test: the_hang_up_check_leaves_the_next_call_alone, which failed first.

Important

  1. A start the core refused stayed on "Calling…". The core sent only CoreEvent::Error in three cases: the engine didn't start, "already in a call", and RingRTC refused the call. Fixed in the core: refused() also sends CallChanged { Ended, Failed } for the peer. The core test a_call_that_fails_to_start_is_reported now expects it; it failed first.

  2. States of a call the app had already ended were dropped silently, for example after the 5 s grace while the core went on. Fixed: a Ringing, Connecting or Connected with no call up here is logged and hung up in the core (Changed.orphan). The grace path also asks the core to hang up once more, which covers a hang-up sent while the call was still starting. Unit test in a_state_of_no_call_up_is_hung_up_and_one_of_another_changes_nothing; it failed first.

  3. Muting during "Calling…" was undone when the relays arrived: the relays' proceed turned the microphone back on. Fixed in the core:

    • Shared.muted is set by SetMuted and reset at Start;
    • it survives the call's first state;
    • proceed respects it.

    No test: exercising it needs a placed call.

  4. No test that a mute the core didn't take isn't shown. Added a_mute_the_core_didnt_take_isnt_shown.

  5. No test that the ring goes when the caller gives up. Added an assertion to the notification test.

  6. No test that our own call never offers Accept. Added an assertion.

  7. The M3 spec contradicted itself about video. M3b is now marked dropped (2026-11-30) in each place it appears.

  8. DESIGN.md named palette colours the call buttons don't use. It now says they are gpui-component's danger, success and warning tints, and lists them under "Fixed, outside the palette".

Smaller findings

  • Call failures weren't logged. call_failed now logs them; the logs hold no content. Declined: letting the timeout's message not replace one already in the banner. The banner shows the newest message everywhere in the app, and changing that is beyond this PR.
  • A failed device switch didn't say which device. It now says "Couldn't switch the microphone: …" or "…the speaker: …". The tick moving before the core confirms is now a shortcut: comment.
  • Declined: a banner when the devices can't be read. The call still works on the system's default devices. The failure is logged, and the core reports an engine failure itself.
  • Test quality:
    • The mute test was renamed mute_and_a_device_choice_show_once_the_core_took_them, with a note that an unlinked core accepts and drops the commands.
    • The duration test now checks that the panel is redrawn on two seconds in a row.
  • Comments: fixed the toolbar line in DESIGN.md, the wording of Close, and the docs of can_call, Shown, the ring's click and show_call.

Left for the owner (not fixed here)

  • A microphone permission denied on macOS gives a silent call, with no word from Hush. The Mac app didn't check either. Checking needs AVFoundation (a new dependency, or msg_send) and a banner pointing to System Settings.
  • The core's call thread never ends (sig-core/src/calls/actor.rs: run holds its own sender), so unlinking mid-call may leave a call running. This is outside this PR's diff and predates it; it needs a shutdown command.

@pitis
pitis merged commit de1b1b5 into main Nov 30, 2026
@pitis
pitis deleted the feat/voice-calls branch November 30, 2026 02:40
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 makes and answers voice calls

1 participant