What the agent does
Infinite scroll in htmx is a server change first, so the agent reads how the list is built before it touches a template. In an app like bigskysoftware/contact-app, contacts() in app.py already parses page = int(request.args.get("page", 1)) and then never uses it: it calls Contact.all() with no argument. Contact.all(page=1) in contacts_model.py does slice by PAGE_SIZE = 100, and Contact.search() returns every match in one list. The committed contacts.json holds 17 contacts, so the first page is the whole table and nobody has seen the gap. The table body comes from templates/rows.html, which the search box also fetches on its own: the input in index.html has hx-target="tbody", and the route returns just the rows when the HX-Trigger header is search.
The agent passes the page through, gives search() the same slice, and has both return whether more rows exist, which it finds by reading one row past the page size. Then it puts the scroll trigger where the search will not break it. The last row of a page that has a successor carries hx-get with the next page and the current q, hx-trigger="revealed" and hx-swap="afterend", and it lives in rows.html. When a new search replaces the table body, the old trigger goes with the old rows and the first page of the new results brings its own. The app already uses revealed for the contact count under the table, so the pattern is one the codebase knows.
Three things in this app decide whether the result is correct. The route must tell a row fetch from a navigation: layout.html sets hx-boost on the body, so a boosted link to /contacts?page=2 also arrives as an htmx request, and it needs the full page. The agent returns bare rows only when the request is from htmx and is not boosted, which htmx marks with the HX-Boosted header. The rows that arrive later must behave like the first ones. Each has a checkbox bound with Alpine's x-model="selected" and an overflow menu that static/js/rsjs-menu.js wires up on the htmx:load event, so the agent checks both on a row loaded by scrolling. And a visitor without JavaScript needs a way forward, so the last row also holds an ordinary link to the next page.
To test it, the agent needs more rows than the repository has. It makes the page size a setting, generates a few hundred contacts into a temporary copy of contacts.json so that Contact.save_db() never rewrites the committed file, and adds pytest tests with Flask's test client: page 1 holds exactly one page and a trigger for page 2, the last page holds none, a search keeps q in the next link, a page past the end returns no rows and no error, and a boosted request gets the full document. Then it starts python app.py against the generated data, scrolls the table in the sandbox's browser and records the sequence of /contacts?page= requests, ticks a checkbox on a late row to see the selection counter move, and opens that row's menu.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "codex",
"input": "A GitHub issue labelled agent asks for the contacts table in this Flask and htmx app to load more rows as the user scrolls. Read app.py, contacts_model.py, templates/layout.html, templates/index.html, templates/rows.html, static/js/rsjs-menu.js and contacts.json first, and say in the pull request how paging works today, including any page parameter that is parsed and not used. Page the list and the search on the server and have both report whether another page exists. Put the trigger on the last row in rows.html: hx-get to the next page with the current q, hx-trigger revealed and hx-swap afterend, plus a plain link for visitors without JavaScript. Return bare rows only for an htmx request that is not boosted, and the full page otherwise. Keep the active search working: a new search must replace the rows and reset paging. Make the page size a setting. Add pytest tests with the Flask test client against generated contacts in a temporary copy of contacts.json, never the committed file: first page, last page, a page past the end, a search with a next page, and a boosted request. Start the app with a few hundred generated contacts, scroll the table in the browser, record the page requests, and confirm on a row loaded by scrolling that its checkbox updates the selected count and its Options menu opens. Finish with git status to show contacts.json is not modified, and open a pull request that closes the issue.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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
The pull request changes app.py, contacts_model.py and templates/rows.html, and adds tests. The description starts with what the agent found: the page argument that was parsed and dropped, the unbounded search, and the row count that hid both. It then shows the pytest output and the browser check: the ordered list of page requests made while scrolling, the selected-count text after ticking a late row, and a screenshot of an open row menu on the third page.
It also states the behaviour that changed for existing users. The table no longer renders every contact on first load, so the browser's find-in-page reaches only the rows loaded so far, and the bulk delete acts on the rows that are ticked, which can now span several loaded pages. A row deleted from a loaded page shifts the pages after it by one, so a contact can be skipped until the next reload; the description names that as the known limit of offset paging over a list that changes and says what a cursor on the contact id would cost.
A reviewer checks that the page size suits the real data, that git status at the end of the transcript shows contacts.json untouched, and that the full-page branch still renders for a boosted request, since a mistake there shows up as a page with rows and no layout.
Run it on every GitHub issue labelled agent
Add an automation to the Project in the console with a github trigger on issues.labeled and the label agent in its labels setting. The saved prompt is the general form of this one: read the issue, find the list it names, page it on the server, load more on scroll, test it and open a pull request that closes the issue. The trigger adds the issue after the prompt, so the same automation serves the contacts table today and the audit log next month.
Only a label added by an owner, member or collaborator of the repository fires the trigger, so a visitor cannot start runs by filing issues. To start the same job from your own tooling, send this body to POST /o/{org}/sessions with a request_id that is a UUID v5 of the issue's node id, and a retried call starts nothing new.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Infinite scroll is a feature you verify by scrolling. The rows that arrive later are where it breaks: a checkbox Alpine never bound, a menu that does not open, a second request for a page already loaded. The agent's sandbox runs the app and a real browser, so it generates enough data to need several pages, scrolls through them and keeps the request log and screenshots with the run. The pull request shows the feature working on rows a unit test never renders.
It also keeps test data out of your repository by construction. This app persists by rewriting a JSON file in its working directory, which makes it easy to commit three hundred generated contacts by accident. The sandbox is thrown away after the run, and the prompt asks for git status as the last command, so the transcript itself shows the committed file was not changed.
Frequently asked questions
Does it work together with htmx active search?
Yes, when the trigger lives in the rows partial. A new search replaces the table body, so the old trigger disappears with the old rows and the first page of results carries a new one with the current q. A test covers a search that has a second page.
Can I get a Load more button instead of automatic loading?
Say so in the issue. The server change is identical; the last row holds a button with hx-get and a click trigger where the automatic version uses revealed. The plain link for visitors without JavaScript stays the same.
Will rows loaded later still work with Alpine and the row menus?
They should, and the agent checks. Alpine binds elements added to the page, and this app's menu script listens for htmx:load, which htmx fires for new content. The browser check ticks a checkbox and opens a menu on a row from a later page and reports what happened.
Does this need htmx 2?
No. revealed and hx-swap="afterend" are in the 1.8.0 file this app vendors, and the agent does not upgrade it as part of this job. Upgrading htmx is a separate pull request with its own checks.
More htmx jobs
The same job on other stacks
- Add Infinite Scroll to a TanStack Query List (TanStack Query)
More jobs like this: Turn a Linear label into a PR
- Add an Ingress Template to a Helm Chart (Helm)
- Add an Ingress to a Kubernetes App (Kubernetes)