Skip to content

Signal: start a chat with someone by username or phone number - #825

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/730-signal-username
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/730-signal-username

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

A Signal people search that is a username (name.42) asks Signal for that account and stores the person, so starting a chat opens a row titled with the username. A plain name, a phone number, and a username link are not sent to Signal.

Tested with cargo test -p chatd --no-default-features (a_username_lookup_opens_a_chat, a_username_shape_is_proven) and cargo clippy -p chatd --no-default-features --all-targets. Not tested: no live Signal, lab not run, no phone or CDSI lookup, no username links, no shell, and the signal-feature build was not compiled in this pass.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/signal-username

Lab run: not run

Compatibility

No protocol change. An older client still searches the people it already stored. This build adds one stored person when a username lookup succeeds.

Risk and rollback

A query that looks like a username is sent to Signal's username lookup. A wrong account id would open a chat with the wrong person. Revert this commit. Phone lookup stays off.

Release note

You can start a Signal chat by typing someone's username.

Closes #730

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟡 1 finding (0 blocking).

The PR adds Signal username lookup: a username-shaped query goes to libsignal's username lookup, the resolved account id is stored as a person, and everything else (names, phone numbers, signal.me links) never reaches Signal. The username validator faithfully mirrors libsignal's hard rules (checked against libsignal's username.rs and constants.rs: charset, the 48-char cap, and the 01 valid / 042 leading-zero / 00 zero discriminator cases); the lookup is bounded by the wire's existing 45-second answer timeout on the adapter's own command thread, and the fault log goes through redact. One defect: the stored PersonRow leaves avatar unset, and upsert_people sets avatar = excluded.avatar unconditionally, so a lookup that resolves to someone already stored nulls their picture and overwrites their known name with the username until the next connection re-fetches them. Every other upsert in this adapter passes ctx.avatar_of for exactly this reason.

Residual risk

  • Phone-number lookup, the other half of the PR title, is not implemented: a phone-shaped query only searches people already stored. The body says 'Phone lookup stays off', but the PR closes #730, which may name the whole feature.
  • A lookup that fails (network error, Signal rate limit) is indistinguishable from 'no such username' in the window: Ok(_) => {} and the warn go nowhere the user sees, so an empty result can look like an answer.
  • Every username-shaped SearchPeople is now one round trip to Signal on the serialized command thread, so a burst of searches queues behind sends for up to the 45-second answer bound.
  • The validator hard-codes libsignal's current hard rules; libsignal is pinned at fixed commits so drift is slow, but if Signal relaxes its username shape, valid usernames would silently not be searched until this filter is updated.

Ok(Some(aci)) if wire::is_aci(&aci) => {
account.live().names.entry(aci.clone()).or_insert_with(|| username.to_owned());
let _ = account.ctx.people(&[PersonRow {
id: aci,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Major: The PersonRow is built with avatar: None (from ..PersonRow::default()), and Context::people upserts with avatar = excluded.avatar unconditionally, so when a searched username resolves to a person chatd already stores (a phone contact, anyone messaged before), their stored picture is nulled and their stored name is replaced by the username even though the or_insert_with on the line just above deliberately keeps the known name in live.names. The picture stays gone until the next connection re-asks Signal. Pass the avatar through the way Event::Contacts does in this same file (avatar_of's own doc says 'so a row recorded again keeps it'); the borrow has to come before id moves aci, hence the field order in the suggestion.

Suggested change
id: aci,
avatar: account.ctx.avatar_of(&aci),
id: aci,

@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 2026
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.

Signal: start a chat with someone by username or phone number

2 participants