{# Spec 153 - /chat page. Renders both states from a single template, branched on ``key_configured``: * State A - no LLM key set: empty pane + "Configure LLM" CTA linking to /admin/settings/llm. No chat input rendered. * State B - key set: streaming chat surface backed by Server-Sent Events from /chat/turn. Egress disclosure banner ALWAYS rendered above whichever state shows (FR-010). #} {% extends "layout.html" %} {% block content %}

Audit AI

{# Inline info toggle. The egress-disclosure banner is FR-010 and must remain reachable - collapsing it by default keeps the page chrome quiet, but the affordance lives one click away next to the title. Aria wiring keeps it screen-reader-usable. #}

Ask your audit data in plain English. Backed by the same tools the audit dashboard uses; numbers cited here match what the rest of the audit shows for the same metric.

{# Egress disclosure - FR-010. Collapsed by default; toggled by the info button next to the page title. The element remains in the DOM so screen readers can locate it via aria-controls. #} {# Privacy-banner toggle. Lives outside the State A / State B branches so the affordance works in both - even when chat isn't configured yet, the user can still pop the FR-010 disclosure open. #} {% if not key_configured %} {# ── State A - empty / unconfigured ────────────────────────── #}

Audit AI is disabled

To enable Audit AI, configure an LLM provider + API key in Settings. The audit will send your conversation content to that provider on every turn; nothing leaves your machine until you configure a key.

{% else %} {# ── State B - configured ────────────────────────────────── #} {# Two-column layout: chat on the left, starter questions on the right. Inline
{# Transcript area. Populated by the inline JS handler below. Sized so the scrollbar lives inside the panel; the input stays anchored at the bottom regardless of conversation length. #}

Ask anything about your audit data - or pick a starter question from the panel on the right.

{# Cost strip - server's CostEvent populates this. #}
Session cost: $0.0000 {% if chat_session_cap_usd > 0 %} / ${{ '%.2f' | format(chat_session_cap_usd) }} cap {% else %} (no cap) {% endif %}
{# Cap-reached overlay - initially hidden; shown when a turn comes back with DoneEvent(finish_reason="cost_cap"). #}
{# ── Starter questions panel ──────────────────────────────── Curated prompts covering the most-asked DB-admin questions. Click pre-fills the chat input (no auto-submit) so users can edit before sending. Grouped by topic so users skim by intent rather than reading a flat list. The set tracks the audit's full MCP tool surface - adding a tool here without a sample question makes the chat feel under-utilised. #}
{# /grid #} {% endif %}
{% endblock %}