feat: clean up comments and improve code readability in favorites and agent components; bump @librechat/data-schemas to 0.0.24

This commit is contained in:
Marco Beretta 2025-11-23 23:44:35 +01:00
parent 4e4a132660
commit bfeae91a96
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
9 changed files with 55 additions and 52 deletions

View file

@ -37,10 +37,8 @@ const getFavoritesController = async (req, res) => {
let favorites = user.favorites || []; let favorites = user.favorites || [];
// Ensure favorites is an array (migration/dev fix)
if (!Array.isArray(favorites)) { if (!Array.isArray(favorites)) {
favorites = []; favorites = [];
// Optionally update the DB to fix it permanently
await User.findByIdAndUpdate(userId, { $set: { favorites: [] } }); await User.findByIdAndUpdate(userId, { $set: { favorites: [] } });
} }

View file

@ -83,7 +83,7 @@ const AgentCard: React.FC<AgentCardProps> = ({ agent, onClick, className = '' })
</p> </p>
</div> </div>
{/* Owner info - moved to bottom right */} {/* Owner info */}
{(() => { {(() => {
const displayName = getContactDisplayName(agent); const displayName = getContactDisplayName(agent);
if (displayName) { if (displayName) {

View file

@ -141,24 +141,24 @@ const AgentDetail: React.FC<AgentDetailProps> = ({ agent, isOpen, onClose }) =>
return ( return (
<OGDialog open={isOpen} onOpenChange={(open) => !open && onClose()}> <OGDialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
<OGDialogContent ref={dialogRef} className="max-h-[90vh] w-11/12 max-w-lg overflow-y-auto"> <OGDialogContent ref={dialogRef} className="max-h-[90vh] w-11/12 max-w-lg overflow-y-auto">
{/* Agent avatar - top center */} {/* Agent avatar */}
<div className="mt-6 flex justify-center">{renderAgentAvatar(agent, { size: 'xl' })}</div> <div className="mt-6 flex justify-center">{renderAgentAvatar(agent, { size: 'xl' })}</div>
{/* Agent name - center aligned below image */} {/* Agent name */}
<div className="mt-3 text-center"> <div className="mt-3 text-center">
<h2 className="text-2xl font-bold text-text-primary"> <h2 className="text-2xl font-bold text-text-primary">
{agent?.name || localize('com_agents_loading')} {agent?.name || localize('com_agents_loading')}
</h2> </h2>
</div> </div>
{/* Contact info - center aligned below name */} {/* Contact info */}
{agent?.support_contact && formatContact() && ( {agent?.support_contact && formatContact() && (
<div className="mt-1 text-center text-sm text-text-secondary"> <div className="mt-1 text-center text-sm text-text-secondary">
{localize('com_agents_contact')}: {formatContact()} {localize('com_agents_contact')}: {formatContact()}
</div> </div>
)} )}
{/* Agent description - below contact */} {/* Agent description */}
<div className="mt-4 whitespace-pre-wrap px-6 text-center text-base text-text-primary"> <div className="mt-4 whitespace-pre-wrap px-6 text-center text-base text-text-primary">
{agent?.description} {agent?.description}
</div> </div>

View file

@ -28,7 +28,6 @@ function ModelSelectorContent() {
searchValue, searchValue,
searchResults, searchResults,
selectedValues, selectedValues,
// Functions // Functions
setSearchValue, setSearchValue,
setSelectedValues, setSelectedValues,

View file

@ -23,14 +23,15 @@ const DraggableFavoriteItem = ({
children, children,
}: DraggableFavoriteItemProps) => { }: DraggableFavoriteItemProps) => {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const [{ handlerId }, drop] = useDrop({ const [{ handlerId }, drop] = useDrop<{ index: number; id: string }, unknown, { handlerId: any }>(
{
accept: 'favorite-item', accept: 'favorite-item',
collect(monitor) { collect(monitor) {
return { return {
handlerId: monitor.getHandlerId(), handlerId: monitor.getHandlerId(),
}; };
}, },
hover(item: { index: number; id: string }, monitor) { hover(item, monitor) {
if (!ref.current) { if (!ref.current) {
return; return;
} }
@ -57,7 +58,8 @@ const DraggableFavoriteItem = ({
moveItem(dragIndex, hoverIndex); moveItem(dragIndex, hoverIndex);
item.index = hoverIndex; item.index = hoverIndex;
}, },
}); },
);
const [{ isDragging }, drag] = useDrag({ const [{ isDragging }, drag] = useDrag({
type: 'favorite-item', type: 'favorite-item',

View file

@ -3,18 +3,23 @@ import { dataService } from 'librechat-data-provider';
import type { FavoritesState } from '~/store/favorites'; import type { FavoritesState } from '~/store/favorites';
export const useGetFavoritesQuery = (config?: any) => { export const useGetFavoritesQuery = (config?: any) => {
return useQuery<FavoritesState>(['favorites'], () => dataService.getFavorites() as Promise<FavoritesState>, { return useQuery<FavoritesState>(
['favorites'],
() => dataService.getFavorites() as Promise<FavoritesState>,
{
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
refetchOnReconnect: false, refetchOnReconnect: false,
refetchOnMount: false, refetchOnMount: false,
...config, ...config,
}); },
);
}; };
export const useUpdateFavoritesMutation = () => { export const useUpdateFavoritesMutation = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation( return useMutation(
(favorites: FavoritesState) => dataService.updateFavorites(favorites) as Promise<FavoritesState>, (favorites: FavoritesState) =>
dataService.updateFavorites(favorites) as Promise<FavoritesState>,
{ {
onSuccess: (data) => { onSuccess: (data) => {
queryClient.setQueryData(['favorites'], data); queryClient.setQueryData(['favorites'], data);

2
package-lock.json generated
View file

@ -47913,7 +47913,7 @@
}, },
"packages/data-schemas": { "packages/data-schemas": {
"name": "@librechat/data-schemas", "name": "@librechat/data-schemas",
"version": "0.0.30", "version": "0.0.31",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-alias": "^5.1.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "@librechat/data-schemas", "name": "@librechat/data-schemas",
"version": "0.0.30", "version": "0.0.31",
"description": "Mongoose schemas and models for LibreChat", "description": "Mongoose schemas and models for LibreChat",
"type": "module", "type": "module",
"main": "dist/index.cjs", "main": "dist/index.cjs",

View file

@ -39,7 +39,6 @@ export interface IUser extends Document {
models: Array<{ models: Array<{
model: string; model: string;
endpoint: string; endpoint: string;
label?: string;
}>; }>;
}; };
createdAt?: Date; createdAt?: Date;