feat: closed-set admin knobs are pickers, not free text

log_level, search_source, download_layout and the transcode hw/preset
were typed by hand, and every consumer carried its own guess at what a
typo meant. The value set is now a Literal in config.py: pydantic
rejects a bad env value at boot (any letter case accepted), sysconfig
refuses a bad override and derives the admin picker's options from the
same Literal, and the consumers read the value as-is.

The Configuration page renders a choice key as a segmented bar, or a
dropdown past six options, with translated option names. Its tabs now
follow the registry's order instead of a hand-kept copy that had
already dropped the explore group.

A single-choice FilterSelect now opens on the option in use: in the
browser it could land on the first row instead.
This commit is contained in:
2026-09-17 00:03:56 +02:00
parent 6c63df6704
commit 07766c43e8
15 changed files with 496 additions and 93 deletions
+12 -5
View File
@@ -17,6 +17,7 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from app import logs
from app.config import LogLevel, choices_of
class _Sink(logging.Handler):
@@ -161,11 +162,17 @@ def test_bound_correlation_appears_and_is_released(sink):
assert "job_id" not in sink.objects()[-1]
def test_an_unknown_level_name_falls_back_to_info_instead_of_silencing():
assert logs.resolve_level("nonsense") == logging.INFO
assert logs.resolve_level(None) == logging.INFO
assert logs.resolve_level("trace") == logs.TRACE
assert logs.resolve_level(" debug ") == logging.DEBUG
def test_every_selectable_level_resolves_to_a_real_logging_level():
# The picker's options come from `LogLevel`; each must be a level `logging` knows, TRACE included.
assert [logs.resolve_level(n) for n in choices_of(LogLevel)] == [
logs.TRACE,
logging.DEBUG,
logging.INFO,
logging.WARNING,
logging.ERROR,
]
with pytest.raises(ValueError):
logs.resolve_level("nonsense")
def test_configure_logging_silences_the_uvicorn_access_log_and_keeps_ours_propagating():