Skip to content

refactor ♻️: clean up iMessage service routing fix and eliminate redundant buddy/chat setup#41

Merged
LingJueYa~ (LingJueYa) merged 2 commits intomainfrom
fix/clean-imessage-service-routing
Feb 27, 2026
Merged

refactor ♻️: clean up iMessage service routing fix and eliminate redundant buddy/chat setup#41
LingJueYa~ (LingJueYa) merged 2 commits intomainfrom
fix/clean-imessage-service-routing

Conversation

@LingJueYa
Copy link
Copy Markdown
Collaborator

Summary

Cleans up the iMessage service routing fix from #40 by eliminating redundant targetBuddy / targetChat setup 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 = iMessage resolution. 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 errors
  • bun test — 286 pass / 0 fail (including 70+ security injection tests)

Related

Copilot AI review requested due to automatic review settings February 27, 2026 03:29
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 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/chatId parameters 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.

@LingJueYa LingJueYa~ (LingJueYa) merged commit 8a4d95d into main Feb 27, 2026
7 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.

2 participants