{% extends "base.html" %}
{% block title %}Session {{ session.id }} — MemoTrail{% endblock %}
{% block content %}
<h1>Session Detail</h1>

<article>
    <header>
        <strong>{{ session.id }}</strong>
    </header>
    <p>
        <strong>Project:</strong> {{ session.project or 'unknown' }}<br>
        <strong>Source:</strong> {{ session.source }}<br>
        <strong>Started:</strong> {{ session.started_at }}<br>
        <strong>Ended:</strong> {{ session.ended_at or 'ongoing' }}<br>
        <strong>Messages:</strong> {{ session.message_count }}<br>
        <strong>Tags:</strong> {{ session.tags | join(', ') if session.tags else 'none' }}
    </p>
    {% if session.summary %}
    <p><strong>Summary:</strong> {{ session.summary }}</p>
    {% endif %}
</article>

{% if decisions %}
<h2>Decisions ({{ decisions|length }})</h2>
<ul>
    {% for d in decisions %}
    <li><mark>{{ d.category }}</mark> {{ d.decision_text }}</li>
    {% endfor %}
</ul>
{% endif %}

<h2>Messages ({{ messages|length }})</h2>
{% for msg in messages[:100] %}
<article>
    <header>
        <strong>{{ msg.role }}</strong>
        <small>{{ msg.timestamp[:16] }}</small>
    </header>
    <pre style="white-space: pre-wrap; word-wrap: break-word;">{{ msg.content[:2000] }}</pre>
</article>
{% endfor %}

{% if messages|length > 100 %}
<p><em>... and {{ messages|length - 100 }} more messages</em></p>
{% endif %}

<a href="/sessions">&larr; Back to sessions</a>
{% endblock %}
