Comment by atomicnumber3
8 hours ago
"Note I’m not saying there are zero risks: the agent could mess up accessibility, it could cause an infinite loop that blocks users, etc. But in general, frontend code is a lot more ephemeral and replaceable than other types of code. So I expect many AI coders will feel comfortable just letting their agent handle it unsupervised (for better or worse)."
This is a weirdly reductive take on frontend correctness. Just for the record, I'm a backend dev. So I don't have much stake in this game.
This idea is, of course, not uncommon. "If the backend has to treat the frontend as adversarial anyway, and has all this cool stuff (constraints etc) for guaranteeing consistency of the system, then the frontend can just do whatever, right?" It plays into a lot of biases around typical frontend devs, typical backend devs, language stereotypes, etc. So it _sounds_ good.
Let me tell you for a moment about one of the spookiest bugs I've seen. It was an app for sorting personal photos. You'd upload pics/vids off your phone, they appear in the UI, you click a folder for them to go into (or click delete to discard), etc. Simple app, right?
Well, naturally, pics from even vaguely modern phones are regularly 5MB or more. Not really something you want to sling around while a user is browsing and their main activity is going to be looking at said pic to decide what folder it goes in (or if it gets deleted). So we thumbnail. And the main app only ever shows the user the thumbnails. The backend organized things quite simply: it gets a list of images from the frontend, it assigns each of them a zero-based index, and generates a thumbnail you'll also access via index. Imagine a URL scheme like `images/0` and `images/0/thumbnail` serving the real assets and the thumbnail.
Well, this app had a bug at one point. The backend was indexing by the arbitrary order the user uploaded them in. The frontend was mostly doing this too. Unfortunately the logic for thumbnails was incorrectly indexing by the "taken time" (which was a post-upload timestamp constructed by looking at basically every available timestamp and picking the "best" one. i.e. hopefully the one the iOS camera app adds, but obviously pics come from other places too and you never know what a user will upload). The end result being users would upload pics, see a thumbnail of an accidental pic they took of their shoe, hit delete. But actually they were deleting a pic of their baby or similar.
Literally none of the testing caught this for 2 main reasons: headless tests don't look at images, and you can't write an assertion like ("does this image look like a downscale of this other image") (at least not easily... i guess image models could do it now? but probabilistic? not a word i like in my unit tests? I digress, this predated the current crop of "AI").
Now let me generalize: your frontend isn't just a weird way to call RPCs on your backend. It's part of the application. I don't think you can just hand-wave. And as we saw above, you can't even say "well the frontend is stateless! any bug is 1 deploy away from fixing!" - deploying the frontend didn't get anyone their baby pictures back.
> you can't write an assertion like ("does this image look like a downscale of this other image"
You can though. Maybe not exactly what you are thinking but there are some pretty good image similarity algorithms like dhash out there that do stuff like this. Mostly they get used to check for duplicate uploads, copyright materials, or "does this look like porn" style filters
This isn't something that needs image models to accomplish really.
The actual problem is that no-one had considered that this (desync between front and backend) COULD happen. Once it was realized that it was possible (and worth testing) the bug was practically solved already.
Such is true for many bugs. Even if you have unit tests, they only test on things you've thought of. It's usually the stuff you haven't thought of that gets you.
No reason not to unit test of course, but don't get a false sense of complacency or assume testing is easy either. That's why it's great to do things very carefully (and probably not with AI Agents).