refactor ♻️: clean up iMessage service routing fix and eliminate redundant buddy/chat setup#41
Merged
LingJueYa~ (LingJueYa) merged 2 commits intomainfrom Feb 27, 2026
Conversation
…ndant buddy/chat setup
There was a problem hiding this comment.
Pull request overview
This pull request refactors the iMessage service routing implementation from PR #40 to eliminate redundant AppleScript variable setup. The refactoring moves targetService/targetBuddy/targetChat initialization from helper functions to entry-point functions, removing duplicate code while maintaining the correct iMessage service routing behavior.
Changes:
- Removed
recipient/chatIdparameters from helper functions that generate AppleScript snippets - Removed redundant service/buddy/chat setup from helper functions, keeping only in entry functions
- Added comprehensive tests to verify single occurrence of service/buddy setup across all affected functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/applescript.ts | Refactored helper functions to expect target variables in outer scope; removed redundant parameter escaping and variable setup from generateSandboxBypassScript, generateDirectSendScript, and their chat variants |
| tests/16-imessage-service-routing.test.ts | Added tests verifying that buddy/service setup occurs exactly once in generated scripts, covering both direct send and sandbox bypass paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…dep vulnerabilities
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.
Summary
Cleans up the iMessage service routing fix from #40 by eliminating redundant
targetBuddy/targetChatsetup in helper functions.Background
PR #40 correctly fixed a bug where buddy-based sends could fall back to SMS by adding explicit
1st service whose service type = iMessageresolution. However, the fix duplicated the service/buddy setup in both the entry functions and the helper snippets, resulting in the same AppleScript variables being set twice in the generated scripts.Verification
bun run lint— 0 errorsbun test— 286 pass / 0 fail (including 70+ security injection tests)Related