Skip to content

Teams card_to_adaptive_card divider renders zero-height (empty Container with separator: True) #45

@patrick-chinchill

Description

@patrick-chinchill

Summary

card_to_adaptive_card converts a divider child into an empty Container with separator: True. Microsoft Teams renders this container at zero height because it has no items, so the separator line is effectively invisible and does not span the card width.

Location

src/chat_sdk/adapters/teams/cards.py, _convert_child_to_adaptive (~L119):

if child_type == "divider":
    return {
        "elements": [{"type": "Container", "separator": True, "items": []}],
        "actions": [],
    }

Expected

The divider should render as a full-width separator line. One option is to hoist separator: True onto the next sibling element instead of emitting an empty container — e.g. during post-processing of the body array, pop any empty-container divider and set separator: True on the following element.

Repro

from chat_sdk.cards import Card, Divider, TextBlock
from chat_sdk.adapters.teams.cards import card_to_adaptive_card

card = Card(children=[TextBlock("above"), Divider(), TextBlock("below")])
payload = card_to_adaptive_card(card)
# Send payload to Teams: no visible divider between "above" and "below".

Workaround (in consuming code)

Wrap card_to_adaptive_card and post-process its output to hoist separators onto the next non-divider element in body, then drop the empty container.


Upstream TS parity

Vercel TS (vercel/chat) has the same bug in packages/adapter-teams/src/cards.ts:

function convertDividerToElement(_element: DividerElement): Container {
  return new Container().withSeparator(true);
}

Per UPSTREAM_SYNC.md ("upstream behavior is input not source of truth"), this is a valid divergence: fix in the Python port now rather than waiting for upstream. Document the divergence in UPSTREAM_SYNC.md under Teams-adapter divergences, and add a regression test. A courtesy issue can be filed on vercel/chat suggesting the same fix, but it should not block this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions