Commit f21f047
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 17379c7 commit f21f047
4 files changed
Lines changed: 178 additions & 9 deletions
File tree
- src/chat_sdk/adapters
- slack
- telegram
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1729 | 1729 | | |
1730 | 1730 | | |
1731 | 1731 | | |
1732 | | - | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
1733 | 1741 | | |
1734 | 1742 | | |
1735 | 1743 | | |
| |||
1739 | 1747 | | |
1740 | 1748 | | |
1741 | 1749 | | |
1742 | | - | |
1743 | | - | |
1744 | | - | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
1745 | 1758 | | |
1746 | 1759 | | |
1747 | 1760 | | |
1748 | | - | |
1749 | | - | |
1750 | | - | |
1751 | | - | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
1752 | 1765 | | |
1753 | 1766 | | |
1754 | 1767 | | |
| |||
1860 | 1873 | | |
1861 | 1874 | | |
1862 | 1875 | | |
1863 | | - | |
| 1876 | + | |
1864 | 1877 | | |
1865 | 1878 | | |
1866 | 1879 | | |
| |||
1973 | 1986 | | |
1974 | 1987 | | |
1975 | 1988 | | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
1976 | 1995 | | |
1977 | 1996 | | |
1978 | 1997 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 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