diff --git a/api/server/controllers/FavoritesController.js b/api/server/controllers/FavoritesController.js index bca08035cf..cc34cb1e56 100644 --- a/api/server/controllers/FavoritesController.js +++ b/api/server/controllers/FavoritesController.js @@ -9,6 +9,28 @@ const updateFavoritesController = async (req, res) => { return res.status(400).json({ message: 'Favorites data is required' }); } + // Validate favorites structure + if (!Array.isArray(favorites)) { + return res.status(400).json({ message: 'Favorites must be an array' }); + } + + for (const fav of favorites) { + const hasAgent = !!fav.agentId; + const hasModel = !!(fav.model && fav.endpoint); + + if (!hasAgent && !hasModel) { + return res.status(400).json({ + message: 'Each favorite must have either agentId or model+endpoint', + }); + } + + if (hasAgent && hasModel) { + return res.status(400).json({ + message: 'Favorite cannot have both agentId and model/endpoint', + }); + } + } + const user = await User.findByIdAndUpdate( userId, { $set: { favorites } }, diff --git a/client/src/components/Agents/AgentCard.tsx b/client/src/components/Agents/AgentCard.tsx index 751cab9b65..6a81a1645e 100644 --- a/client/src/components/Agents/AgentCard.tsx +++ b/client/src/components/Agents/AgentCard.tsx @@ -48,6 +48,12 @@ const AgentCard: React.FC = ({ agent, onClick, className = '' }) aria-describedby={`agent-${agent.id}-description`} tabIndex={0} role="button" + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + onClick(); + } + }} >
diff --git a/client/src/components/Conversations/Conversations.tsx b/client/src/components/Conversations/Conversations.tsx index 57dd8fcd47..4af0119475 100644 --- a/client/src/components/Conversations/Conversations.tsx +++ b/client/src/components/Conversations/Conversations.tsx @@ -175,7 +175,7 @@ const Conversations: FC = ({ } let rendering: JSX.Element; if (item.type === 'favorites') { - rendering = ; + rendering = ; } else if (item.type === 'chats-header') { rendering = (