{% from "_macros.html" import icon %}
{#
  New chat, and New folder.

  Its own partial because "New chat" changes with the Chat/Agent switch and this
  row sits *outside* the tree the switch swaps -- above the scroll area, so it
  does not scroll away. It arrives out of band instead, the move the `done`
  frame already makes for the chat title.

  It was not a partial to begin with, and the button went on saying "New chat"
  after the switch moved to Agents while the tree beneath it showed agent chats.
  Whether it worked was not the question: it said one thing and did another,
  which is exactly the shape of failure the switch itself was arranged to avoid.
#}
{% if can.get("chat.create") or can.get("folder.manage") %}
<div class="sidebar__actions" id="sidebar-actions"
     {% if oob %}hx-swap-oob="true"{% endif %}>
  {% if can.get("chat.create") %}
  {# Carries the side the switch is on, so this opens the new-chat screen
     already on the right fork. #}
  <a class="btn btn--primary btn--grow"
     href="/chat{{ '?kind=agent' if sidebar_kind == 'agent' else '' }}">
    {{ icon("plus", "icon--sm") }}
    {{ "New agent chat" if sidebar_kind == "agent" else "New chat" }}
  </a>
  {% endif %}
  {% if can.get("folder.manage") %}
  {# Asks for the name rather than making "New folder" and leaving somebody to
     find the rename. `data-prompt` writes the answer into hx-vals before the
     request goes out; see ui.js for why this is not htmx's own hx-prompt. #}
  <button class="btn btn--icon" hx-post="/api/folders" hx-swap="none"
          data-prompt="What should this folder be called?"
          data-prompt-title="New folder" data-prompt-field="name"
          data-prompt-label="Create"
          aria-label="New folder" title="New folder">
    {{ icon("folder") }}
  </button>
  {% endif %}
</div>
{% endif %}
