Using an AI Assistant to Brainstorm
Async Background Task Updates
I ran into a classic background task UI problem in my app this week. I have a feature where clicking a button “Generate Post” kicks off a background job that would take quite a while (video processing pipeline). The UI would correctly show a “processing...” pill, but it wouldn’t update to “complete” when the job finished. The user had to manually refresh the page to see the result, which felt janky. Additionally, I want some periodic updates to be shown on the page so users trust it’s still running and can reason about how much longer it might take.
This is a common async challenge, and I’ve solved it a few different ways before. It’s something I could work through on my own, but it speeds things up to use AI to get all the simple options visible immediately.
I described the problem, my stack (HTMX), and asked for a few common approaches to get a quick jumping-off point. It immediately laid out the trade-offs for four distinct patterns.
Here’s the summary of its proposals:
Standard Polling: Use
hx-trigger=”every 1s”to hit a status endpoint repeatedly.Server-Sent Events (SSE): A real-time approach where the server pushes an event to the client when the job is done using the HTMX SSE extension
OOB Swap on Response: Have the initial request wait for the (fast) job to finish and return the final UI. This wasn’t viable for my longer-running jobs.
A “Self-Polling Pill”: A pattern where the server returns only the “processing” pill. That pill then uses
hx-trigger=”load delay:1s”to check its own status. If still processing, the status endpoint returns the same pill (creating a loop). If complete, it returns the final “complete” pill.
This let me skip to evaluating options faster and thinking creatively about other options.
I like simple when it comes to architecture. Server-Sent Events are a perfectly fine solution, but they require adding a dependency (SSE Extension) to manage persistent connections. Why do that when a 1-second polling delay is perfectly acceptable for this feature?
Option 4 was the clear winner for me: a pure-HTMX solution with no dependencies and super easy testing and great debugability. Since I was familiar with the pattern I could quickly voice transcribe all the details that needed to be changed and set up to do this, so it was simple for an agent to make the specific changes I requested. And simple to review and validate that it was what I wanted
This is just a more efficient way to work. AI cannot replace thought, but it can accelerate and help you think through things. It helps me brainstorm faster, surfaces patterns, and lets me focus my time on the actual decision and implementation, not the preliminary research.

