{% from "_macros.html" import model_avatar %}
{#
  Shortcuts to start a chat with a particular model. These link rather than
  post, so no chat exists until something is actually said.

  Its own partial, and always rendered even when empty, because the Chat/Agent
  switch changes what they link to and they sit above the tree the switch
  swaps -- so they arrive out of band, exactly as the New chat button does. An
  empty div is what lets that swap find its target: a block that vanished when
  the last model was unpinned would leave the out-of-band fragment with nowhere
  to land, and htmx says nothing when a target is missing.
#}
<div class="nav-group nav-group--pinned" id="sidebar-pinned"
     {% if oob %}hx-swap-oob="true"{% endif %}>
  {% if pinned_models and can.get("chat.create") %}
  <div class="nav-group__label">Pinned models</div>
  {% for model in pinned_models %}
  {# Carries the side the switch is on. Picking a pinned model on the Agent
     side used to open an ordinary chat, which is the fork silently ignoring the
     one choice already made. `?kind=` is a preselection like `?model=` itself:
     the new-chat screen still decides, and nothing is fixed until the first
     message is sent. #}
  <a class="nav-item nav-item--model"
     href="/chat?model={{ model.model_id }}{{ '&kind=agent' if sidebar_kind == 'agent' else '' }}">
    {{ model_avatar(model, cls="nav-item__avatar") }}
    <span class="nav-item__label">{{ model.label }}</span>
  </a>
  {% endfor %}
  {% endif %}
</div>
