fix(telegram): 重設計訊息格式 + 修復 detail/reanalyze/history 按鈕失效
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 1m26s
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 1m26s
- format() / format_with_nemotron(): 移除 ═══ 分隔符,改為簡潔換行佈局 - send_approval_card(): 新增 incident_id 參數,傳入 _build_inline_keyboard() - decision_manager.py: 呼叫 send_approval_card() 時傳入 incident.incident_id - 問題根因: incident_id 未傳入 _build_inline_keyboard() 導致第二排按鈕從未渲染 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -139,6 +139,8 @@ async def _push_decision_to_telegram(
|
||||
nemotron_tools=nemotron_tools,
|
||||
nemotron_validation=nemotron_validation,
|
||||
nemotron_latency_ms=nemotron_latency_ms,
|
||||
# 2026-04-05 Claude Code: 傳入 incident_id 以啟用 detail/reanalyze/history 按鈕
|
||||
incident_id=incident.incident_id,
|
||||
)
|
||||
|
||||
# 🔴 發送成功後設置去重 key (TTL 10 分鐘)
|
||||
|
||||
@@ -271,25 +271,26 @@ class TelegramMessage:
|
||||
else:
|
||||
source_label = "⚙️ <b>規則匹配</b>"
|
||||
|
||||
# 2026-04-05 Claude Code: 重設計訊息格式,提升易讀性
|
||||
# 組裝訊息
|
||||
message = (
|
||||
f"═══════════════════════════\n"
|
||||
f"{self.status_emoji} <b>{html.escape(self.risk_level)}</b> | {html.escape(self.resource_name[:25])}\n"
|
||||
f"═══════════════════════════\n"
|
||||
f"📋 <code>{html.escape(incident_id)}</code>\n"
|
||||
f"🎯 資源: <code>{safe_resource}</code>\n"
|
||||
f"━━━━━━━━━━━━━━━━━━━\n"
|
||||
f"{source_label}\n"
|
||||
f"👥 責任: {resp_display}\n"
|
||||
f"📊 信心: {conf_emoji} {confidence_pct}%\n"
|
||||
f"{ai_cost_display}"
|
||||
f"💡 原因: {safe_root_cause}\n"
|
||||
f"{frequency_block}"
|
||||
f"{signoz_block}"
|
||||
f"━━━━━━━━━━━━━━━━━━━\n"
|
||||
f"🔧 建議: {safe_action}\n"
|
||||
f"{self.status_emoji} <b>{html.escape(self.risk_level)}</b> <code>{html.escape(incident_id)}</code>\n"
|
||||
f"<b>{safe_resource}</b>\n"
|
||||
f"\n"
|
||||
f"{source_label} {conf_emoji} {confidence_pct}%\n"
|
||||
f"👥 {resp_display}\n"
|
||||
f"💡 {safe_root_cause}\n"
|
||||
)
|
||||
if ai_cost_display:
|
||||
message += f"{ai_cost_display}"
|
||||
if frequency_block:
|
||||
message += f"\n{frequency_block}"
|
||||
if signoz_block:
|
||||
message += f"\n{signoz_block}"
|
||||
message += (
|
||||
f"\n🔧 <b>建議:</b> {safe_action}\n"
|
||||
f"⏱️ 停機: {safe_downtime}\n"
|
||||
f"🔍 <a href='{signoz_url}'>查看 SignOz Trace (±5min)</a>"
|
||||
f"🔍 <a href='{signoz_url}'>SignOz Trace</a>"
|
||||
)
|
||||
|
||||
return message[:900]
|
||||
@@ -397,21 +398,20 @@ class TelegramMessage:
|
||||
if self.nemotron_latency_ms > 0:
|
||||
nemotron_block += f"└ 延遲: {self.nemotron_latency_ms:.0f}ms\n"
|
||||
|
||||
# 2026-04-05 Claude Code: 重設計訊息格式,提升易讀性
|
||||
# 組裝訊息
|
||||
message = (
|
||||
f"═══════════════════════════\n"
|
||||
f"{self.status_emoji} <b>{html.escape(self.risk_level)}</b> | {html.escape(self.resource_name[:25])}\n"
|
||||
f"═══════════════════════════\n"
|
||||
f"📋 <code>{html.escape(incident_id)}</code>\n"
|
||||
f"🎯 資源: <code>{safe_resource}</code>\n"
|
||||
f"━━━━━━━━━━━━━━━━━━━\n"
|
||||
f"{source_label}\n"
|
||||
f"├ 📊 信心: {conf_emoji} {confidence_pct}%\n"
|
||||
f"├ 👥 責任: {resp_display}\n"
|
||||
f"└ 💡 原因: {safe_root_cause}\n"
|
||||
f"{nemotron_block}"
|
||||
f"━━━━━━━━━━━━━━━━━━━\n"
|
||||
f"🔧 建議: {safe_action}\n"
|
||||
f"{self.status_emoji} <b>{html.escape(self.risk_level)}</b> <code>{html.escape(incident_id)}</code>\n"
|
||||
f"<b>{safe_resource}</b>\n"
|
||||
f"\n"
|
||||
f"{source_label} {conf_emoji} {confidence_pct}%\n"
|
||||
f"👥 {resp_display}\n"
|
||||
f"💡 {safe_root_cause}\n"
|
||||
)
|
||||
if nemotron_block:
|
||||
message += f"\n{nemotron_block}"
|
||||
message += (
|
||||
f"\n🔧 <b>建議:</b> {safe_action}\n"
|
||||
f"⏱️ 停機: {safe_downtime}"
|
||||
)
|
||||
|
||||
@@ -1281,6 +1281,8 @@ class TelegramGateway:
|
||||
nemotron_tools: list[dict] | None = None,
|
||||
nemotron_validation: str = "",
|
||||
nemotron_latency_ms: float = 0.0,
|
||||
# 2026-04-05 Claude Code: incident_id 用於 detail/reanalyze/history 按鈕
|
||||
incident_id: str = "",
|
||||
) -> dict:
|
||||
"""
|
||||
推送待簽核卡片到 Telegram (v7.0 含 SignOz 整合)
|
||||
@@ -1330,6 +1332,7 @@ class TelegramGateway:
|
||||
suggested_action=suggested_action,
|
||||
estimated_downtime=estimated_downtime,
|
||||
approval_id=approval_id,
|
||||
incident_id=incident_id,
|
||||
primary_responsibility=primary_responsibility,
|
||||
confidence=confidence,
|
||||
namespace=namespace,
|
||||
@@ -1356,10 +1359,12 @@ class TelegramGateway:
|
||||
text = message.format_with_nemotron() if nemotron_enabled else message.format()
|
||||
|
||||
# 建立按鈕 (含自動調優)
|
||||
# 2026-04-05 Claude Code: 傳入 incident_id 以啟用 detail/reanalyze/history 按鈕
|
||||
keyboard = self._build_inline_keyboard(
|
||||
approval_id=approval_id,
|
||||
include_auto_tuning=bool(auto_tuning_command),
|
||||
auto_tuning_command=auto_tuning_command,
|
||||
incident_id=incident_id or message.incident_id,
|
||||
)
|
||||
|
||||
# 發送訊息
|
||||
|
||||
Reference in New Issue
Block a user