Skip to content

A missed call shows at the time of the call, not when Hush got its message - #274

Merged
pitis merged 2 commits into
mainfrom
fix/missed-call-time
Nov 29, 2026
Merged

pitis merged 2 commits into
mainfrom
fix/missed-call-time

Conversation

@pitis

@pitis pitis commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

What changed

A missed call is now recorded at the time its offer was sent, not when Hush handled it. Before, a call that waited on the server while Hush was closed showed up as "Missed voice call" under Today, even if the call was days ago.

  • IncomingEnvelope keeps the envelope's send time (client_timestamp, the sender's clock), clamped to the minute before the server had it (call_sent_at, as key_check already does for key changes). Messages use the same clock (sent_at is the sender's timestamp), and the timeline places events among messages by comparing at with sent_at, so the missed call now sits on the right day and in the right spot.
  • The call thread stores each offer's send time by call id (Shared.offers) before handing the offer to RingRTC, and drops it at RingRTC's first state for that call. When RingRTC rejects the offer (expired after 60 s, busy, glare), the missed call gets that time. Resetting Shared (a call starting or ending) keeps the map, because other offers in the same batch may still be on their way.
  • CallOutput::ChatEvent now carries its own at. The core actor no longer stamps it with Utc::now() when it writes the event.
  • hold_back_unaccepted_call (calls from message requests or strangers, which never ring) gets the envelope's time. It records the missed call at that time and lists the request at that time too.

Choices

  • Clock: the sender's timestamp, as messages use, not server_timestamp. The sender chooses that value, so it is clamped to [server − 60 s, server]. A missing or negative one would otherwise put the event before the epoch (hidden, since the apps load events from 0) and hide a held-back request (last_message_at stays 0). A future one would pin the request to the top. An honest sender's time passes unchanged. RingRTC's expiry check still uses the server-based age, as before.
  • Calls that ring while Hush runs: no change. Their event is still written when the call ends. For a missed call that rang, that is at most about a minute after the offer: RingRTC expires offers older than 60 s, and the ring times out. Signal Desktop works the same way for a rejected offer: it records it at now − age, the offer's time. It records a call that rang from its first ring, though, so a long connected call shows at its start in Signal and at its end in Hush. That is a different question from this bug, so I left it alone (see below).
  • Chat list: a missed call does not move a chat; refresh_summary counts only messages and decryption failures, and this PR doesn't change that. The only place the time affects the list is a stranger's held-back call, which lists the request through list_chat. That now happens at the offer's time, the same way a late message lists at its sent_at. An old offer puts the request in its place by time instead of at the top. It stays visible, since last_message_at > 0.
  • Already recorded events keep their wrong time. Their original offer time was never stored, so it can't be recovered.

How it was tested

Test first. The new tests ran against the plumbing with the old behaviour (every event stamped "now"), and all five failed with the event at "now" instead of the offer's time:

  • calls::actor::tests::an_offer_delivered_late_is_missed_when_it_was_sent: goes through the real call thread and RingRTC. An offer a day old is rejected as expired and its missed call is at the offer's time.
  • calls::actor::tests::an_expired_offer_is_a_missed_call (extended): the Bridge uses the stored offer time and then drops it.
  • calls::actor::tests::a_rejected_offer_while_busy_is_missed_and_leaves_the_active_call_alone (extended): a busy rejection gets its offer's time.
  • calls::actor::tests::an_offer_keeps_its_time_while_another_call_comes_and_goes (new): an offer's time survives both resets of Shared. Removing either mem::take makes it fail. It also pins the choice that a call that rang is recorded when it ends.
  • actor::tests::the_call_router_records_calls_at_their_time (new, from review): the router records a held-back offer at its envelope time and the engine's ChatEvent at its at. It fails when either Utc::now() stamp is put back.
  • actor::tests::a_calls_time_is_the_senders_within_reason (new, from review): the clamp. It failed against the unclamped helper.
  • actor::tests::a_held_back_call_is_missed_when_it_was_made (new): a stranger's call from a day ago is missed at that time, and the request is listed at that time, below a chat that was active an hour ago.

The existing call tests pass unchanged, including a_call_from_a_message_request_is_held_back_as_missed and a_call_that_cant_be_checked_doesnt_ring.

Gate: make format && make check (cargo fmt --check, both cargo clippy --all-targets … -D warnings, cargo test --features hush-desktop/snapshot -q): all pass on the head merged with main (sig-core 546 passed, 4 ignored; desktop 363 passed). There is no UI change, so no snapshots.

Not done

  • A missed call from an accepted chat that has no messages yet (say, a phone contact you never wrote to) is recorded but doesn't list the chat: the engine path never calls list_chat, and refresh_summary ignores missed calls. This predates the PR; it could be its own issue.
  • A connected or rung call is still recorded when it ends. Signal shows it from when it rang (incoming) or started (outgoing). Moving it to the start is a small follow-up if wanted.

Closes #273

An offer that waited on the server while Hush was closed reached RingRTC
expired and was recorded as missed at the time Hush handled it, so a call
from days ago showed under Today. The envelope's send time (the sender's
clock, as messages use) now travels with the offer: the call thread keeps
it by call id until RingRTC's first state for the call, and a rejected
offer's missed call takes it. A held-back call from a chat not accepted
is recorded, and its request listed, at that time too. Calls that ring
while Hush runs are still recorded when they end.
The sender chooses an envelope's timestamp: zero or negative hid a
held-back request and its missed call, and one in the future pinned the
request on top. Clamped as key changes are. Review fixes too: the call
router is tested end to end, an offer time that is missing is logged,
the engine test reports engine errors, and comments say what the code
does.
@pitis

pitis commented Nov 29, 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 and comments. None found anything Critical. The fixes are in 576f8f6. The gate (make format && make check) passes on the head merged with main.

Important

  1. The sender's timestamp was used without any check (silent-failure). It is the sender's to choose. A zero or negative value hid a held-back request (last_message_at stays 0) and put the missed call before the epoch, where the apps load events from 0 and never show it. A future value pinned the request to the top of the list.
    Fixed: call_sent_at clamps it to [server − 60 s, server], the way key_check already does for key changes. An honest sender's time passes unchanged. Test: a_calls_time_is_the_senders_within_reason, which failed against the unclamped helper.
  2. The router code between the tested pieces had no test (tests). Putting back either Utc::now() stamp the PR removed left every test green.
    Fixed: the_call_router_records_calls_at_their_time runs spawn_call_router on a LocalSet. It checks that a held-back offer is recorded at its envelope time and the engine's ChatEvent at its at. It failed with the old stamps put back.
    The one line still not covered is CallCommand::Incoming's sent_at_ms on the path that rings, because that path needs a linked account and identity keys. Only the types guard it.
  3. The engine test sat under the section comment "tested without the engine" (comments).
    Fixed: moved it next to the_call_actor_spawns_and_lists_devices.

Suggestions taken

  • If an offer's time is missing, the fallback now logs a warning (call id only). A test covers that a Rejected with no stored time is recorded at "now" (silent-failure, tests).
  • The engine test records events and prints them if it times out, so an engine that fails to start says why (silent-failure, tests).
  • Comments: the reason the map is kept across calls now lives on the offers field, and a misleading inline comment is gone. The hold_back_unaccepted_call doc now says the chat is listed from then only if it isn't listed yet.

Not changed

  • Record a call that rang (or connected) at its start, as Signal does (code). The issue asks to keep live calls sensible, and they are: a missed call that rang is recorded at most about a minute after its offer. Moving connected calls to their start time is a product choice for a follow-up.
  • A missed call from an accepted chat with no messages doesn't list the chat (code, silent-failure). This predates the PR (the engine path never calls list_chat, and refresh_summary ignores missed calls). It is noted in the PR body as a possible issue of its own.
  • Glare rejections are recorded as missed (silent-failure, not confident). This predates the PR and the PR doesn't change it.
  • Tests set shared.offers directly (tests, rated 1). This matches how the file already inspects shared.active, and the engine and router tests cover the real path.

@pitis
pitis merged commit 926a95b into main Nov 29, 2026
@pitis
pitis deleted the fix/missed-call-time branch November 29, 2026 16:31
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.

A missed call shows at the time of the call, not when Hush got its message

1 participant