fix(photon): stop advertising fenced code-block support on iMessage
The gateway's tool-progress path emits terminal commands as fenced code blocks on any adapter whose supports_code_blocks is True. The Photon adapter set that flag from PHOTON_MARKDOWN, but the sidecar's /send router (send-format.mjs) silently routes every URL-bearing message through the plain-text builder — where fences survive as literal backtick characters — and even the markdown path renders a fence as inline monospace text, not a block. Net effect: raw fenced terminal commands (and raw markdown around them) surfaced in iMessage bubbles no matter what the user's prompt-level style rules said. Fix the whole class: the adapter never claims code-block support, so the gateway emits its compact one-line tool preview instead. Prose markdown passthrough (bold/italic/headings) is unchanged, and no config change is required — tool_progress can stay at its user's preferred mode. Tests: new capability + E2E tests pin that the gateway cannot emit a fence for Photon with real adapter + real display resolution; the old supports_code_blocks-mirrors-env expectation (which pinned the buggy behavior) now asserts the flag is always False.
This commit is contained in:
@@ -43,9 +43,16 @@ def test_format_message_passthrough_by_default(
|
||||
assert adapter.format_message(_MD) == _MD
|
||||
|
||||
|
||||
def test_supports_code_blocks_mirrors_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
def test_supports_code_blocks_never_enabled(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Fenced code blocks are not renderable on iMessage: URL-bearing
|
||||
messages fall back to raw text (literal fences), and the markdown path
|
||||
renders a fence as inline monospace, not a block. The adapter therefore
|
||||
never advertises code-block support — the gateway emits its compact
|
||||
one-line tool preview instead (see test_code_block_capability.py)."""
|
||||
monkeypatch.delenv("PHOTON_MARKDOWN", raising=False)
|
||||
assert _make_adapter(monkeypatch).supports_code_blocks is True
|
||||
assert _make_adapter(monkeypatch).supports_code_blocks is False
|
||||
monkeypatch.setenv("PHOTON_MARKDOWN", "false")
|
||||
assert _make_adapter(monkeypatch).supports_code_blocks is False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user