All jobs

Add Loading Indicators to an htmx App

Yes. An agent finds every htmx request that shows nothing while it runs, adds indicators and in-flight styles, checks each in a browser, opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent lists the requests before it adds a spinner, because in an htmx app they are spread across template attributes rather than one fetch layer. In an app laid out like bigskysoftware/contact-app, a Flask application with htmx 1.8.0 vendored at static/js/htmx-1.8.0.js, templates/layout.html sets hx-boost="true" on the body, so every link and form in the app is an AJAX request. templates/index.html has a search box with hx-get="/contacts" on keyup delay:200ms changed and hx-indicator="#spinner" pointing at an <img id="spinner" class="htmx-indicator">, and a count span with hx-get="/contacts/count" on revealed that contains a second image with the same id="spinner". That count takes two seconds, because Contact.count() in contacts_model.py sleeps for two. The rest show nothing while they run: the per-row Delete in templates/rows.html, the bulk delete, the email check in templates/edit.html that fires on every keystroke after 200 ms, the Delete Contact button, the archive button in templates/archive_ui.html whose background thread sleeps up to a second per step, and every boosted navigation to /contacts/new or an edit page.

It starts with the duplicate id, since it is a bug waiting for the next change: hx-indicator="#spinner" resolves with a selector and finds the first match, and two elements share it. The search spinner keeps the id and the count's image loses it, which costs nothing because htmx adds the htmx-request class to the element making the request and its own descendant indicator lights up through .htmx-request .htmx-indicator. Then each silent request gets the smallest thing that shows it is running. The boosted navigations get a bar at the top of the page: hx-indicator is inherited, so one attribute on the body pointing at a #page-indicator element covers every boosted link and form, while the search box's own attribute still overrides it. The email field gets a small Checking… indicator next to .error, and the delete links and the archive button get no new element at all, only a .htmx-request style in static/site.css that dims them and sets pointer-events: none, which also stops a second click on a delete that is already in flight.

static/site.css gains the indicator rules explicitly rather than relying on the stylesheet htmx injects, because htmx.config.includeIndicatorStyles can turn that off and a reviewer should be able to see the rule. The per-row Delete already uses hx-swap="outerHTML swap:1s", so the row sits for a second with htmx-swapping on it; the agent adds a fade for that class so the delay reads as a transition rather than a hang. The Alpine bulk-delete bar, which calls htmx.ajax('DELETE', '/contacts', …) from a click handler, is left as it is and named in the pull request, since an indicator there needs the source element to carry the class and that is a hyperscript or Alpine change outside this one.

The proof is in a browser, because an indicator is a thing you see. The agent installs the pinned requirements in its sandbox, runs the Flask app, and opens it in its own browser: it scrolls the count into view and takes a screenshot while the two-second count runs, types in the search box, clicks through to an edit page while the bar shows, and types an email to see the check indicator. It keeps the screenshots as artifacts and reads app.py to confirm no route changed. The repository has no test suite to run, and the pull request says so.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add loading indicators to the htmx app. Read templates/layout.html, templates/index.html, templates/rows.html, templates/edit.html, templates/new.html, templates/archive_ui.html, static/site.css, app.py and contacts_model.py first, and list every htmx request including boosted navigation, with whether anything shows while it runs. Fix the duplicate spinner id. Add a page-level indicator for boosted navigation through an inherited hx-indicator on the body, an indicator for the email check, and htmx-request styles in site.css that dim and disable the delete links and the archive button while their request is in flight, plus a fade for the htmx-swapping row. Leave the Alpine bulk-delete bar alone and say why. Run the app in your sandbox, open it in your browser, screenshot each indicator while its request runs, and open a pull request with the list, the screenshots and the diff.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that changes templates/layout.html, templates/index.html, templates/edit.html and static/site.css, with no change to app.py. Its description is the table of every request and what it showed before and after, the screenshots taken while each request ran, and a note on the bulk-delete bar it left alone.

The run's record keeps the app start and the browser session, so a reviewer can watch the two-second count with its spinner and the boosted navigation with its bar rather than imagine them from the diff.

Before merging, a reviewer decides whether the dimmed delete controls should also carry aria-busy, which the pull request proposes, and whether to upgrade to an htmx release that has hx-disabled-elt and replace the CSS-only disabling with it, which is a separate change.

Run it on every pull request that adds an htmx attribute

An automation in the Project with a github trigger on pull_request.opened and pull_request.synchronize runs a prompt that reads the pull request's template changes, finds any new hx-get, hx-post or hx-delete with no indicator and no htmx-request style covering it, and posts a review comment naming it. The trigger adds the event after the prompt and fills in nothing else.

A team with several htmx apps starts one run per repository from a script, POST /o/{org}/sessions with this input and the repository in resources, and a request_id that is a UUID v5 of the repository's full name so a retried call returns the run already started. Each run reads that app's own templates, so one on htmx 2 gets hx-disabled-elt where this one gets a CSS rule.

The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.

Why run it on Rush?

Finding every silent request means reading every template and knowing which attributes inherit, and proving an indicator means seeing it, which needs the app running and a browser pointed at it during a slow request. The agent does both in its own sandbox and keeps the screenshots, so the pull request shows the spinner mid-request instead of describing it.

The same job across several apps runs in parallel, one sandbox and one browser each, and every pull request carries that app's own request table and its own screenshots.

Frequently asked questions

Why is the duplicate id a problem if both spinners seem to work?

They work for different reasons: the search uses hx-indicator="#spinner" and gets the first element with that id, and the count's image works only because it sits inside the requesting element. Move the markup and one of them goes dark. Removing the second id keeps both working for one reason each.

Does hx-indicator on the body affect the search box?

No. hx-indicator is inherited by descendants, and the search input's own hx-indicator takes precedence, so it keeps its spinner while every other boosted request shows the page bar.

Why CSS on htmx-request rather than disabling the button?

htmx 1.8.0 has no hx-disabled-elt; it adds the htmx-request class to the requesting element for the life of the request. A rule that sets pointer-events: none on that class stops a second click without touching the markup, and reverts the moment the response swaps in.

Why no indicator on the Alpine bulk delete?

That request starts from htmx.ajax() inside an Alpine click handler with the form as source, so the htmx-request class lands on the form, not the button a user is looking at. Styling that correctly means changing the Alpine component, and the pull request leaves it for a change of its own.

More htmx jobs

More jobs like this: Turn a Linear label into a PR

Keep reading