Files that outlived the chats that held them, and a page that led with its footnotes

The second audit pass. Four things, and the first two were reported.

The Prompts page put a screen of variables and a screen of preview above
the editor, so the tabs began two screens down and switching one had to
drag the whole page to be any use -- and on a short tab it could not drag
far enough, leaving the panel stranded above a screenful of nothing.
Editor first, reference after, bar sticky. Custom themes were three fixed
slots: fifty-seven empty colour boxes on a fresh instance and no way to
make a fourth theme. One block per theme plus a blank one, colours behind
a disclosure. Both measured rather than argued about -- rendered through
TestClient and driven under headless Chromium, where the tab bar moved
385->642px before and does not move now, and the themes page went from
5495px to 2820px.

Asking where generated images go found the other two. Deleting a chat
cascades to the attachment rows and leaves every file on disk; the helper
written for exactly that was called from one place, and it was not the
delete button, a schedule's chat, a helper's chat or deleting an account.
Underneath it, `claim` bound message_id and never chat_id, so anything
picked before a chat existed kept an empty chat_id forever -- which six
readers filter on, so those files were also unnamed in the prompt,
unopenable in the canvas, and invisible to the one caller the cleanup had.

And folders nest now. The route has handled parent_id since folders
existed, with a cycle guard and a depth cap the move path never applied;
the sidebar has always drawn a tree. Nothing could ask for one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-07 13:20:59 +02:00
parent 3afbccba81
commit c4aff999ba
25 changed files with 814 additions and 104 deletions
+35
View File
@@ -2,6 +2,8 @@
from __future__ import annotations
import pathlib
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import select
@@ -49,6 +51,39 @@ def test_the_preview_controls_are_inside_what_the_preview_includes(
assert f'name="{name}"' in controls, name
def test_the_editor_comes_before_the_reference(client: TestClient, registered):
"""The Variables legend and the Preview run to a screen each and used to sit
above the tabs, so the thing this page exists for started two screens down.
Every tab switch then had to move the viewport to be any use -- and on a
short panel the scroller cannot reach the tab bar, so it clamped to the
bottom and left the panel stranded above a screenful of nothing.
Asserted as an ordering rather than by reading the CSS, because the position
is the fix: with the tabs near the top there is nothing to scroll past.
"""
page = client.get("/admin/prompts").text
tabs = page.index('class="tabs__bar"')
assert tabs < page.index("Variables</h2>")
assert tabs < page.index("Preview</h2>")
assert tabs < page.index("Tool descriptions</h2>")
def test_the_tab_bar_sticks_to_the_top_of_the_scroller():
"""The Tools panel is longer than a screen, so a bar that scrolls away means
changing tab is a scroll back up to find it."""
css = (
pathlib.Path(__file__).resolve().parents[1]
/ "src/lembas/web/static/css/admin.css"
).read_text()
bar = css.split(".tabs__bar {", 1)[1].split("}", 1)[0]
assert "position: sticky" in bar
assert "top: 0" in bar
# Opaque, or the panel shows through it; stacked, or a panel's own cards
# paint over it.
assert "background:" in bar
assert "z-index:" in bar
def test_the_page_is_refused_to_a_plain_user(client: TestClient, plain_user):
assert client.get("/admin/prompts").status_code == 403
assert client.post("/admin/prompts", data={}).status_code == 403