Pinned models that know which side you are on

Reported: a pinned model always opened an ordinary chat, even with Agents
selected in the sidebar. They now carry `&kind=agent` with the switch -- a
preselection like `?model=` itself, so the new-chat screen still decides and
nothing is fixed until the first message is sent.

They sit above the tree the switch swaps, so this is the same shape as the New
chat button a few commits ago and gets the same treatment: their own partial,
arriving out of band. The group is rendered even when nothing is pinned,
because a block that vanished when the last model was unpinned would leave that
fragment with nowhere to land -- and htmx says nothing at all when a target is
missing, which is the silent failure this codebase keeps cataloguing.
`.nav-group--pinned:empty` stops the empty one taking room.

Chasing it turned up something else. The shortcuts came from `_chat_context`,
which only the chat pages build -- so the library, connections, settings and
folder pages carried the sidebar without them. A shortcut that is there on one
page and gone on the next. They come from `sidebar_context` now, where they
belong: it is sidebar content, and it is what the fragment route has.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-04 12:53:47 +02:00
parent 7411517ce1
commit 47f2cff640
7 changed files with 139 additions and 18 deletions
+12 -1
View File
@@ -20,7 +20,7 @@ lembas info # paths + counts, useful when confused
lembas secret-key # generate LEMBAS_SECRET_KEY
lembas create-admin # create or promote an admin
pytest # 1412 tests, ~87s
pytest # 1419 tests, ~87s
# PLAN.md tracks what is and is not built
ruff check . # lint (line length 100)
python scripts/build_artwork.py # regenerate artwork (SVG + PWA icons;
@@ -999,6 +999,17 @@ already been a bug once.
`position` order. Pinned models get shortcuts in the chat sidebar and nothing
else -- a picker whose order differs from the admin screen is just confusing.
The shortcuts come from `sidebar_context`, not from `_chat_context` where they
began: they are sidebar content, the fragment route that re-renders the sidebar
has only the former, and the library and connections pages carry the sidebar
without ever calling the latter -- so the shortcuts were simply absent on all of
them. They carry `&kind=agent` with the switch, and they sit above the tree it
swaps, so they arrive out of band exactly as the New chat button does. The group
is rendered **even when empty**, because a block that vanished when the last
model was unpinned would leave that out-of-band fragment with nowhere to land,
and htmx says nothing at all when a target is missing; `.nav-group--pinned:empty`
is what stops the empty one taking room.
**System prompts are precedence, not concatenation.** chat > folder > model >
instance, most specific wins outright
(`services/chat.py:effective_system_prompt`). Stacking them reads well in a