diff --git a/packages/web/src/components/chat/AttachmentProgress.tsx b/packages/web/src/components/chat/AttachmentProgress.tsx new file mode 100644 index 00000000..668289f1 --- /dev/null +++ b/packages/web/src/components/chat/AttachmentProgress.tsx @@ -0,0 +1,57 @@ +import React from 'react'; +import type { TransferState } from '../../stores/transferStore'; + +interface Props { + loaded: number; + total: number; + state: TransferState; + filename: string; + onPause?: () => void; + onResume?: () => void; + onAbort?: () => void; + size?: 'tile' | 'pill'; +} + +function fmt(bytes: number): string { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + if (bytes < 1024 * 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(1)} MB`; + return `${(bytes / 1024 / 1024 / 1024).toFixed(2)} GB`; +} + +export function AttachmentProgress({ loaded, total, state, filename, onPause, onResume, onAbort, size = 'tile' }: Props) { + const pct = total > 0 ? Math.min(100, Math.round((loaded / total) * 100)) : 0; + const bg = state === 'failed' ? 'bg-accent-rose/30' : 'bg-accent-mint/30'; + const isFinal = state === 'completed' || state === 'aborted'; + return ( +