diff --git a/src/langbot/libs/dingtalk_api/a2ui.py b/src/langbot/libs/dingtalk_api/a2ui.py index c2322da75..b5c939a1f 100644 --- a/src/langbot/libs/dingtalk_api/a2ui.py +++ b/src/langbot/libs/dingtalk_api/a2ui.py @@ -122,7 +122,7 @@ def text_card_components() -> list[dict[str, typing.Any]]: { 'id': 'root', 'component': 'Column', - 'children': ['content', 'langbot-brand'], + 'children': ['langbot-brand', 'content'], 'gap': 8, }, { diff --git a/src/langbot/pkg/platform/adapters/dingtalk/interaction.py b/src/langbot/pkg/platform/adapters/dingtalk/interaction.py index a36e89375..f97cc955c 100644 --- a/src/langbot/pkg/platform/adapters/dingtalk/interaction.py +++ b/src/langbot/pkg/platform/adapters/dingtalk/interaction.py @@ -150,7 +150,7 @@ def _build_interaction_messages( ) children.append(button_id) - children.append('langbot-brand') + children.insert(0, 'langbot-brand') components.extend(brand_components()) components.insert(0, {'id': 'root', 'component': 'Column', 'children': children, 'gap': 12}) return {'form': form}, components, field_types diff --git a/src/langbot/pkg/platform/sources/dingtalk.py b/src/langbot/pkg/platform/sources/dingtalk.py index e1ca4f7f8..d984af805 100644 --- a/src/langbot/pkg/platform/sources/dingtalk.py +++ b/src/langbot/pkg/platform/sources/dingtalk.py @@ -520,7 +520,7 @@ def _dingtalk_a2ui_form( ] ) children.append(button_id) - children.append('langbot-brand') + children.insert(0, 'langbot-brand') components.extend(brand_components()) return data, components diff --git a/tests/unit_tests/platform/test_dingtalk_adapter.py b/tests/unit_tests/platform/test_dingtalk_adapter.py index a5fb28382..02eba76d1 100644 --- a/tests/unit_tests/platform/test_dingtalk_adapter.py +++ b/tests/unit_tests/platform/test_dingtalk_adapter.py @@ -53,7 +53,7 @@ def test_dingtalk_dify_input_card_uses_a2ui_binding_and_required_check(): assert field['value'] == {'path': '/form/value'} assert button['action']['event']['context']['input'] == {'path': '/form/value'} assert button['checks'][0]['condition']['call'] == 'required' - assert components[0]['children'][-1] == 'langbot-brand' + assert components[0]['children'][0] == 'langbot-brand' assert any(component['id'] == 'langbot-brand-link' for component in components) diff --git a/tests/unit_tests/platform/test_dingtalk_api.py b/tests/unit_tests/platform/test_dingtalk_api.py index 05a4eadcc..73ead0fd6 100644 --- a/tests/unit_tests/platform/test_dingtalk_api.py +++ b/tests/unit_tests/platform/test_dingtalk_api.py @@ -35,7 +35,7 @@ def test_text_card_keeps_brand_when_content_updates(): components = create_text_card_messages('surface-id', 'hello')[2]['updateComponents']['components'] by_id = {component['id']: component for component in components} - assert by_id['root']['children'] == ['content', 'langbot-brand'] + assert by_id['root']['children'] == ['langbot-brand', 'content'] assert by_id['langbot-brand']['children'] == ['langbot-brand-icon', 'langbot-brand-link'] assert by_id['langbot-brand-icon']['url'] == 'https://langbot.app/logo-blue.png' assert by_id['langbot-brand-icon']['previewEnabled'] is False diff --git a/tests/unit_tests/platform/test_dingtalk_eba_adapter.py b/tests/unit_tests/platform/test_dingtalk_eba_adapter.py index 280a4f48e..916311f6a 100644 --- a/tests/unit_tests/platform/test_dingtalk_eba_adapter.py +++ b/tests/unit_tests/platform/test_dingtalk_eba_adapter.py @@ -342,7 +342,7 @@ async def test_dingtalk_interaction_delivery_and_callback_event(): components = kwargs['a2ui_messages'][2]['updateComponents']['components'] button = next(component for component in components if component['component'] == 'Button') assert button['action']['event']['context']['actionId'] == 'lbi:callback-token:a:0' - assert components[0]['children'][-1] == 'langbot-brand' + assert components[0]['children'][0] == 'langbot-brand' assert any(component['id'] == 'langbot-brand-link' for component in components) native = dingtalk_card_callback_event(