Real-World UI Refactoring: A Hands-On Comparison of Four AI Coding Tools
A practical evaluation of four AI coding tools on a real indoor measurement app. Using the same screenshots, source code, and analysis prompt, the comparison examines visual cleanup, state-machine debugging, and implementation readiness across a multi-room scanning workflow. It also presents the fixes, lifecycle considerations, and regression tests needed to make the interaction reliable.
Real-World UI Refactoring: A Hands-On Comparison of Four AI Coding Tools
1. The Problem: A Real Multi-Room Scanning Workflow
I have recently been refining an in-house indoor measurement tool. Its core use case is simple: users walk around a room with their phone, the system quickly generates a 3D scene, and spatial relationships can then be used to measure dimensions and produce a floor plan. Once the basic functionality was working, the most serious usability issues appeared in the transitions involved in scanning multiple rooms.
To expose these issues, I completed a full scan in a multi-room space and captured five consecutive device screenshots covering:
Start scanning → scanning in progress → saving a room → repositioning across spaces → 2D floor-plan result
Viewed as a sequence, the problems were obvious:
- First issue: One room produced an incomplete area of less than 0.3 square meters, but the interface still displayed a green success message and encouraged the user to scan the next room. The user naturally assumed that the room had been saved successfully. In reality, the incomplete fragment could not participate in later spatial stitching.
- Second issue: When the user reached a doorway, the camera entered sleep mode. After the interface returned, it instructed the user to “return to the original room and scan again,” but the highlighted button behaved more like “create a new room” than “continue stitching the current draft.” A mistaken tap could disconnect all previously scanned space.
- Third issue: The final results page displayed every wall label at once. More than 20 labels covered the floor plan, making the room outlines difficult to see.
These were not merely styling problems. They were interaction failures caused by the combination of a state machine, callback paths, and data-filtering rules.
2. Method: Show the Model the Source Code Before Changing It
Complex pages should not be modified immediately. My usual process is to provide the screenshots and project source code to an AI coding tool first, asking it to analyze the interaction problems and produce both an issue list and a redesign diagram. Only after reviewing the proposed approach do I move on to code changes.
The prompt was deliberately constrained. Instead of asking the model to describe what “looks bad,” I required it to analyze the workflow at three levels: user path, state transitions, and the responsibility of each visual element.
Using the screenshots and source code below, analyze the interaction issues from the perspectives of “user path, state transitions, and visual element responsibility.”Output an issue list and a page redesign diagram.For each issue, identify the root cause by specifying the relevant state, function, and callback branch.Provide the proposed approach first. Do not rewrite the complete code yet; the output will be reviewed by the development team.
This approach matters because directly changing code can easily hide one local problem while creating another. Cross-space repositioning is especially risky: it involves room drafts, camera lifecycle events, and spatial stitching relationships. Without first mapping out the state transitions, any implementation is likely to introduce new defects.
3. Evaluation: The Same Source Code Produced Very Different Results
I provided the same five screenshots, the same prompt, and the same project source code to four mainstream AI coding tools. I also selected the highest reasoning tier available in each client wherever possible. I expected their performance on complex interactions to be broadly similar, but the results showed a clear separation.
For convenience, the four tools are referred to as Tool A, Tool B, Tool C, and Tool D.
| Dimension | Tool A | Tool B | Tool C | Tool D |
|---|---|---|---|---|
| Visual noise reduction and comparison mockups | Excellent | Good | Excellent | Fair |
| State-machine debugging | Missed | Identified | Missed | Missed |
| Practicality of the proposed fix | Medium | High | Medium | Low |
Tools A and C were particularly strong at reducing visual noise. They quickly identified the excessive number of labels on the results page, the unclear hierarchy of the instructional text, and the overly prominent primary button. They also provided redesign suggestions with comparison mockups. However, their analysis mostly remained at the visual layer and did not trace the underlying button logic deeply enough.
Tool D was more conservative. It offered many suggestions such as adding explanatory text, reducing background emphasis, and adjusting colors, but it failed to identify the critical break in the cross-space repositioning flow.
Tool B was the only one that followed the button entry point deep into the source code. Rather than changing only the text shown on the page, it traced the retry button’s click event to the room-creation function and uncovered a hidden bug: clicking Retry did not reuse the current room draft. Instead, it went directly through the new-room branch. As a result, a space that should have been stitched to the existing room became a separate room. The user believed they were rescanning, but the application had already split the room into two independent entities.
An even more revealing example came from a lightweight model that looked only at the screenshots and did not inspect the source code. It recommended removing the 3D white model in the lower-right corner because it considered the element “too visually noisy.” In fact, that white model was the core output of the scene-generation workflow. This illustrates the risk of relying on visual understanding alone: an element may look inconvenient while still being essential to the product’s primary function.
4. The Fixes: State Management, Visual Cleanup, and Regression Testing
4.1 Fixing the Retry Button State
The original logic can be simplified to the following incorrect implementation:
function handleRetry() {// Bug: creates a new room and loses the current stitching relationshipcreateRoom();}
The correct approach is to first determine whether an unfinished room draft exists. If it does, the application should change that draft’s state to rescanning while preserving the existing room ID. A new room should be created only when no valid draft is available.
An illustrative fix would be:
function handleRetry() {const draft = getLatestDraftRoom();if (draft && draft.status === 'saved' && draft.area < MIN_VALID_AREA) {updateRoomStatus(draft.id, 'rescanning');return;}createRoom();}
The key point is to preserve the room ID. Only when the ID remains unchanged can the cross-space repositioning flow determine that the current scan continues from the previous room rather than starting from an unrelated new room.
4.2 Reducing Label Noise on the Results Page
Displaying more than 20 wall numbers directly on the floor plan is fundamentally an information-hierarchy problem. Three rules can help:
- Filter by area: Hide wall labels below a chosen threshold by default. Display them only when the user selects them.
- Link visibility to zoom level: At low zoom levels, show only room centers and major dimensions. Reveal detailed wall labels after the user zooms in sufficiently.
- Group labels visually: Merge labels for adjacent walls into clusters, and reveal the individual details when the cluster is expanded.
A simple filtering implementation could look like this:
const visibleWallLabels = walls.filter((wall) => {if (zoom < 2) return wall.area > 0.5;return true;});
This preserves access to the complete information set without turning the initial floor-plan view into a pile of overlapping labels.
4.3 Cross-Space Repositioning After Camera Sleep
Camera sleep is not an ordinary UI state. It is a device-lifecycle event. When the page becomes visible again, the application must actively restore the scanning state machine instead of simply displaying a message telling the user to return to the original room.
A more appropriate transition is to enter a reacquire state, restore the most recent draft when possible, and automatically switch to the continuation entry point for the current room. If the draft has expired or is otherwise invalid, the user can then be prompted to create a new room.
The highlighted button must also correspond exactly to the underlying state transition:
- If the button says Continue stitching, it must call
resumeRoom. - If the button says Retry, it must call
updateRoomStatus(roomId, 'rescanning').
The form text, button label, and callback action must remain consistent. Once those three elements diverge, users are likely to encounter a failure at a critical point in the workflow.
5. Regression Testing: Locking the State Machine into Test Cases
State-machine bugs are difficult to find through manual interaction alone. Even if a defect is fixed once, a later change can easily reintroduce it. Critical state transitions should therefore be represented in unit tests:
test('retry keeps the same room id when area is too small', () => {const state = reducer(initialState, {type: 'roomSaved',roomId: 'room-1',area: 0.3,});const next = reducer(state, { type: 'retryPressed' });expect(next.rooms.map((r) => r.id)).toContain('room-1');expect(next.activeRoomId).toBe('room-1');});
This test ensures that Retry continues to reuse the current draft instead of creating a new room.
6. Conclusion
The main lesson from this comparison is that visual understanding can answer whether a page looks good, while deeper reasoning is needed to determine whether the underlying logic is correct.
In complex UI refactoring, the most time-consuming work is often not layout adjustment. It is understanding state machines, device lifecycles, and data-stitching behavior—the parts users cannot see directly. Four tools may appear close when evaluated broadly, but their differences become obvious in real projects involving multi-room scanning and cross-space repositioning.
For future complex interaction work, I will follow one rule: provide the screenshots and source code together, and require the model to identify root causes before proposing a solution and writing code. Only when the state machine is secured by regression tests can UI refactoring avoid becoming a cycle of fixing one problem while creating another.
