refactor: anonymous/free chat experience

- Enhanced lambda function formatting in `_after_commit` for better clarity.
- Simplified generator expression in `_match_condition` for improved readability.
- Streamlined function signature in `_eligible` for consistency.
- Updated imports and refactored anonymous chat routes to use a new agent creation method.
- Added a new function `_load_anon_document` to handle document loading from Redis.
- Improved UI components by replacing legacy structures with modern alternatives, including alerts and separators.
- Refactored quota-related components to utilize new alert structures for better user feedback.
- Cleaned up unused variables and optimized component states for performance.
This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-05-31 15:58:21 -07:00
parent 0cce9b7e64
commit 0f2e3c7655
17 changed files with 493 additions and 278 deletions

View file

@ -24,6 +24,7 @@ def _event_type(type_: str = "test.thing") -> EventType:
def test_register_then_get_returns_the_event_type(isolated_event_catalog: None) -> None:
from app.event_bus.catalog import catalog
catalog.register(_event_type())
assert catalog.get("test.thing") is not None
@ -32,12 +33,14 @@ def test_register_then_get_returns_the_event_type(isolated_event_catalog: None)
def test_get_unknown_type_returns_none(isolated_event_catalog: None) -> None:
from app.event_bus.catalog import catalog
assert catalog.get("does.not.exist") is None
def test_register_duplicate_type_raises(isolated_event_catalog: None) -> None:
"""A type is a contract; registering it twice is a bug, not an override."""
from app.event_bus.catalog import catalog
catalog.register(_event_type())
with pytest.raises(ValueError, match="already registered"):
@ -47,6 +50,7 @@ def test_register_duplicate_type_raises(isolated_event_catalog: None) -> None:
def test_all_is_a_defensive_snapshot(isolated_event_catalog: None) -> None:
"""Mutating the returned dict must not corrupt the registry."""
from app.event_bus.catalog import catalog
catalog.register(_event_type())
snapshot = catalog.all()