{# One copy of every repeated piece of markup. The full pages and the JSON poll endpoints both render these macros, so a change to an entry, a row or the action bar cannot drift between the two. ``entry`` and ``ticket_row`` take a view dataclass; the rest take the page. #} {% macro file_icon() -%} {%- endmacro %} {# Read-only files under a thread entry: images open the lightbox, everything else is a download link. The stored file name is never shown; only the original name the user uploaded. ``large`` turns the images into content-width previews; the agent reply keeps the compact thumbnails. #} {% macro file_list(files, large=false) -%} {% if files %} {% endif %} {%- endmacro %} {# The composer's/editor's pending files. Each chip carries the stored name and delete URL the uploader script needs; the upload script adds the same shape for files it is still sending. #} {% macro pending_files(files, target) -%} {% for f in files %}
  • {{ file_icon() }} {{ f.name }} {{ f.size }}
  • {% endfor %} {%- endmacro %} {% macro ticket_row(row) -%}
  • {%- if row.failed -%} {%- elif row.working -%} {%- elif row.unread -%} Unread. {%- endif -%} {{ row.title }}{% if row.summary %}{{ row.summary }}{% endif %} {{ row.id }} {{ row.repo }} {%- if row.failed %}Last turn failed{% endif -%}
  • {%- endmacro %} {% macro state_tag(page) -%} {{ page.state_label }} {%- endmacro %} {% macro new_badge(entry) -%} {% if entry.new %}New{% endif %} {%- endmacro %} {# The header copy control of a thread entry. Its value is the stored Markdown, so a paste keeps newlines and code fences instead of the rendered HTML; entries without a stored body (notices, alerts, an empty ticket text) do not get one, because a button that copies nothing looks broken. #} {% macro copy_markdown(entry) -%} {% if entry.markdown %}{% endif %} {%- endmacro %} {# Reading an agent reply aloud. ``speech_url`` is set only when the daemon has both keys and the reply has a body, so the gate needs no second copy in the template. The URL names the comment, never its text: the server looks the reply up itself. The script sets the busy, playing and error states on this button, swapping the speaker for a stop square while it plays. #} {% macro speak(entry) -%} {% if entry.speech_url %}{% endif %} {%- endmacro %} {# The model marker in an agent reply's header. The model's name, and then a coloured dot after this change, is all the header can spare: the token count, the New badge and the four controls have to share one line on a phone. The name stays available as hover and screen-reader text. The colour is a palette index derived from the alias's position in the configured model map; "unknown" is the grey dot for an id no alias maps to. #} {% macro model_dot(dot) -%} {{ dot.label }} {%- endmacro %} {% macro entry(entry) -%} {% if entry.kind == "user" %}
    {{ entry.who }}{{ new_badge(entry) }}{{ copy_markdown(entry) }}
    {{ entry.html|safe }}
    {{ file_list(entry.files, large=true) }}
    {% elif entry.kind == "agent" %}
    {{ entry.who }} {{ new_badge(entry) }} {% for item in entry.meta %}{{ item.text }}{% endfor %} {% if entry.model_dot %}{{ model_dot(entry.model_dot) }}{% endif %} {{ copy_markdown(entry) }} {{ speak(entry) }}
    {{ entry.html|safe }}
    {{ file_list(entry.files) }}
    {% elif entry.kind == "notice" %}

    {{ new_badge(entry) }}{{ entry.notice }}

    {% elif entry.kind == "error" %} {% elif entry.kind == "warning" %} {% endif %} {%- endmacro %} {% macro working(page) -%}

    Working, {{ page.working_for }}{% if page.last_output_ago %} ยท last output {{ page.last_output_ago }} ago{% endif %}

    {%- endmacro %} {# The running turn's steps, directly above the working line. The page renders this empty block and the first poll fills it (a page with no cursor asks for a replacement). The poll then appends list items only, so the block's own markup lives in one place. The stylesheet hides all but the last five steps unless the block carries ``steps--all``. #} {% macro steps_block() -%} {%- endmacro %} {# One step: quiet Markdown for the agent's text, one escaped line for a tool call. Only ``step.html`` is safe; the tool name and summary are Jinja's. #} {% macro step_item(step) -%}
  • {%- if step.kind == "text" -%}
    {{ step.html|safe }}
    {%- else -%} {{ step.tool }}{% if step.summary %}: {{ step.summary }}{% endif %} {%- endif -%}
  • {%- endmacro %} {% macro state_forms(page) -%} {% for action in page.state_actions %} {% endfor %} {%- endmacro %} {# An empty status slot beside the actions. The page script fills it when an upload is busy; it never carries server-rendered copy, but it stays in the markup in every state so ticket.js needs no branch for its absence. #} {% macro send_reason() -%} {%- endmacro %} {# The state menu lives in the composer tools, to the right of the Model select. The poll replaces its wrapper, so the button disappears in In Progress and the items follow the ticket's state without a reload. The items keep their form targets, ids and shortcuts; a hidden item still means the server offers that action, which is why app.js lets a shortcut activate one without the visibility check. #} {% macro state_menu(page) -%} {% if page.ticket.state == "Needs Input" or page.ticket.state == "QA" %} {% endif %} {%- endmacro %} {% macro composer_actions(page) -%} {% if page.ticket.state == "In Progress" %} {# Stop takes Send's place and its primary styling while a turn runs. Send is absent rather than disabled: a turn has to end before a reply can be posted, and the page script reads this absence as the disabled state. #} {{ send_reason() }} {% else %} {{ send_reason() }} {% endif %} {%- endmacro %} {% macro saved_indicator(saved_at) -%} {% if saved_at %}Saved {% endif %} {%- endmacro %} {# The Web Push opt-in bell. It is rendered only when the daemon has a push store, and push.js reveals it only for a browser that can subscribe and has not subscribed yet. The VAPID public key rides in a data attribute because the script has to hand it to pushManager.subscribe, and the CSP forbids inline script. #} {% macro push_bell(public_key) -%} {% if public_key %} {% endif %} {%- endmacro %} {# The Needs Input count badge and its screen-reader label. It sits beside the Tickets link in the dock, and beside the ticket page's back link because the phone layout hides the whole dock on that page. The wrapper carries hidden and the inner span the number; the server renders both from the count and app.js's setTitle keeps them in step with every poll. The label follows the number so a screen reader says "Tickets, 3 waiting on you" without needing a plural form. #} {% macro needs_input_dot(needs_input_count) -%} {{ needs_input_count }} waiting on you {%- endmacro %} {# The bottom dock, on every page. ``current`` names the one link marked aria-current: the page's own link, except on the editor (``new``), whose New ticket button is the current one. #} {% macro dock(current, needs_input_count) -%} {%- endmacro %} {% macro home_body(page) -%} {% if page.open_count == 0 %}

    Nothing open

    New tickets and anything waiting on you will appear here.

    {% else %}

    Tickets

    {% for group in page.groups %}

    {{ group.title }} {{ group.count }}

    {% if group.rows %} {% else %}

    {{ group.empty_text }}

    {% endif %}
    {% endfor %} {% endif %} {%- endmacro %} {% macro archive_body(page) -%}

    Archive

    Done tickets, newest first.

    Done {{ page.count }}

    {% if page.rows %} {% else %}

    No done tickets.

    {% endif %}
    {%- endmacro %}