A crowd you can find, and a phone 65px too narrow
Two reports against 1.6.0 and 1.7.0, both correct. The crowd worked end to end and was, in practice, not there: the picker was behind the ⋯ menu of a chat that already existed, and the switch was a card on the Agents page, which made it read as an agent-chat feature. The picker is now a button in the composer toolbar on both screens that include it, and on the new-chat screen the choice rides along with the first message, so a chat can start as a crowd instead of having to be converted into one. The instance switch has its own page. The width bug was the suggestion cards, exactly as reported. `.suggestions` rendered 455px inside a 366px column, and the tree's standing rule applied on its own made it worse -- 428px to 455px. A grid item carries `min-width: auto`, which is a min-content floor, and a floor beats `width: 100%`; the floor is measured while the percentage is indefinite, so `min(100%, …)` alone sends the track to a card's max-content. Both halves now go on all four auto-fit grids, and a test refuses either alone. It survived four releases of narrow-width checking because the harness never rendered that screen: `TestClient(app)` runs no lifespan outside a `with` block, so the startup-seeded cards were missing from every shot ever taken of it. And its overflow check skipped anything inside a scroller -- right for a table in its own scroller, blind to the scroller itself, which `overflow-y: auto` makes scroll sideways too. Both fixed; it now names the box and the child to blame. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+48
-33
@@ -296,6 +296,11 @@ async def start_chat(
|
||||
scope_on: list[str] = Form(default=[]),
|
||||
scope_skill_all: list[str] = Form(default=[]),
|
||||
scope_skill_on: list[str] = Form(default=[]),
|
||||
# Who else answers, as the crowd menu stood before the first word. There is no
|
||||
# chat row yet to attach members to, so the choice rides along with the message
|
||||
# -- the same mechanism the scope switches above use, and the reason the control
|
||||
# lives inside the composer's form rather than in the topbar.
|
||||
crowd_model_ids: list[str] = Form(default=[]),
|
||||
) -> Response:
|
||||
"""Create a chat from its first message.
|
||||
|
||||
@@ -329,6 +334,8 @@ async def start_chat(
|
||||
skills_off=frozenset(scope_skill_all) - frozenset(scope_skill_on),
|
||||
)
|
||||
|
||||
_apply_crowd(db, chat, user, crowd_model_ids)
|
||||
|
||||
_adopt_draft(db, user, draft_id, chat)
|
||||
|
||||
user_message = chat_service.create_message(db, chat, ROLE_USER, content)
|
||||
@@ -1510,6 +1517,45 @@ def _thread_context(db: DBSession, chat: Chat, user: User) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _apply_crowd(db: DBSession, chat: Chat, user: User, values: list[str]) -> None:
|
||||
"""Replace a chat's crowd with the models named, in the order named.
|
||||
|
||||
One implementation for both the composer (where the choice rides along with
|
||||
the first message) and the settings panel, because two would be two places to
|
||||
forget a rule -- and there are three:
|
||||
|
||||
* **Checked against what this person can reach**, never against what exists.
|
||||
A control checked only in the template is advisory, and a crafted request
|
||||
walks past it. Same reasoning as the model branch in `update_chat`.
|
||||
* **Never the chat's own model**, which would answer twice in a row.
|
||||
* **Capped by `crowd.max_models`**, on the way in as well as on the way out.
|
||||
|
||||
The connection is stored beside the id because `Model` is unique on the pair,
|
||||
and a model offered by two connections is two rows with different capabilities.
|
||||
"""
|
||||
from lembas.db.models import CrowdMember
|
||||
|
||||
settings = settings_store.crowd(db)
|
||||
reachable = {
|
||||
model.model_id: model for model in chat_service.available_models(db, user)
|
||||
}
|
||||
wanted: list[str] = []
|
||||
for value in values:
|
||||
value = str(value).strip()
|
||||
if value and value in reachable and value != chat.model_id and value not in wanted:
|
||||
wanted.append(value)
|
||||
wanted = wanted[: int(settings["max_models"])]
|
||||
|
||||
chat.crowd = [
|
||||
CrowdMember(
|
||||
model_id=model_id,
|
||||
connection_id=reachable[model_id].connection_id,
|
||||
position=index,
|
||||
)
|
||||
for index, model_id in enumerate(wanted)
|
||||
]
|
||||
|
||||
|
||||
def _messages_after(db: DBSession, message: Message) -> list[Message]:
|
||||
"""Everything later in this chat than one message.
|
||||
|
||||
@@ -2117,39 +2163,8 @@ async def update_chat(request: Request, db: Db, user: RequiredUser, chat_id: str
|
||||
|
||||
if "crowd_model_ids" in form:
|
||||
# The same shape as the bases above: one field always sent, so clearing
|
||||
# every box clears the crowd. Checked against what this person can reach
|
||||
# rather than against what exists, or the picker is advisory and a crafted
|
||||
# request walks past it -- the reasoning the model branch carries.
|
||||
from lembas.db.models import CrowdMember
|
||||
|
||||
settings = settings_store.crowd(db)
|
||||
reachable = {
|
||||
model.model_id for model in chat_service.available_models(db, user)
|
||||
}
|
||||
wanted: list[str] = []
|
||||
for value in form.getlist("crowd_model_ids"):
|
||||
value = str(value).strip()
|
||||
# Never the chat's own model: it would answer twice in a row, which is
|
||||
# nobody's idea of a second opinion.
|
||||
if value and value in reachable and value != chat.model_id and value not in wanted:
|
||||
wanted.append(value)
|
||||
wanted = wanted[: int(settings["max_models"])]
|
||||
|
||||
chat.crowd = [
|
||||
CrowdMember(
|
||||
model_id=model_id,
|
||||
connection_id=next(
|
||||
(
|
||||
model.connection_id
|
||||
for model in chat_service.available_models(db, user)
|
||||
if model.model_id == model_id
|
||||
),
|
||||
None,
|
||||
),
|
||||
position=index,
|
||||
)
|
||||
for index, model_id in enumerate(wanted)
|
||||
]
|
||||
# every box clears the crowd.
|
||||
_apply_crowd(db, chat, user, form.getlist("crowd_model_ids"))
|
||||
|
||||
submitted_params = {name: form[name] for name in _PARAM_RANGES if name in form}
|
||||
if submitted_params:
|
||||
|
||||
Reference in New Issue
Block a user