Fix bulk actions, create chats lazily, rework the UI

Seven reported problems.

**Bulk model actions 404'd.** /admin/models/{model_id} was registered
before /admin/models/bulk, and FastAPI matches in registration order, so
"bulk" was parsed as a model id. Moved above the parameterised route,
with a comment saying why, and a regression test.

**Empty chats piled up.** There is now no endpoint that creates one.
"New chat" is a link to /chat, which renders a composer with no row
behind it, and POST /api/chats/start writes the chat together with its
first message. Opening one and walking away leaves nothing.

**Pinning meant two different things.** The picker is now always in the
administrator's position order; pinned models get shortcuts in the chat
sidebar and nothing else. A picker whose order silently differs from the
admin screen is just confusing.

**Model images were missing in chat.** Assistant bubbles now show the
avatar of the model that actually wrote the turn -- which is not always
the model the chat is set to now -- falling back to the LLeMbas mark.
The picker shows it too.

**No global or per-model system prompt.** Three layers now: instance
(Admin -> General), model (Admin -> Models), chat. Precedence, not
concatenation: most specific wins outright. Stacking them reads well in
a settings screen and badly in practice, because two layers that
disagree give the model contradictory instructions and nobody can tell
which is losing. The chat panel shows the inherited prompt as
placeholder text so "leave empty to inherit" is not a guess.

**Alignment and button sizing.** Added --control-h and friends to
tokens.css; every button, input and select takes its height from them,
so a mixed row is flush by construction rather than by per-instance
nudging. Icon buttons are square at that height. Added .btn-row,
.card__header/.card__footer and .grid so pages stop carrying inline
styles, and moved every admin page onto them.

**Settings needed structure.** The user settings page is now tabbed
(Account / Models / Appearance / Security) using radio inputs and
sibling selectors -- no JavaScript, and the browser keeps the chosen tab
across a re-render.

Caught while checking: the chat.css surgery had deleted the attachment,
chip and dropzone rules. Restored, and there is now a check that every
literal class used in a template has a CSS rule.

197 tests, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-07-21 12:59:52 +02:00
parent bdce2764b1
commit 7b67568f2c
30 changed files with 1264 additions and 536 deletions
+30 -13
View File
@@ -8,8 +8,9 @@
{% block admin_content %}
<p class="admin-lede">
Every model discovered across your connections. The order here is the order
users see. Pinned models are offered first, and the default is what a new chat
starts with.
users see in the picker. <strong>Pinning</strong> does not reorder anything —
it puts a shortcut in the chat sidebar. The <strong>default</strong> is what a
new chat starts with.
</p>
{% if saved %}
@@ -26,12 +27,14 @@
</div>
{% else %}
<form method="post" action="/admin/models/bulk" class="bulk-bar">
<span class="text-sm muted">With selected:</span>
<button class="btn btn--sm" name="action" value="enable" type="submit">Enable</button>
<button class="btn btn--sm" name="action" value="disable" type="submit">Disable</button>
<button class="btn btn--sm" name="action" value="public" type="submit">Make public</button>
<button class="btn btn--sm" name="action" value="private" type="submit">Restrict</button>
<form method="post" action="/admin/models/bulk">
<div class="bulk-bar">
<span class="bulk-bar__label">With selected:</span>
<button class="btn btn--sm" name="action" value="enable" type="submit">Enable</button>
<button class="btn btn--sm" name="action" value="disable" type="submit">Disable</button>
<button class="btn btn--sm" name="action" value="public" type="submit">Make public</button>
<button class="btn btn--sm" name="action" value="private" type="submit">Restrict</button>
</div>
<div class="model-rows">
{% for model in models %}
@@ -82,7 +85,7 @@
{% for model in models %}
<section class="card" id="model-{{ model.id }}">
<div class="row row--between" style="margin-bottom: var(--sp-4)">
<div class="card__header">
<div class="row" style="gap: var(--sp-3); min-width: 0">
{{ model_avatar(model, cls="model-row__avatar") }}
<div style="min-width: 0">
@@ -111,6 +114,18 @@
placeholder="What is this model good at?">{{ model.description }}</textarea>
</div>
<div class="field">
<label class="field__label" for="sp-{{ model.id }}">System prompt</label>
<textarea class="textarea" id="sp-{{ model.id }}" name="system_prompt" rows="3"
placeholder="{{ instance_prompt or 'No instance prompt is set.' }}"
>{{ model.system_prompt }}</textarea>
<p class="field__hint">
Used by chats on this model that have no prompt of their own.
{% if instance_prompt %}Leave empty to fall back to the instance prompt.
{% else %}Leave empty to send no system prompt.{% endif %}
</p>
</div>
<div class="field">
<span class="field__label">Capabilities</span>
<div class="checkbox-row">
@@ -138,7 +153,7 @@
</label>
<label class="checkbox">
<input type="checkbox" name="pinned" value="true" {{ 'checked' if model.pinned }}>
<span>Pinned — offered first in the picker</span>
<span>Pinned — shortcut in the chat sidebar</span>
</label>
</div>
</div>
@@ -169,12 +184,14 @@
{% endif %}
</div>
<button class="btn btn--primary" type="submit">Save {{ model.label }}</button>
<div class="btn-row">
<button class="btn btn--primary" type="submit">Save {{ model.label }}</button>
</div>
</form>
<div class="connection__footer">
<div class="card__footer">
<form method="post" action="/admin/models/{{ model.id }}/image"
enctype="multipart/form-data" class="row" style="gap: var(--sp-2)">
enctype="multipart/form-data" class="btn-row">
<input class="input input--file" type="file" name="image"
accept="image/png,image/jpeg,image/webp,image/gif" required
aria-label="Model image">