Renovate mitigation panels and messages
This commit is contained in:
@@ -495,6 +495,17 @@ INSIGHT_GRAPH_SPECS = [
|
||||
},
|
||||
]
|
||||
|
||||
INFORMATION_OVERVIEW_SLUGS = (
|
||||
"platform",
|
||||
"thread",
|
||||
"workspace_created",
|
||||
"stability_state",
|
||||
"stability_computed",
|
||||
"commitment_computed",
|
||||
"last_event",
|
||||
"last_ai_run",
|
||||
)
|
||||
|
||||
|
||||
def _format_unix_ms(ts):
|
||||
if not ts:
|
||||
@@ -892,6 +903,27 @@ def _all_graph_payload(conversation):
|
||||
return graphs
|
||||
|
||||
|
||||
def _information_overview_rows(conversation):
|
||||
latest_snapshot = conversation.metric_snapshots.first()
|
||||
rows = []
|
||||
for slug in INFORMATION_OVERVIEW_SLUGS:
|
||||
spec = INSIGHT_METRICS.get(slug)
|
||||
if not spec:
|
||||
continue
|
||||
rows.append(
|
||||
{
|
||||
"slug": slug,
|
||||
"title": spec.get("title") or slug.replace("_", " ").title(),
|
||||
"value": _format_metric_value(conversation, slug, latest_snapshot),
|
||||
"group": spec.get("group"),
|
||||
"group_title": INSIGHT_GROUPS.get(spec.get("group"), {}).get(
|
||||
"title", "Information"
|
||||
),
|
||||
}
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def _commitment_directionality_payload(conversation):
|
||||
latest_snapshot = conversation.metric_snapshots.first()
|
||||
inbound = conversation.commitment_inbound_score
|
||||
@@ -1574,6 +1606,26 @@ def _parse_result_sections(result_text):
|
||||
|
||||
|
||||
def _build_interaction_signals(operation, result_text, message_event_ids):
|
||||
def _normalize_signal_key(value):
|
||||
key = re.sub(r"[^a-z0-9]+", "_", str(value or "").strip().lower()).strip("_")
|
||||
if key == "open_loops":
|
||||
return "open_loop"
|
||||
return key
|
||||
|
||||
def _signal_display_label(label, key):
|
||||
if str(label or "").strip():
|
||||
return str(label).strip().title()
|
||||
return str(key or "Signal").replace("_", " ").strip().title()
|
||||
|
||||
meaning_by_key = {
|
||||
"repair": "Repair markers suggest active attempts to restore connection.",
|
||||
"de_escalation": "De-escalation markers suggest pressure reduction and safer tone.",
|
||||
"open_loop": "Open loops are unresolved topics likely to reappear later.",
|
||||
"risk": "Risk markers indicate escalating friction or potential rupture points.",
|
||||
"conflict": "Conflict markers indicate direct tension or adversarial framing.",
|
||||
"draft_generated": "Draft generation indicates actionable next-step options are available.",
|
||||
}
|
||||
|
||||
text = (result_text or "").lower()
|
||||
signals = []
|
||||
heuristics = [
|
||||
@@ -1585,17 +1637,25 @@ def _build_interaction_signals(operation, result_text, message_event_ids):
|
||||
]
|
||||
for label, token, valence in heuristics:
|
||||
if token in text:
|
||||
signal_key = _normalize_signal_key(label)
|
||||
signals.append(
|
||||
{
|
||||
"label": label,
|
||||
"display_label": _signal_display_label(label, signal_key),
|
||||
"signal_key": signal_key,
|
||||
"meaning": meaning_by_key.get(signal_key, ""),
|
||||
"valence": valence,
|
||||
"message_event_ids": message_event_ids[:6],
|
||||
}
|
||||
)
|
||||
if not signals and operation == "draft_reply":
|
||||
signal_key = _normalize_signal_key("draft_generated")
|
||||
signals.append(
|
||||
{
|
||||
"label": "draft_generated",
|
||||
"display_label": _signal_display_label("draft_generated", signal_key),
|
||||
"signal_key": signal_key,
|
||||
"meaning": meaning_by_key.get(signal_key, ""),
|
||||
"valence": "positive",
|
||||
"message_event_ids": message_event_ids[:3],
|
||||
}
|
||||
@@ -1662,12 +1722,26 @@ def _build_memory_proposals(operation, result_text):
|
||||
|
||||
|
||||
def _group_memory_proposals(memory_proposals):
|
||||
signal_keys_by_kind = {
|
||||
"open_loops": ["open_loop"],
|
||||
"emotional_state": ["de_escalation", "repair", "conflict"],
|
||||
"patterns": ["repair", "conflict"],
|
||||
"friction_loops": ["conflict", "risk"],
|
||||
"summary": ["open_loop", "repair", "de_escalation", "conflict", "risk"],
|
||||
"rules": ["repair", "conflict", "risk"],
|
||||
"insights": ["open_loop", "repair", "de_escalation", "conflict", "risk"],
|
||||
}
|
||||
grouped = {}
|
||||
for item in memory_proposals or []:
|
||||
label = str(item.get("kind_label") or item.get("kind") or "Insights").strip()
|
||||
key = label.lower()
|
||||
key = str(item.get("kind") or label).strip().lower()
|
||||
if key not in grouped:
|
||||
grouped[key] = {"title": label, "items": []}
|
||||
grouped[key] = {
|
||||
"title": label,
|
||||
"key": key,
|
||||
"signal_keys": list(signal_keys_by_kind.get(key, [])),
|
||||
"items": [],
|
||||
}
|
||||
grouped[key]["items"].append(item)
|
||||
return list(grouped.values())
|
||||
|
||||
@@ -3502,6 +3576,7 @@ class AIWorkspaceInformation(LoginRequiredMixin, View):
|
||||
"person": person,
|
||||
"workspace_conversation": conversation,
|
||||
"directionality": directionality,
|
||||
"overview_rows": _information_overview_rows(conversation),
|
||||
"commitment_graph_cards": commitment_graph_cards,
|
||||
"graphs_url": reverse(
|
||||
"ai_workspace_insight_graphs",
|
||||
|
||||
Reference in New Issue
Block a user