fix 🐛: force iMessage service on buddy-based sends to prevent SMS fallback#40
Merged
LingJueYa~ (LingJueYa) merged 1 commit intophoton-hq:mainfrom Feb 27, 2026
Conversation
…lback When sending to a recipient by phone number or email, the AppleScript used a bare `buddy "recipient"` lookup with no service specified. On machines where both iMessage and SMS relay are active, Messages resolves the buddy against whichever service is default — often SMS — resulting in green bubble messages even when the recipient supports iMessage. Fix all four buddy-based send helpers to explicitly resolve the buddy against the iMessage service: set targetService to 1st service whose service type = iMessage set targetBuddy to buddy "<recipient>" of targetService Affected functions: - generateSendTextScript - generateSendWithAttachmentScript - generateSandboxBypassScript (file attachment helper) - generateDirectSendScript (file attachment helper) Chat ID-based sends (generateSendTextToChat etc.) are unaffected as they use `chat id "..."` which already resolves the correct service. Fixes photon-hq#39 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot started reviewing on behalf of
Ryan Zhu (underthestars-zhy)
February 27, 2026 00:28
View session
There was a problem hiding this comment.
Pull request overview
This PR updates the AppleScript generators used for “buddy”-based sends so Messages resolves recipients against the iMessage service explicitly, preventing unintended SMS (green bubble) fallback on systems with SMS relay enabled.
Changes:
- Force iMessage service resolution in
generateSendTextScript. - Force iMessage service resolution in attachment send helpers (direct send + sandbox bypass).
- Force iMessage service resolution in text+attachment combined send helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
When calling
sdk.send(recipient, text)with a phone number or email, messages are sent as SMS (green bubble) instead of iMessage (blue bubble), even when the recipient supports iMessage.The root cause is that
generateSendTextScriptand related buddy-based send helpers use a barebuddylookup with no service specified:On Macs where both iMessage and SMS relay are active, Messages resolves the buddy against whichever service is the default — often SMS.
Fix
Explicitly resolve the buddy against the iMessage service in all four buddy-based send helpers:
Affected functions
generateSendTextScriptgenerateSendWithAttachmentScriptgenerateSandboxBypassScript(file attachment helper)generateDirectSendScript(file attachment helper)Chat ID-based sends (
generateSendTextToChatetc.) are unaffected — they usechat id "..."which already resolves the correct service.Testing
All 283 existing tests pass. Manually verified blue bubble delivery on macOS with SMS relay enabled.
Closes #39