Files on their way: progress, time left, pause, cancel, retry and remove, with a transfer service that does the sending.
Re: Export fails on files over 2 GB
Thanks, Dana. I've attached the server log and a capture of the failing request so engineering can reproduce it.
0 of 3 uploaded
0 of 3 uploaded · 0 bytes of 6.4 MB
- export-worker-2026-12-01.log
Uploading, 0%. 0 bytes of 410 KB
- export-request.har
Uploading, 0%. 0 bytes of 6 MB
- Export error.svg
Uploading, 0%. 0 bytes of 835 bytes
Drop files here or chooseChoose files
Up to 25 MB
Sending waits for the uploads.
import { Component, UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { AsyncResult } from "effect/reactivity"import { Button } from "./ui/uicontext/components/Button.ts"import { uploadStatus } from "./ui/uicontext/components/domain/Upload.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, radius, space } from "./ui/uicontext/components/tokens.stylex.ts"import { Dropzone } from "./ui/uicontext/components/upload/Dropzone.ts"import { UploadQueue } from "./ui/uicontext/components/upload/UploadQueue.ts"import { AddUploads, ChangeUpload, ClearDoneUploads, simulatedTransport, uploadsLayer, WatchUploads } from "./ui/uicontext/components/upload/Uploads.ts"import { errorScreenshot, fileFromDataUrl, sampleFile } from "./uploads.ts"const styles = stylex.create({ reply: { display: "grid", gap: space.lg, inlineSize: "min(100%, 36rem)", padding: space.lg, borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.xl, backgroundColor: color.panel, }, subject: { margin: 0, fontSize: font.base, fontWeight: 600 }, body: { margin: 0, color: color.muted, fontSize: font.sm, lineHeight: 1.5 }, foot: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: space.md, flexWrap: "wrap" }, status: { margin: 0, color: color.muted, fontSize: font.sm },})const Message = UiSchema.TaggedEnum({ PickedAttachments: { files: Schema.Array(Schema.instanceOf(File)) }, RequestedAttachmentChange: { id: Schema.String, action: Schema.Literals(["pause", "resume", "cancel", "retry", "remove"]) }, RequestedClearAttachments: {}, ClickedSend: {},})const TicketReplyNoDeps = Html.component({ name: "TicketReply", model: Schema.Struct({ sent: Schema.Boolean }), message: Message, queries: { attachments: { query: WatchUploads, args: () => ({}) } },}).make({ init: () => ({ sent: false }), update: { PickedAttachments: ($, { files }) => $.run(AddUploads.make({ files })), RequestedAttachmentChange: ($, { id, action }) => $.run(ChangeUpload.make({ id, action })), RequestedClearAttachments: ($) => $.run(ClearDoneUploads.make()), ClickedSend: ($) => $.evolve({ sent: true }), }, view: (h, model) => { const files = AsyncResult.getOrElse(h.queries.attachments, () => []) const waiting = files.filter((f) => uploadStatus(f) !== "done").length const failed = files.some((f) => uploadStatus(f) === "failed") return h.div.attrs(sx(styles.reply)).children( h.h3.attrs(sx(styles.subject)).children("Re: Export fails on files over 2 GB"), h.p.attrs(sx(styles.body)).children("Thanks, Dana. I've attached the server log and a capture of the failing request so engineering can reproduce it."), UploadQueue(h, { props: { label: "Attachments", files, pausable: true }, onEmit: { RequestedPause: ({ id }) => Message.RequestedAttachmentChange({ id, action: "pause" }), RequestedResume: ({ id }) => Message.RequestedAttachmentChange({ id, action: "resume" }), RequestedCancel: ({ id }) => Message.RequestedAttachmentChange({ id, action: "cancel" }), RequestedRetry: ({ id }) => Message.RequestedAttachmentChange({ id, action: "retry" }), RequestedRemove: ({ id }) => Message.RequestedAttachmentChange({ id, action: "remove" }), RequestedClearDone: () => Message.RequestedClearAttachments(), }, }), Dropzone(h, { props: { label: "Attach files", size: "sm", accept: { maxSize: 25 * 1024 * 1024 } }, onEmit: { Picked: ({ files }) => Message.PickedAttachments({ files }), Refused: () => undefined }, }), h.div.attrs(sx(styles.foot)).children( h.p.attrs({ role: "status", ...sx(styles.status) }).children( model.sent ? "Reply sent." : failed ? "Retry or remove the failed file to send." : waiting > 0 ? "Sending waits for the uploads." : "", ), Button(h, { tone: "primary" }).disabled(model.sent || waiting > 0).on("click", Message.ClickedSend()).children("Send reply"), ), ) },})const log = sampleFile("export-worker-2026-12-01.log", 420_000, "text/plain")const capture = sampleFile("export-request.har", 6_300_000, "application/json")const screenshot = fileFromDataUrl(errorScreenshot, "Export error.svg")// the capture drops partway the first time it's sent, then goes throughexport const TicketReply = TicketReplyNoDeps.pipe(Component.provide(uploadsLayer( simulatedTransport({ bytesPerSecond: 1_200_000, fail: (file, attempt) => (file === capture && attempt === 1 ? { at: 0.6, reason: "The connection dropped. Try again." } : undefined), }), { idPrefix: "attachment", initial: [ { id: "attachment-log", name: log.name, size: log.size, type: log.type, loaded: 0, file: log }, { id: "attachment-capture", name: capture.name, size: capture.size, type: capture.type, loaded: 0, file: capture }, { id: "attachment-shot", name: screenshot.name, size: screenshot.size, type: screenshot.type, loaded: 0, file: screenshot }, ], },)))Installation
pnpm dlx shadcn@latest add checkfu/uicontext/upload-queueUsage
import type { UploadItem } from "./ui/uicontext/components/domain/Upload.ts"import { UploadQueue } from "./ui/uicontext/components/upload/UploadQueue.ts"const Message = UiSchema.TaggedEnum({ RequestedFileChange: { id: Schema.String, action: Schema.Literals(["cancel", "retry", "remove"]) },})// `files` comes from your transfer: each file's bytes sent and its Outcome (Pending, Accepted, Refused)export const Attachments = (h: Html.H<typeof Message.Type>, files: ReadonlyArray<UploadItem>) => UploadQueue(h, { props: { label: "Attachments", files }, onEmit: { RequestedCancel: ({ id }) => Message.RequestedFileChange({ id, action: "cancel" }), RequestedRetry: ({ id }) => Message.RequestedFileChange({ id, action: "retry" }), RequestedRemove: ({ id }) => Message.RequestedFileChange({ id, action: "remove" }), RequestedPause: () => undefined, RequestedResume: () => undefined, RequestedClearDone: () => undefined, }, })Examples
Every state
Waiting its turn, sending with the time left, paused, done, and failed with the reason. The app passes each file's bytes sent and Outcome; the queue draws them.
1 of 5 uploaded, 1 failed
1 of 5 uploaded · 907 MB of 2.3 GB · 1 failed
- Q4 board deck — FINAL (approved by legal) v12.pdfUploaded
18 MB
- site-walkthrough.mov
Uploading, 38%. 774 MB of 2 GB · 3 min left
- customer-interviews.zip
Paused · 114 MB of 326 MB
- pricing-model.xlsx
The server stopped answering. Try again.
- notes.md
Waiting · 0 bytes
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import type { UploadItem } from "./ui/uicontext/components/domain/Upload.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { UploadQueue } from "./ui/uicontext/components/upload/UploadQueue.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 34rem)" } })const files: ReadonlyArray<UploadItem> = [ { id: "f1", name: "Q4 board deck — FINAL (approved by legal) v12.pdf", size: 18_400_000, type: "application/pdf", loaded: 18_400_000, outcome: { _tag: "Accepted", request: "f1" } }, { id: "f2", name: "site-walkthrough.mov", size: 2_147_483_648, type: "video/quicktime", loaded: 812_000_000, rate: 9_400_000, outcome: { _tag: "Pending", request: "f2" } }, { id: "f3", name: "customer-interviews.zip", size: 342_000_000, type: "application/zip", loaded: 120_000_000, paused: true, outcome: { _tag: "Pending", request: "f3" } }, { id: "f4", name: "pricing-model.xlsx", size: 2_400_000, type: "", loaded: 1_100_000, outcome: { _tag: "Refused", request: "f4", reason: "The server stopped answering. Try again." } }, { id: "f5", name: "notes.md", size: 0, type: "text/markdown", loaded: 0 },]export const QueueStates = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( UploadQueue(h, { props: { label: "Files", files, pausable: true, locale: "en-US" }, onEmit: { RequestedPause: () => undefined, RequestedResume: () => undefined, RequestedCancel: () => undefined, RequestedRetry: () => undefined, RequestedRemove: () => undefined, RequestedClearDone: () => undefined, }, }), )API reference
UploadQueueComponent
Props
| Name | Type | Description |
|---|---|---|
labelrequired | string | What's being uploaded, as the list's name: "Receipts" |
filesrequired | UploadItem[] | Every file with its progress and Outcome; the app keeps the list |
pausable | boolean | The transfer can go on from where it stopped: offer Pause |
hideSummary | boolean | Hide the line over the list; for one or two files in a form |
locale | string | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedPause | { id: string } | Stop sending the file, keeping what's sent so the app can go on later |
RequestedResume | { id: string } | Go on with a paused file |
RequestedCancel | { id: string } | Stop the file and drop it |
RequestedRetry | { id: string } | Send a failed file again |
RequestedRemove | { id: string } | Take a finished or failed file off the list |
RequestedClearDone | {} | Take every finished file off the list |
UploadsView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
concurrency | number | 3 | How many files go at once; 3 by default |
initial | UploadItem[] | — | Files already on the list when the page opens: earlier uploads, or a failed one to retry |
idPrefix | string | "upload" | The prefix of the ids new files get; "upload" by default |