From 43e7b97c0f508a4c7fe760b73916592af9bb7ecc Mon Sep 17 00:00:00 2001 From: ex_tianzy Date: Thu, 12 Nov 2026 16:21:10 +0800 Subject: [PATCH] fix(work): mark interrupted tasks red independently of reply delivery --- deployable/relay/task_cards.py | 2 +- deployable/tests/test_task_cards.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/deployable/relay/task_cards.py b/deployable/relay/task_cards.py index d906032..3dcb726 100644 --- a/deployable/relay/task_cards.py +++ b/deployable/relay/task_cards.py @@ -12,7 +12,7 @@ DELIVERY={None:'尚未接收结果','ready':'已接收结果,等待投递','se def card_content(task_id,execution,delivery,files=None): execution=execution if execution in EXECUTION else 'unknown' - color='green' if execution=='completed' else 'red' if execution=='failed' else 'orange' if execution in {'waiting_for_approval','unknown'} else 'blue' + color='green' if execution=='completed' else 'red' if execution in {'failed','interrupted'} else 'orange' if execution in {'waiting_for_approval','unknown'} else 'blue' elements=[{'tag':'div','text':{'tag':'plain_text','content':'任务状态:'+EXECUTION[execution]}}, {'tag':'div','text':{'tag':'plain_text','content':'文字回复:'+DELIVERY.get(delivery,'状态待核对')}}, {'tag':'note','elements':[{'tag':'plain_text','content':'任务编号:'+task_id}]}] diff --git a/deployable/tests/test_task_cards.py b/deployable/tests/test_task_cards.py index f52211a..42c96bd 100644 --- a/deployable/tests/test_task_cards.py +++ b/deployable/tests/test_task_cards.py @@ -124,6 +124,16 @@ def test_text_delivery_never_claims_attachments_delivered(): assert '已发送1件,待投递1件,异常或待核对1件' in mixed +@pytest.mark.parametrize('state,color',[ + ('running','blue'),('waiting_for_approval','orange'),('unknown','orange'), + ('completed','green'),('failed','red'),('interrupted','red')]) +def test_execution_color_is_independent_of_text_delivery(state,color): + card=card_content('synthetic',state,'replied',[]) + assert card['header']['template']==color + if state=='interrupted': + assert '已中断' in json.dumps(card,ensure_ascii=False) + + async def test_card_uses_task_bound_source_and_skips_foreign_and_expired(env,monkeypatch): task(env);cards,calls,clock=setup_cards(env,monkeypatch) with env['store'].db: