Six things that looked like they worked

None of these fails loudly and two of them correct themselves if you reload,
which is why five were found by reading rather than by anybody reporting them.

The reply that lost its author is the one worth knowing about: the frame that
replaces a bubble when a reply lands was looking the models up as nobody, and
"no user" answers "no models" rather than "all models" -- so every finished
reply swapped the model's avatar for the plain mark and put the instance's name
where the model's should be, until the next page load put it back.

Beside it: a concurrency quota enforced on two of the six paths that start a
reply, including neither of the two most used; a custom theme whose success and
warning colours moved the text and left the background behind; a phone shell
sized to one viewport inside a document sized to another, which is the reported
scroll past the bottom of Settings; a whole conversation's Markdown rendered on
every page load and read by nothing; a skip guard inert since it was written;
and an endpoint nothing has ever called.

The scroll fix folded five near-identical scroller rules into one, which is
also where the containment they were all missing now lives.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 12:49:26 +00:00
co-authored by Claude Opus 5
parent d73a791c86
commit 92070d7879
14 changed files with 259 additions and 82 deletions
+65
View File
@@ -1167,3 +1167,68 @@ def test_the_think_frame_lands_beside_the_reasoning_body_not_around_it():
# Neither element may open a tag that the other closes: siblings, not nested.
assert "</span>" in between or "</div>" in between
assert between.count("<div") <= 1
# --- Who a finished reply says it came from ----------------------------------
def test_a_finished_bubble_names_the_model_that_wrote_it(db, client, registered, make_chat):
"""The `done` frame and the tail route render the bubble from scratch, and
both looked the models up as *nobody* -- which `models_visible_to` answers
with an empty list, not with everything. So a reply was attributed correctly
for as long as it was streaming and lost its avatar and its author line at
the instant it finished, then corrected itself on the next page load.
Asserted on the rendered HTML rather than on the argument: passing `owner`
is what the old code looked like it was doing, and an assertion on the call
would have been green throughout.
"""
from lembas.api import chats as chats_api
from lembas.db.models import Chat, Connection, Message, Model, User
connection = Connection(name="c", base_url="http://127.0.0.1:1", api_key_encrypted="")
db.add(connection)
db.commit()
db.add(Model(connection_id=connection.id, model_id="mithril-7b", display_name="Mithril 7B"))
db.commit()
chat_id = make_chat(model_id="mithril-7b")
chat = db.get(Chat, chat_id)
owner = db.get(User, chat.user_id)
message = Message(
chat_id=chat.id, role="assistant", content="Spoken.",
complete=True, model_id="mithril-7b",
)
db.add(message)
db.commit()
html = chats_api._render_bubble(db, chat, owner, message)
assert "Mithril 7B" in html
def test_the_reply_limit_covers_every_way_of_starting_one(db):
"""It was enforced in `_send` alone, so an account at its ceiling reached it
by sending into an existing chat and walked past it by pressing New chat --
and by editing, by sending a queued message, and by regenerating.
Reading the source is the honest test here: driving four routes to the point
of refusal needs four live generations, which is a fixture that would tell
you more about the fixture than about the guard.
"""
import inspect
from lembas.api import chats as chats_api
source = inspect.getsource(chats_api)
for route in ("start_chat", "edit_message", "send_queued_now", "regenerate", "_send"):
body = source.split(f"def {route}(", 1)[1].split("\n@router", 1)[0]
assert "_refuse_extra_reply" in body, route
def test_a_new_chat_is_not_written_before_the_limit_is_checked(db):
"""A refusal that has already created the row leaves an empty chat in the
sidebar as the visible result of being told no."""
import inspect
from lembas.api import chats as chats_api
body = inspect.getsource(chats_api.start_chat)
assert body.index("_refuse_extra_reply") < body.index("_new_chat(")