The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { |
| 2 | type AttachmentUploadState, |
| 3 | formatAttachmentUploadProgress, |
| 4 | } from "../lib/attachmentUploadState"; |
| 5 | import { useDelayedStatus } from "./useDelayedStatus"; |
| 6 | |
| 7 | export function useAttachmentUploadProgress( |
| 8 | key: string, |
| 9 | upload: AttachmentUploadState | undefined, |
| 10 | ) { |
| 11 | const uploading = upload?.status === "uploading"; |
| 12 | const shown = useDelayedStatus( |
| 13 | `${key}:${upload?.environmentId ?? ""}:${uploading ? "uploading" : "idle"}`, |
| 14 | uploading ? true : null, |
| 15 | 150, |
| 16 | ); |
| 17 | return uploading && shown ? formatAttachmentUploadProgress(upload.progress) : null; |
| 18 | } |