{#- The chats of a project as the chats pane lists them, from `project`, `chats`, `marks`, `access` and `current_chat_id`: the chat the page shows, or none. Every page inside a project includes it. `marks` is by chat id: the mark before the title, for a chat that has one. A chat with no title yet is muted. After the title stands how long ago something last happened in the chat. At `full` each chat has a menu. At `propose` only a chat with no title has one, to name it. The menu and the field that renames the chat are placed by the row of the chat, which gives them an anchor name of its own. The chats in the trash stand under the rest, folded away with their count; the fold is there only while the trash holds a chat. It starts open on a page that shows a chat of the trash. After that the morph leaves it as the user left it: `open` is on the `morphIgnore` list of htmx. The list fetches itself again when `chats` fires on it: the answer to a request that changed a title, a mark or the trash fires it. It also fetches itself every second while an agent works in the project, and stops when the server gives it without `every`. An agent started from another window while none worked shows only when the page is loaded again. The morph changes only what differs, so an open menu or field stays. Of the fetches asked for while one is on its way only the last is sent: an older answer never lands over a newer one. -#} {% set mark_texts = {"working": "An agent works here", "proposal": "A proposal waits here", "new": "A new answer", "failed": "The answer failed or was stopped"} %} {#- The attributes of a form in the menu of `chat` that posts `action`: `trash` or `restore`. For the chat the page shows it is a plain form: the page it shows changes, so the answer is a redirect. For any other chat htmx posts it and the page stays. The answer then has no body: it fires `chats`, and the list comes anew. The menu is deleted, not left to the morph, which would keep it open; the list brings a closed one. -#} {% macro posts(chat, action) -%} {% if chat.id == current_chat_id %}method="post" action="/chats/{{ chat.id }}/{{ action }}"{% else %}hx-post="/chats/{{ chat.id }}/{{ action }}" hx-target="closest .menu" hx-swap="delete"{% endif %} {%- endmacro %} {#- The row of `chat` in the list. -#} {% macro row(chat) %} {% set mark = marks.get(chat.id) %}
No chats yet.
{% endif %} {% if trash %}