#{{ provider_thread_id or ticket.id }}
{% if provider_thread_id %}
open_in_new
{% endif %}
{% if ticket.thread.customer_hash %}
{% endif %}
{# Row 1b: product icon + name + customer website #}
{% if ticket.thread.product_name or ticket.thread.customer_website %}
{% if product and product.product_type == 'business_care' %}
BC
{% elif product and product.pico_url %}
{% endif %}
{% if ticket.thread.product_name %}
{{ ticket.thread.product_name }}
{% endif %}
{% if ticket.thread.customer_website %}
{% set ws_href = ticket.thread.customer_website if ticket.thread.customer_website.startswith('http') else 'https://' + ticket.thread.customer_website %}
{% if site_check and site_check.is_online == true %}
{% set tip = 'Online' %}
{% if site_check.error_message %}{% set tip = 'Online (' ~ site_check.http_status ~ ' — ' ~ site_check.error_message ~ ')' %}
{% elif site_check.http_status %}{% set tip = 'Online (' ~ site_check.http_status ~ ', ' ~ (site_check.response_time_ms or '?') ~ 'ms)' %}{% endif %}
{% elif site_check and site_check.is_online == false %}
{% set tip = 'Offline' %}
{% if site_check.error_message %}{% set tip = 'Offline — ' ~ site_check.error_message %}{% endif %}
{% endif %}
{{ ticket.thread.customer_website | truncate(32) }}
{% endif %}
{% endif %}
{# -- Second row: controls + info -- #}
{# Support contract status — only show if we have actual support data (zen_type or has_support) #}
{% if ticket.thread.zen_type or ticket.thread.has_support is not none %}
{% if ticket.thread.has_support %}
verified
{{ ticket.thread.support_type or 'Support Active' }}
{% elif ticket.thread.is_support_expired %}
error
Support Expired
{% else %}
check_circle
Support Active
{% endif %}
{% endif %}
{# Intent / sentiment badge from latest AI classification #}
{% if suggestions %}
{% set _latest_s = suggestions|sort(attribute='created_at', reverse=True)|first %}
{% set _intent = (_latest_s.classification_json|fromjson).get('intent_category', '') %}
{% if _intent %}
{% set _intent_map = {
'angry': ['red', 'sentiment_very_dissatisfied'],
'escalation': ['red', 'priority_high'],
'complaint': ['orange', 'feedback'],
'refund': ['orange', 'currency_exchange'],
'bug': ['amber', 'bug_report'],
'question': ['blue', 'help'],
'config': ['blue', 'settings'],
'help': ['blue', 'support_agent'],
'feature_request': ['purple', 'lightbulb'],
'thanks_solved': ['green', 'check_circle']
} %}
{% set _style = _intent_map.get(_intent, ['gray', 'label']) %}
{{ _style[1] }}
{{ _intent | replace('_', ' ') | title }}
{% endif %}
{% endif %}
{# Customer language — manual override (any language, not limited to what support knows) #}
{% if not ticket.first_response_at %}
{% endif %}
{# -- Thread Summary / TL;DR -- shown when no segments, otherwise integrated into topic overlay #}
{% if thread_summary and segments|length <= 1 %}
summarize
Thread Summary
{{ thread_summary }}
{% endif %}
{# -- Review request banner -- #}
{% if is_review_request and ticket.status == 'closed' and not ticket.is_read %}
sentiment_very_satisfied
Happy customer — time for a review request!
This customer sent a thank-you on a closed ticket. Reply to
clear the Addons "unanswered" counter and
earn a positive rating.
{% endif %}
{# -- Conversation thread -- #}
{# Floating topic overlay — single pill, updated via JS #}
{% if segments|length > 1 %}
{# Expandable per-topic summary panel under the pill #}
{% endif %}
{% set ns = namespace(prev_seg=-1) %}
{% for msg in messages %}
{% set cur_seg = message_segment_map.get(msg.id, -1) %}
{% if cur_seg != ns.prev_seg and cur_seg >= 0 %}
{# Inline topic marker (not sticky — observed by JS) #}
topic
{{ segments[cur_seg].label if cur_seg < segments|length else 'Topic' }}
{% set ns.prev_seg = cur_seg %}
{% endif %}
{% if scroll_to_message_id and msg.id == scroll_to_message_id %}