Skip to content

Commit a20eeb1

Browse files
fix: address PR #41 review comments
- Fix versioning scheme description inconsistency in CHANGELOG.md - Extract _extract_action_values() helper in Teams adapter (was duplicated between _handle_message_action and _handle_adaptive_card_action) - GitHub raw dict duplication noted but not extracted (only 2 call sites with slight differences in the type/review_comment branching) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a579436 commit a20eeb1

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Synced to [Vercel Chat 4.25.0](https://github.com/vercel/chat). New versioning:
1212
- **Slack OAuth redirect fix**: `handle_oauth_callback` correctly forwards `redirect_uri` option.
1313

1414
### Versioning
15-
- Version scheme changed from `0.0.1aX` to `0.{upstream_minor}.{patch}`
15+
- Version scheme changed from `0.0.1aX` to `0.{upstream_major}.{upstream_minor}[.patch]`
1616
- `UPSTREAM_PARITY` constant in `chat_sdk.__init__` for programmatic access
1717
- Sync procedure documented in [UPSTREAM_SYNC.md](docs/UPSTREAM_SYNC.md)
1818

src/chat_sdk/adapters/teams/adapter.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,20 @@ async def _handle_message_activity(
350350

351351
self._chat.process_message(self, thread_id, message, options)
352352

353+
@staticmethod
354+
def _extract_action_values(action_data: dict[str, Any]) -> tuple[str, Any]:
355+
"""Extract action ID and submitted values from a Teams action payload.
356+
357+
For plain buttons: ``{"actionId": "btn", "value": "x"}`` → ``("btn", "x")``
358+
For ChoiceSet: ``{"actionId": "__auto_submit", "sel": "opt"}`` → ``("__auto_submit", {"sel": "opt"})``
359+
"""
360+
action_id = action_data.get("actionId", "")
361+
submitted_values: Any = {k: v for k, v in action_data.items() if k != "actionId"}
362+
# Unwrap single "value" key for plain button backward compat
363+
if list(submitted_values.keys()) == ["value"]:
364+
submitted_values = submitted_values["value"]
365+
return action_id, submitted_values
366+
353367
def _handle_message_action(
354368
self,
355369
activity: dict[str, Any],
@@ -377,13 +391,7 @@ def _handle_message_action(
377391
)
378392
)
379393

380-
# Extract action_id; pass remaining keys as value so ChoiceSet
381-
# input values are not dropped.
382-
action_id = action_value.get("actionId", "")
383-
submitted_values = {k: v for k, v in action_value.items() if k != "actionId"}
384-
# If there's a single "value" key, unwrap it for simple button clicks
385-
if list(submitted_values.keys()) == ["value"]:
386-
submitted_values = submitted_values["value"]
394+
action_id, submitted_values = self._extract_action_values(action_value)
387395

388396
from_user = activity.get("from", {})
389397
self._chat.process_action(
@@ -426,10 +434,7 @@ async def _handle_adaptive_card_action(
426434
)
427435
)
428436

429-
action_id = action_data.get("actionId", "")
430-
submitted_values = {k: v for k, v in action_data.items() if k != "actionId"}
431-
if list(submitted_values.keys()) == ["value"]:
432-
submitted_values = submitted_values["value"]
437+
action_id, submitted_values = self._extract_action_values(action_data)
433438

434439
from_user = activity.get("from", {})
435440
self._chat.process_action(

0 commit comments

Comments
 (0)