Commit c84fd1d
committed
fix(slack,telegram): align unfurl merge with TS spread + small parity fixes
Address review findings on the chat@4.27.0 adapter bug-fix sweep:
1. Slack ``_merge_unfurl_into_preview``: TS does
``{ ...preview, ...unfurl }`` which lets unfurl OVERRIDE the
preview's existing fields (except ``title``, which is short-
circuited at the ``_enrich_links`` call site when the preview
already has one). The previous Python implementation preserved
non-None preview fields, so a preview that picked up a description
from one source could never be overwritten by a more authoritative
unfurl. Switch to "unfurl wins when present" semantics for
``description`` / ``image_url`` / ``site_name``; ``title`` matches
TS via the existing ``_enrich_links`` short-circuit. Add a
regression test (``preview.description = "old"``,
``unfurl.description = "new"`` -> output is ``"new"``).
2. Slack ``_TRAILING_SLASH_PATTERN.sub("", url)``: TS
``url.replace(TRAILING_SLASH_PATTERN, "")`` strips a single
trailing ``/``; Python's ``re.sub`` defaults to all matches. Pin
``count=1`` for parity (also locks down behaviour if the regex
ever loosens beyond an end-anchored match).
3. Slack: regression test that two ``message_changed`` events for the
same message ts overwrite the cached unfurl (rather than merging
in stale entries). Locks in the ``state.set(...)`` overwrite
semantics that the 1h cache TTL relies on.
4. Slack ``_extract_links``: regression test that a URL containing
an unbalanced ``(`` survives the angle-bracket regex (a tightening
of the URL pattern would silently drop wikipedia-style links).
5. Slack ``_enrich_links`` call site: comment noting that each
message containing a not-yet-unfurled link adds up to ~2s of
latency worst-case (``_UNFURL_WAIT_MS``).
6. Telegram MarkdownV2 renderer fallback: comment explaining the
trade-off vs upstream's ``node satisfies never`` exhaustive check
(Python silently degrades unknown nodes to escaped text rather
than raising, prioritising delivery over compile-time signal).
7. Slack ``test_slack_format.py``: add a missing test for the bare-
mention regex with an email tail (``@user@example.com`` ->
``<@user>@example.com``) — pins the boundary case between a real
mention and an email-style suffix glued to it.
https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj1 parent acfff9e commit c84fd1d
3 files changed
Lines changed: 162 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1775 | 1775 | | |
1776 | 1776 | | |
1777 | 1777 | | |
1778 | | - | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
1779 | 1787 | | |
1780 | 1788 | | |
1781 | 1789 | | |
| |||
1785 | 1793 | | |
1786 | 1794 | | |
1787 | 1795 | | |
1788 | | - | |
1789 | | - | |
1790 | | - | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1791 | 1804 | | |
1792 | 1805 | | |
1793 | 1806 | | |
1794 | | - | |
1795 | | - | |
1796 | | - | |
1797 | | - | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
1798 | 1811 | | |
1799 | 1812 | | |
1800 | 1813 | | |
| |||
1906 | 1919 | | |
1907 | 1920 | | |
1908 | 1921 | | |
1909 | | - | |
| 1922 | + | |
1910 | 1923 | | |
1911 | 1924 | | |
1912 | 1925 | | |
| |||
2019 | 2032 | | |
2020 | 2033 | | |
2021 | 2034 | | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
2022 | 2041 | | |
2023 | 2042 | | |
2024 | 2043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
158 | 168 | | |
159 | 169 | | |
160 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
0 commit comments