Skip to content

fix(photon): disable iMessage data detection on styled sends - #88506

Closed
fluxkapacitor wants to merge 1 commit into
NousResearch:mainfrom
fluxkapacitor:fix/photon-markdown-url-data-detection
Closed

fluxkapacitor wants to merge 1 commit into
NousResearch:mainfrom
fluxkapacitor:fix/photon-markdown-url-data-detection

Conversation

@fluxkapacitor

@fluxkapacitor fluxkapacitor commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Markdown messages containing raw URLs 500 in the Photon iMessage provider. The styled send path (plain string + UTF-16 formatting ranges) never sets enableDataDetection on sendText, so the server defaults data detection ON for styled sends — and a raw URL in the text trips it. The previous workaround (send-format.mjs chooseSendFormat) routed URL-bearing markdown to plain text, silently dropping all formatting.

This PR fixes the class at the provider layer: the sidecar's existing pinned-SDK patch mechanism (patch-spectrum-mixed-attachments.mjs precedent) now rewrites @spectrum-ts/imessage's two styled outbound call sites to pass enableDataDetection: false explicitly:

  1. sendContent's markdown case → sendText(..., { enableDataDetection: false }) (single-content sends — the path /send uses)
  2. send$1's group branch → sendMultipart(..., { enableDataDetection: false }) (group/multipart sends — same 500 class on styled parts)

Result: markdown with URLs sends as one styled message, URL embedded and auto-linked by iMessage. The sidecar's /send no longer needs the URL-gate and sends markdown as markdown. The patch joins the existing postinstall chain so fresh installs get both patches.

Why this shape

  • The SDK accepts options.enableDataDetection on both sendText and sendMultipart (see @photon-ai/advanced-imessage) — the provider just never passes it. Explicit false overrides the server default; proven live (below).
  • The patch is anchor-based with loud failure: if a future spectrum-ts reshapes the provider, the sidecar exits with a clear error rather than silently 500ing sends.
  • Patch-on-startup is the established pattern for this SDK's bugs (patch-spectrum-mixed-attachments.mjs); it self-heals existing installs without an npm bump, and spectrum-ts pins exactly because it ships breaking majors.

Prior art (this is not a duplicate)

Verification

  • Live E2E (real bridge, real iMessage): applied the identical patch to the installed SDK, sent **bold** + https://example.com through the real provider → returned messageId, arrived as one bubble, bold intact, URL tappable. (Baseline: unstyled sends work; the styled+URL path is the documented 500.)
  • Tests: new test_url_markdown_patch.py (6 tests: applies to real anchors, idempotent via marker, fails loudly on reshaped SDK, fails loudly when SDK missing, preserves CRLF). Neighbors test_url_send_path.py + test_spectrum_patch.py green — 15/15.
  • node --check on both .mjs files; package.json JSON-valid.

Follow-up (not in this diff)

send-format.mjs's chooseSendFormat is now unused by the sidecar (its module tests still pass). Removing the dead workaround is a separate cleanup — keeping this PR minimal.

Markdown messages containing raw URLs 500 in the iMessage provider: the
styled send path (text + UTF-16 formatting ranges) defaults server-side
data detection ON, and a URL in the text trips it. The previous workaround
routed URL-bearing markdown to plain text, losing all formatting.

Patch @spectrum-ts/imessage's two styled outbound call sites to pass
enableDataDetection: false explicitly (sendContent markdown case and the
group sendMultipart call), so URL-bearing markdown sends as ONE styled
message with the URL embedded. Verified live against the real bridge:
markdown + URL arrives as a single bubble, bold intact, link tappable.

The sidecar no longer needs the chooseSendFormat URL-gate and sends
markdown as markdown. send-format.mjs is left in place (its module-level
tests still pass); removing the now-dead workaround is a follow-up.
@fluxkapacitor
fluxkapacitor force-pushed the fix/photon-markdown-url-data-detection branch from 3ee4117 to 1e1289b Compare August 17, 2026 16:13
@fluxkapacitor
fluxkapacitor requested a review from a team August 17, 2026 16:13
@fluxkapacitor

Copy link
Copy Markdown
Contributor Author

Closing — no longer needed. The styled+URL 500 is avoided on this project via a Photon-side setting ('replies as markdown?'), verified live with pure upstream code; running raw clean. Thanks for the merge of the original workaround in #73615 either way.

@fluxkapacitor
fluxkapacitor deleted the fix/photon-markdown-url-data-detection branch August 17, 2026 16:19
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants