feat(teams): keep card body visible after approval button click

Pass cmd/desc in button action data so the card response can
reconstruct the original body. Clicking a button now replaces
only the actions with a status line, keeping the command and
reason text visible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aamir Jawaid 2026-04-30 06:05:00 +00:00 committed by Teknium
parent 39b0bc377c
commit 45780edbbf

View file

@ -411,12 +411,20 @@ class TeamsAdapter(BasePlatformAdapter):
"always": "✅ Always allowed", "always": "✅ Always allowed",
"deny": "❌ Denied", "deny": "❌ Denied",
} }
cmd = data.get("cmd", "")
desc = data.get("desc", "")
body = []
if cmd:
body.append(TextBlock(text="⚠️ Command Approval Required", wrap=True, weight="Bolder"))
body.append(TextBlock(text=f"```\n{cmd}\n```", wrap=True))
if desc:
body.append(TextBlock(text=f"Reason: {desc}", wrap=True, isSubtle=True))
body.append(TextBlock(text=label_map[choice], wrap=True, weight="Bolder"))
return InvokeResponse( return InvokeResponse(
status=200, status=200,
body=AdaptiveCardActionCardResponse( body=AdaptiveCardActionCardResponse(
value=AdaptiveCard() value=AdaptiveCard().with_version("1.4").with_body(body)
.with_version("1.4")
.with_body([TextBlock(text=label_map[choice], wrap=True, weight="Bolder")])
), ),
) )
@ -433,6 +441,12 @@ class TeamsAdapter(BasePlatformAdapter):
return SendResult(success=False, error="Teams app not initialized") return SendResult(success=False, error="Teams app not initialized")
cmd_preview = command[:2000] + "..." if len(command) > 2000 else command cmd_preview = command[:2000] + "..." if len(command) > 2000 else command
# Truncated for button data payload — just enough to reconstruct the card body.
btn_data_base = {
"session_key": session_key,
"cmd": command[:200] + "..." if len(command) > 200 else command,
"desc": description,
}
card = ( card = (
AdaptiveCard() AdaptiveCard()
@ -446,23 +460,23 @@ class TeamsAdapter(BasePlatformAdapter):
ExecuteAction( ExecuteAction(
title="Allow Once", title="Allow Once",
verb="hermes_approve", verb="hermes_approve",
data={"hermes_action": "approve_once", "session_key": session_key}, data={**btn_data_base, "hermes_action": "approve_once"},
style="positive", style="positive",
), ),
ExecuteAction( ExecuteAction(
title="Allow Session", title="Allow Session",
verb="hermes_approve", verb="hermes_approve",
data={"hermes_action": "approve_session", "session_key": session_key}, data={**btn_data_base, "hermes_action": "approve_session"},
), ),
ExecuteAction( ExecuteAction(
title="Always Allow", title="Always Allow",
verb="hermes_approve", verb="hermes_approve",
data={"hermes_action": "approve_always", "session_key": session_key}, data={**btn_data_base, "hermes_action": "approve_always"},
), ),
ExecuteAction( ExecuteAction(
title="Deny", title="Deny",
verb="hermes_approve", verb="hermes_approve",
data={"hermes_action": "deny", "session_key": session_key}, data={**btn_data_base, "hermes_action": "deny"},
style="destructive", style="destructive",
), ),
]) ])