From Interaction Walkthroughs to State-Machine Bug Hunting: Using LLMs to Refactor Complex Front-End Interactions
This article shares a practical workflow for using large language models to refactor complex front-end interactions, based on a real multi-room 3D scanning app. It covers a three-step process of providing full context, documenting problems with evidence, and confirming solutions before coding, along with a comparative experiment across leading models. The results show that UI-level polish tasks are handled similarly by mainstream models, while deep state-machine logic debugging exposes major capability differences. A reusable evaluation checklist for testing models against real projects is also included.
1. A Real Development Scenario
As an independent developer, I have been building a tool for the whole-house customization industry: a user walks around a room with their phone, and the tool automatically generates a 3D scene and floor plan, letting designers present results to clients on the spot.
Once the basic features worked, the truly difficult part emerged — the interaction flow for continuous multi-room scanning. I captured five key frames from actual device sessions covering “start scanning, scanning, saving a single room, relocation across spaces, and final floor-plan output.” Reviewing them frame by frame revealed four typical problems:
- Premature completion feedback: One room produced only 0.3 square meters of fragmentary data, yet the UI showed a green “done” checkmark, encouraging the user to proceed to the next step.
- Contradictory state prompts: When the user walked to a doorway and the camera was interrupted by background sleep, the system then prompted them to “return to the original room to continue” — logically contradicting itself.
- Error-prone visual design: Two highlighted buttons had nearly equal visual weight, and accidental taps triggered “create a new separate room” instead of “merge back into the existing room,” breaking the data chain.
- Information overload on the results page: The final floor plan showed more than twenty automatically numbered wall labels densely packed together, obscuring the key graphic information.
All these problems share a common trait: any single screenshot looks only mildly problematic, but when strung together into a complete interaction flow, the experience becomes awkward everywhere. This is the classic dilemma of complex interaction design — local correctness does not imply global smoothness.
2. A Workflow of “Let the Model Understand the Problem First, Then Touch Code”
When refactoring a complex page that already works, the worst approach is to start changing code immediately. My habit is to split the workflow into three steps.
1. Provide complete context
I mount the project source code locally so the model can understand the real code structure and state transitions, rather than guessing the implementation from screenshots alone.
2. Describe the problems + provide evidence
I submit multiple real-device screenshots together with one unified descriptive prompt, and ask the model to do two things:
- Enumerate all problems in the current interaction flow, ranked by severity;
- For each problem, produce a mockup of the revised design and explain the proposed fix, for human review.
3. Only code after the solution is confirmed
Only after the mockups and logical reasoning pass human review do I move into actual code changes. The value of this step is that the cost of “fixing things in the wrong direction” is moved forward into the zero-code stage.
3. A Simple but Effective Model Comparison Experiment
With this workflow in mind, I submitted the same source code, the same screenshots, and the same prompt to the highest reasoning tiers of leading general-purpose LLMs (tier names differ across platforms, but each was the strongest thinking mode available in its client) for a horizontal comparison.
The goal was not benchmark scores, but a more practical question: how large is the capability gap between models on “front-end interaction noise reduction” versus “deep logical bug hunting”?
Result 1: UI-level noise reduction — little difference across models
For visible issues like excessive wall labels on the results page and overly high information density, all tested models produced usable solutions, such as grouping labels by wall, adding toggle switches, and offering a simplified mode. Some lower-priced models performed on par with flagship tiers on these tasks. This suggests that for pattern-based UI optimization problems, mainstream models are already quite close in capability, so there is little reason to agonize over model choice.
Result 2: Deep logical bug hunting — a clear divergence
What truly separated the models was the second problem. Hidden in the test data was a state-machine defect: when a user taps “retry” after an abnormal interruption, the app should return to the original room and continue scanning; instead, it creates an isolated new room that cannot be stitched to the existing data.
Of the four models tested, three failed to find this bug — they focused on the interface layer and reviewed the state-flow code only superficially. Only one model traced the complete state-machine transition paths through the code and uncovered the hidden defect.
Conclusions and reflections
This experiment gave me two insights:
- The capability difference is not about “can or cannot,” but about “how deep.” For complex interactions and state-machine logic, whether a model is willing and able to perform complete path enumeration and boundary reasoning is the key dividing line between flagship and ordinary models.
- Don’t pick models by benchmark scores alone. Models with similar benchmark scores can perform very differently on real engineering tasks. The most reliable approach is a small-scale test with your own real project — as this experiment showed, one round was enough to reveal which models can withstand complex logical scrutiny.
4. A Reusable Evaluation Checklist
If you want to verify whether the tools at hand are up to complex front-end refactoring, design your experiment following this checklist:
- Prepare real code with seeded defects, ideally hidden in the state-flow layer rather than the interface layer;
- Keep the prompt and context identical across runs, so the only variable is the model itself;
- Require an initial problem list and mockups to evaluate the completeness and accuracy of its problem localization;
- Focus on edge cases: interruption recovery, accidental taps, incomplete data, and other non-happy-path scenarios;
- Have humans review before coding, always retaining final judgment over the solution.
5. Final Thoughts
LLMs are evolving from “code completion tools” into “solution review partners,” but the quality of their output depends heavily on the task type: pattern-based optimization is already reliable, while deep logical reasoning remains the strength of only a few models. Understand the strengths and weaknesses of your models, then decide which parts of the work to delegate to them — this is far more practical than chasing any leaderboard. The same methodology applies to developers using regional model ecosystems or AI-powered coding platforms: test them with your most complex, real business scenarios, and the answer will reveal itself.
