feat: resolve contact names for chat and message display#77
Closed
jsindy wants to merge 1 commit into
Closed
Conversation
Add macOS Contacts framework integration to resolve phone numbers and emails to contact display names. Names appear in chat listings, message history, watch streams, and all RPC payloads. - Add ContactResolver in IMsgCore with eager preload of all contacts - Enrich chats, history, watch, and RPC output with sender/contact names - Support `--to "Name"` in send command for name-based recipient lookup - Graceful fallback to raw handles when Contacts access is denied
|
We need this! LGTM. |
Collaborator
|
Thanks @jsindy. I landed a combined maintainer version on main in 5203f74. I kept the core shape from this PR: optional Contacts lookup, additive JSON/RPC fields ( Proof: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Phone numbers and emails in chat listings, message history, and watch streams are displayed as raw handles (
+14155551212) with no way to identify who they belong to. Thechatscommand'sdisplay_namefield is usually empty for 1:1 conversations since Messages.app doesn't populate it. There's also no way to send a message by contact name —--torequires a phone number or email.Solution
Add macOS Contacts framework integration that resolves handles to display names from the system address book.
New:
ContactResolverin IMsgCoreContactResolvingprotocol withNoOpContactResolverfallback when Contacts access is deniedPhoneNumberNormalizerfor consistent phone normalizationEnriched output across all surfaces
imsg chats[1] (+14155551212)[1] John Smith (+14155551212)imsg history[recv] +14155551212: hello[recv] John Smith: helloimsg watch[recv] +14155551212: hello[recv] John Smith: hello"sender": "+14155551212""sender": "+14155551212", "sender_name": "John Smith""contact_name": "John Smith"for 1:1 chatsSend by contact name
The resolver is only created when
--tolooks like a name (not phone/email), so--chat-idsends skip Contacts entirely.Changes
Sources/IMsgCore/ContactResolver.swiftPackage.swiftContactsframeworkSources/imsg/Resources/Info.plistNSContactsUsageDescriptionResources/imsg.entitlementsSources/imsg/OutputModels.swiftsender_name/contact_namefieldsSources/imsg/RPCPayloads.swiftSources/imsg/RPCServer.swiftcontactResolverpropertySources/imsg/RPCServer+Handlers.swiftSources/imsg/ChatTargetResolver.swiftlooksLikeName+resolveRecipientNameSources/imsg/Commands/ChatsCommand.swiftSources/imsg/Commands/HistoryCommand.swiftSources/imsg/Commands/WatchCommand.swiftSources/imsg/Commands/SendCommand.swift--to "Name"Sources/imsg/Commands/RpcCommand.swiftTests/Caveats
--to "Name"requires an unambiguous match; multiple matches produce an error with candidates listedTesting
swift buildpasses cleanlychats,history,watchsender_nameandcontact_namefields--to "Name"resolves and sends correctly