969 strings, an instance default and a per-person choice, and no half-done corner: the admin prose is translated too. Design and reasoning: LLeMbas.wiki/Translations. KEYED BY THE ENGLISH SENTENCE A missing entry renders the key, which is the English -- so an untranslated string looks as it always did, an English instance is byte-for-byte 1.6.0, and a half-finished catalogue is a half-translated page rather than a page of dotted key names. The cost is that editing an English sentence orphans its translation silently, which is what tests/test_translations.py asserts in both directions. No gettext: .po -> .mo is a build step and this project does not have one. A JINJA GLOBAL, AND THEREFORE A CONTEXTVAR `t()` is a global for the reason `brand` already documents -- render() is bypassed by 25 TemplateResponse calls and 8 get_template().render() calls, the latter being the SSE frames, which have no Request at all. A global is bound once at import and the language is per person, so the active language is a ContextVar set per request. 🚨 `get_current_user` had to become `async def`. FastAPI runs a sync dependency in a threadpool, and anyio copies the context in and discards it on the way out -- so the language was set where nothing could see it and every page rendered in the instance's language whatever anybody had chosen, with no error anywhere. NOT TRANSLATED, ON PURPOSE Everything a model reads: the 60 prompt fragments, and the dates in harness.py, schedule/runner.py and schedule/compile.py. Only `i18n.stamp` is localised, and only where a person reads it -- with the *format* translatable as well as the words, because "26. septembra 2026" is a different pattern rather than the same one with different words in it. A process locale is not an option: global, not thread-safe, two people's pages at once. A second fragment telling models to answer in the reader's language was written during this work and removed: `core.style` has said it since long before, and test_an_empty_override_turns_a_fragment_off caught the duplicate. THE BULK PASS 1213 sites wrapped by a one-off script that only touched patterns it could not misread. It got three wrong in a way that mattered -- `t('…')` inside `attr="…"` where the sentence held an apostrophe, closing the Jinja string and 500ing two pages whose partials no test renders. tests/test_translations.py now compiles all 110 templates. It also wrapped the product's own name, an SSH key header, a keystroke hint and an example URL, all taken back out: a string is not translatable just because it is a string. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
126 lines
4.7 KiB
HTML
126 lines
4.7 KiB
HTML
{% extends "base.html" %}
|
|
{% from "_macros.html" import icon, mark %}
|
|
{#
|
|
Messages: one conversation per person, opened at the most recent turns.
|
|
|
|
The ordinary chat shell, with two differences. It opens on the live chunk
|
|
rather than on everything, and above that sits a sentinel that fetches the
|
|
page before it when scrolled into view. Everything else — the composer, the
|
|
bubbles, the tail poller, the streaming shell — is the same machinery, which
|
|
is the whole reason this is a `Chat` with a different `kind`.
|
|
#}
|
|
|
|
{% block title %}Messages - {{ brand.name }}{% endblock %}
|
|
|
|
{% block head %}
|
|
<link rel="stylesheet" href="{{ asset('css/chat.css') }}">
|
|
{% endblock %}
|
|
|
|
{% block body_attrs %} data-authenticated="true"{% endblock %}
|
|
|
|
{% block body %}
|
|
<div class="shell">
|
|
{% include "partials/sidebar.html" %}
|
|
|
|
<main class="main">
|
|
<header class="topbar">
|
|
{% include "partials/_sidebar_toggle.html" %}
|
|
<h1 class="topbar__title">{{ icon("chat", "icon--sm") }} Messages</h1>
|
|
<div class="topbar__actions">
|
|
{% if schedules %}
|
|
<details class="picker">
|
|
<summary class="btn btn--sm">
|
|
{{ icon("clock", "icon--sm") }} {{ schedules | length }} scheduled
|
|
</summary>
|
|
<div class="picker__menu">
|
|
<div class="picker__label">Posting into this conversation</div>
|
|
{% for item in schedules %}
|
|
<a class="jobs__row jobs__row--open" href="/scheduled/{{ item.row.id }}/edit">
|
|
<span>
|
|
<strong>{{ item.row.title }}</strong>
|
|
<span class="text-xs faint">{{ item.summary }}</span>
|
|
</span>
|
|
{% if not item.row.enabled %}
|
|
<span class="badge badge--warning">{{ t("paused") }}</span>
|
|
{% endif %}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
{% if can.get("schedule.use") %}
|
|
<a class="btn btn--sm" href="/scheduled/new">{{ icon("plus", "icon--sm") }} Schedule</a>
|
|
{% endif %}
|
|
</div>
|
|
</header>
|
|
|
|
<div class="thread-scroll" id="thread-scroll">
|
|
<div class="thread" id="thread">
|
|
{% if not messages %}
|
|
<div class="thread__intro">
|
|
{{ mark(cls="empty__mark", uid="messages") }}
|
|
<h2 class="empty__title">{{ t("Nothing said yet") }}</h2>
|
|
<p class="empty__text">{{ t("One conversation that keeps going. Anything scheduled to write here will arrive in it.") }}</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{#
|
|
The sentinel goes above the turns and replaces itself with the page
|
|
before, plus a fresh sentinel. Rendered only when there is something
|
|
earlier, so a short conversation has no loading row at the top.
|
|
#}
|
|
{% if more_before %}
|
|
<div class="history-sentinel"
|
|
hx-get="/api/messages/history?before={{ oldest_id }}"
|
|
hx-trigger="revealed"
|
|
hx-target="this"
|
|
hx-swap="outerHTML"
|
|
hx-sync="this:drop">
|
|
<span class="visually-hidden" role="status">{{ t("Loading earlier messages") }}</span>
|
|
<div class="history-sentinel__shape" aria-hidden="true">
|
|
<div class="skeleton skeleton--line"></div>
|
|
<div class="skeleton skeleton--line skeleton--short"></div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for message in messages %}
|
|
{% include "chat/_message.html" %}
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
{#
|
|
Outside `#thread` and outside the composer form, for the two reasons
|
|
`tests/test_chat_tail.py` already walks the chat page to enforce.
|
|
#}
|
|
<div hidden id="thread-tail"
|
|
hx-get="/api/chats/{{ chat.id }}/tail"
|
|
hx-trigger="every 5s"
|
|
hx-target="#thread" hx-swap="beforeend"
|
|
hx-sync="this:drop"></div>
|
|
|
|
{% include "chat/_composer.html" %}
|
|
</main>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{#
|
|
`steps.js` only. `composer.js` and `commands.js` were listed here too, and
|
|
`base.html` already loads both on every page -- so this screen ran each of
|
|
them **twice**.
|
|
|
|
Each is an IIFE with its own state, and `stopPropagation()` does not stop a
|
|
second listener already bound to the same node. So: two composer menus stacked
|
|
on each other; one Enter on a highlighted `/` item running the command twice
|
|
(`/help` opening two dialogs, `/image` posting the message twice); an `@`
|
|
mention attaching its file twice; and `Alt+B`, `Alt+E`, `Alt+T` and `Alt+I`
|
|
toggling their panel twice, which is to say doing nothing at all.
|
|
|
|
None of it looks like a script loaded twice. Found by driving the file under a
|
|
DOM stub, which is the rule the working notes set out and the reason it does.
|
|
#}
|
|
{% block scripts %}
|
|
<script src="{{ asset('js/steps.js') }}" defer></script>
|
|
{% endblock %}
|