
The UX of On-Device Inference
A client AI feature's first impression is a progress bar. Designing the download, the streaming output, worker isolation, and honest failure states so the wait feels deliberate.
TL;DR: A client-side AI feature's first impression is a progress bar, not the feature itself — the download, the wait, the streaming output, and the eventual failure each need to feel deliberate rather than broken. This article covers designing the first-run download as an honest experience, using token streaming to convert a real wait into an engaged one, keeping the page responsive with Web Worker isolation, and handling failure and thermal limits without ever leaving the user staring at a silent spinner.
The first run is the feature's first impression
Client-side AI has a structural difference from server-hosted AI that shapes everything about its UX: the first use may require a large download, so the feature's opening act is logistics before it is capability. Hiding that reality from the user reads as breakage — a feature that appears to hang for no visible reason. Presenting it honestly, as a real download with a real reason, reads as substance instead.
Consent belongs before weight moves, particularly on metered or otherwise constrained connections. Stating the download size plainly and asking before it starts is not friction — a surprise 300 MB download landing on someone's data plan is a trust withdrawal the feature is unlikely to earn back with whatever value it eventually delivers.
Progress needs to tell the truth about what kind of waiting is happening. The download itself can show determinate progress, because bytes downloaded are a countable, honest number. Initialization after the download completes is a different kind of wait — whether model loading and runtime warm-up report a percentage depends on the runtime. WebLLM, for example, reports both loading weights from its cache and loading GPU shader modules as a fraction through its initialization progress callback (source, not documented, v0.2.88, as of November 2026). Show what the runtime actually reports, and when it reports no fraction, an honest indeterminate state serves better than a fabricated percentage. Throughout both phases, the page itself must remain fully usable; the download mechanics that make this possible belong to the loading side of this topic, and this article's job is only the presentation layer on top of them.
Deferral itself is a design choice, not a default. Downloading only on explicit feature invocation, or downloading quietly in the background after a clear opt-in, are both legitimate patterns — which one fits depends on the feature's weight and on how much trust the relationship with the user has already earned, and it should never be chosen by accident. A lightweight embedding model used for search-as-you-type can reasonably fetch itself quietly in the background the first time a user opens the relevant screen; a multi-hundred-megabyte generation model earns an explicit prompt instead, because the size and the commitment it represents are simply not comparable.
Streaming as perceived performance
Local generation has a distinctive latency shape: a perceptible pause before the first token appears — the prefill — followed by a comparatively steady flow of output after that. The right design target follows from that shape directly. It is time-to-first-visible-progress, not time-to-completion, because the first visible token is what tells a waiting user that something is actually happening.
Token streaming into the interface is a high-leverage move for perceived performance on a generation-shaped feature. A five-second wait for a complete answer feels slow and uncertain; the same five seconds spent watching words arrive one after another feels like an engaged read rather than a stall, even though the total elapsed time has not changed at all.
A stream needs an exit. A visible stop control that the user can invoke, paired with generation that genuinely halts the moment the user navigates away or starts typing something new, is not optional polish — a stream nobody can stop is closer to a hostage situation than a feature, however good the output eventually turns out to be.
Non-generation tasks stream differently, and it is worth naming the distinction explicitly. Classification and embedding results arrive whole, and on capable hardware they can arrive quickly. When they do, the design problem inverts: the job is making a fast result feel appropriately fast, not dressing it up with a theatrical spinner borrowed from the generation case where the wait is actually real. Reusing a generation-shaped loading pattern on a task that genuinely completes in a few dozen milliseconds manufactures a delay the underlying computation never actually had.
Keeping the page alive under load
The main-thread rule for this topic is close to non-negotiable: inference runs inside a Web Worker, so the page keeps scrolling, keeps accepting typed input, and keeps responding to the user while the model computes in the background. A frozen tab during inference is a recognizable client-AI failure mode, and moving inference off the main thread addresses it through architecture rather than careful timing.
// Inference lives in a worker; the main thread never blocks on compute
const worker = new Worker('inference-worker.js')
worker.postMessage({ type: 'infer', input })
worker.onmessage = (e) => handleStreamChunk(e.data)As of November 2026, the WebGPU specification does not define how a GPU schedules compute work against rendering work; a working hypothesis, not a documented rule, is that heavy compute and rendering on the same GPU compete for it. Running inference during an animation-heavy moment on the page can degrade both the animation and the inference — scheduling the heavier computational work into quieter moments in the interface is a genuine, usable design lever rather than a micro-optimization.
Concurrency needs an honest default: one inference request in flight at a time per model. Rapid-fire requests — the per-keystroke case, most obviously — need queuing or coalescing at the feature layer, with simple debouncing usually enough to keep the model from being asked to do work that will be discarded before it finishes anyway.
The worker's messaging shape is worth sketching as a concrete pattern, and WebLLM's web-worker engine has a message for each part (source, not documented, v0.2.88, as of November 2026): an init message that loads the model once, a request message per inference call, stream-chunk messages carrying partial output back to the main thread, and a cancel message that actually stops generation rather than merely hiding its output.
Failure, timeout, and thermal honesty
Local inference fails locally, and each failure mode needs its own honest, non-technical, user-visible state. Out-of-memory errors call for a downgrade: WebGPU reports them as a GPUOutOfMemoryError, and its specification notes that the operation may succeed if attempted again with a lower memory requirement, or if memory used by other resources is released first. GPU device-loss events also happen, and on genuinely weak hardware a generation may simply never finish within any reasonable window — each of these deserves language a non-technical user can actually understand, without pretending the failure did not happen.
The timeout posture matters as much as the failure states themselves. A generation that exceeds its time budget should degrade to a fallback path where one exists, or end with a plain-language explanation where it does not. Silence and an infinite spinner are the two endings this article bans outright — both leave the user with no information and no path forward, which is strictly worse than an honest failure message.
Battery and thermal courtesy deserve explicit design attention on mobile devices. Sustained inference genuinely heats a device and drains its battery measurably, so long-running features should respect page visibility changes and back off when the tab is backgrounded, rather than continuing to run at full intensity somewhere the user cannot even see the output arriving. A feature that keeps computing after the user has switched apps is spending real battery on output nobody is watching.
The fallback path's user experience has to match its privacy story honestly. If degrading from on-device to server inference changes where the user's content actually travels, that switch needs to be disclosed to the user, not made silently behind the scenes — the full disclosure framework for that trade-off belongs to the privacy side of this topic, but the UX rule stated here is simple: a change in where data goes is never a change the interface hides.
Taken together, these are not separate polish items to add once the feature works — they are the difference between a feature that reads as a deliberate product decision and one that reads as an unfinished demo someone forgot to clean up before shipping.