Skip to content

fix 🐛: force iMessage service on buddy-based sends to prevent SMS fallback#40

Merged
LingJueYa~ (LingJueYa) merged 1 commit intophoton-hq:mainfrom
mgoulart:fix/force-imessage-service-on-buddy-sends
Feb 27, 2026
Merged

fix 🐛: force iMessage service on buddy-based sends to prevent SMS fallback#40
LingJueYa~ (LingJueYa) merged 1 commit intophoton-hq:mainfrom
mgoulart:fix/force-imessage-service-on-buddy-sends

Conversation

@mgoulart
Copy link
Copy Markdown
Contributor

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 generateSendTextScript and related buddy-based send helpers use a bare buddy lookup with no service specified:

tell application "Messages"
    set targetBuddy to buddy "+1234567890"
    send "Hello" to targetBuddy
end tell

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:

tell application "Messages"
    set targetService to 1st service whose service type = iMessage
    set targetBuddy to buddy "+1234567890" of targetService
    send "Hello" to targetBuddy
end tell

Affected functions

  • generateSendTextScript
  • generateSendWithAttachmentScript
  • generateSandboxBypassScript (file attachment helper)
  • generateDirectSendScript (file attachment helper)

Chat ID-based sends (generateSendTextToChat etc.) are unaffected — they use chat 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

…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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@LingJueYa LingJueYa~ (LingJueYa) merged commit 0da0e8d into photon-hq:main Feb 27, 2026
9 of 10 checks passed
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.

sdk.send() sends as SMS (green bubble) instead of iMessage when no service is specified

3 participants