mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 05:20:55 +00:00
* 🏷️ fix: Model Spec Menu Label and Agent Avatar Fallbacks The selector's header already falls back from a spec's `label` to its `name` (`getSelectedValueText`), but the menu item and search result render `spec.label` bare. A spec persisted without a label therefore shows its name in the header while its row in the list is blank — selectable, but unlabeled. Specs targeting an agent had a related gap: the chat landing resolves the agent and shows its avatar, while the selector resolved icons from the spec/preset/endpoint only. An agent with an avatar still rendered a generic endpoint icon in the menu unless `iconURL` was set by hand. - Fall back to `spec.name` when `label` is absent or empty, matching the header. - Resolve the target agent's avatar as the icon when the spec defines none of its own; an explicit `iconURL` still wins. `getSpecAgentAvatarURL` returns the avatar as a primitive so the memoized `SpecIcon` compares a string rather than the identity of the agents map, and both call sites already consume `useModelSelectorContext`, so reading `agentsMap` adds no new subscription. * 🔁 refactor: Normalize Spec Labels on Ingest, Harden Agent Avatar Lookup Addresses the review findings, which fell into two patterns rather than four independent bugs. The label fallback was applied per render site, but the spec list feeds five consumers: the menu row, the search row, `filterItems`, the spec/endpoint discriminator in `SearchResults`, and `getSelectedIcon`. Guarding two of them left `filterItems` throwing on `label.toLowerCase()` and the discriminator misclassifying a label-less spec as an endpoint — reproducing, inside the fix, the exact inconsistency the fix targeted. Normalize once on ingest instead: `normalizeModelSpecs` fills a missing label from the name where the selector derives its spec list, so every consumer works from a complete spec and the per-site guards are removed. It returns the original array and the original spec objects when nothing needs filling in, so memoized consumers see no new identities. The avatar helper had the same shape of problem — a second resolution path that skipped what the existing one already handled: - Resolve via `getAgentAvatarUrl`, which supports agents persisting `avatar` as a URL string rather than an object. - Gate on `isAgentsEndpoint`. `tModelSpecPresetSchema` permits `agent_id` alongside any endpoint, so a leftover id on a non-agent spec would otherwise surface an unrelated agent's identity. - Thread the avatar through `getSelectedIcon`, so the selector trigger keeps the agent avatar after selection instead of reverting to the generic endpoint icon. * 🩹 fix: Treat Empty Spec Icon Fields as Unset `??` only skips null and undefined, so an `iconURL: ''` — what a form-backed config writer persists for an untouched field — stopped the chain and suppressed both the agent avatar and the endpoint icon, leaving the generic fallback. Resolve the first non-empty candidate instead. This matches `applyModelSpecPreset`, which already ignores an empty `iconURL`, and keeps `showIconInMenu` as the explicit way to render no icon. * 🔁 refactor: Normalize Spec Labels at the Query Boundary, Cover Favorites The context-level normalization missed a parallel consumer: the favorites sidebar reads `startupConfig.modelSpecs.list` directly, so a pinned label-less spec rendered a blank row and its icon ignored the agent avatar — the same two gaps this PR fixes in the selector. Move normalization to the true shared boundary instead of adding another per-consumer call: `useGetStartupConfig` normalizes in its query function, once per fetch, cached — so the selector, search, mentions, favorites, and provider-key reachability all read complete specs. The `ModelSelectorContext` call is removed as redundant. - `normalizeModelSpecs` is now a single pass with a lazy copy (allocated only on the first incomplete spec), replacing the `some` + `map` double scan. - `FavoriteItem` threads `agentAvatarURL` into `SpecIcon`; the list resolves it per spec from the agents map it already holds, passed as a primitive so memoization is unaffected. |
||
|---|---|---|
| .. | ||
| index.ts | ||
| queries.ts | ||