mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-30 14:25:19 +01:00
* refactor: Enhance FileContainer with customizable button and container styles, onClick button handling, and type override * refactor: Update file type handling to support partial file objects * refactor: Extract download handling into a custom hook for improved reusability * refactor: Replace LogContent with Stdout component and enhance Attachment rendering for added visibility * feat: Update @librechat/agents to version 2.4.1 for referencing generated files in subsequent code interpreter uses * feat: Add support for tab-separated values (TSV) in mime type handling and improve error logging for regex patterns * chore: Update @librechat/agents to version 2.4.11 for better `session_id` instructions when wanting to persist files between executions * chore: Update @librechat/agents to version 2.4.12 for improved functionality * fix: Enhance argument parsing in useParseArgs to support JSON input and improve code extraction * refactor: Update input handling in useAutoSave to require more than one character before saving to local storage
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { TFile } from 'librechat-data-provider';
|
|
import type { ExtendedFile } from '~/common';
|
|
import FileIcon from '~/components/svg/Files/FileIcon';
|
|
import ProgressCircle from './ProgressCircle';
|
|
import SourceIcon from './SourceIcon';
|
|
import { useProgress } from '~/hooks';
|
|
import { cn } from '~/utils';
|
|
|
|
const FilePreview = ({
|
|
file,
|
|
fileType,
|
|
className = '',
|
|
}: {
|
|
file?: Partial<ExtendedFile | TFile>;
|
|
fileType: {
|
|
paths: React.FC;
|
|
fill: string;
|
|
title: string;
|
|
};
|
|
className?: string;
|
|
}) => {
|
|
const radius = 55;
|
|
const circumference = 2 * Math.PI * radius;
|
|
const progress = useProgress(
|
|
file?.['progress'] ?? 1,
|
|
0.001,
|
|
(file as ExtendedFile | undefined)?.size ?? 1,
|
|
);
|
|
|
|
const offset = circumference - progress * circumference;
|
|
const circleCSSProperties = {
|
|
transition: 'stroke-dashoffset 0.5s linear',
|
|
};
|
|
|
|
return (
|
|
<div className={cn('relative size-10 shrink-0 overflow-hidden rounded-xl', className)}>
|
|
<FileIcon file={file} fileType={fileType} />
|
|
<SourceIcon source={file?.source} isCodeFile={!!file?.['metadata']?.fileIdentifier} />
|
|
{progress < 1 && (
|
|
<ProgressCircle
|
|
circumference={circumference}
|
|
offset={offset}
|
|
circleCSSProperties={circleCSSProperties}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default FilePreview;
|