{% extends "base.html" %}
{% block title %}Sessions — MemoTrail{% endblock %}
{% block content %}
<h1>Sessions <small>({{ total }} total)</small></h1>

{% if project %}
<p>Filtered by project: <mark>{{ project }}</mark> <a href="/sessions">clear</a></p>
{% endif %}

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Project</th>
            <th>Started</th>
            <th>Messages</th>
            <th>Summary</th>
        </tr>
    </thead>
    <tbody>
        {% for s in sessions %}
        <tr>
            <td><a href="/sessions/{{ s.id }}">{{ s.id[:16] }}...</a></td>
            <td>
                {% if s.project %}
                <a href="/sessions?project={{ s.project }}">{{ s.project[:30] }}</a>
                {% else %}
                <em>unknown</em>
                {% endif %}
            </td>
            <td>{{ s.started_at[:16] }}</td>
            <td>{{ s.message_count }}</td>
            <td>{{ (s.summary or 'No summary')[:80] }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>

{% if total_pages > 1 %}
<nav>
    <ul>
        {% if page > 1 %}
        <li><a href="/sessions?page={{ page - 1 }}{% if project %}&project={{ project }}{% endif %}">Previous</a></li>
        {% endif %}
        <li>Page {{ page }} of {{ total_pages }}</li>
        {% if page < total_pages %}
        <li><a href="/sessions?page={{ page + 1 }}{% if project %}&project={{ project }}{% endif %}">Next</a></li>
        {% endif %}
    </ul>
</nav>
{% endif %}
{% endblock %}
