AI Coding Assistants in Practice: Debugging Mobile State-Machine Defects with LLMs

    A walkthrough of using AI coding assistants to review a multi-room indoor scanning flow: evidence-first review, model comparison on the same prompt, a hidden relocation-retry bug, and a reusable checklist for complex mobile UI state machines.

    1. Background: A Real Interactive Complexity Problem

    I had been iterating on a small indoor space-scanning tool published on the app store. Friends in whole-home customization said that talking through a space or sketching on paper rarely helped clients picture a renovation. The tool lets you walk a room with a phone and quickly produce a 3D scene plus a 2D floor plan—useful on site and as a way to capture dimensions.

    After the basics worked, the remaining pain was the flow for scanning several rooms in a row. I tested in a multi-space venue and captured five sequential screenshots: start scan → scanning → save one room → cross-space relocation → 2D floor-plan result.

    Setting aside overestimated area in large spaces, the five-screen sequence still felt wrong:

    1. False success. Screen 3 showed only a 0.3 m² fragment, yet the UI still showed a green check and pushed the user to the next room.
    2. State thrashing. After the camera slept in the background at a doorway, screen 4 told the user to return to the original room.
    3. Trap in error recovery. Tapping the wrong highlighted button created a “new room only” path, so the new room would not join previous scans.
    4. Overloaded result page. The floor plan was covered with more than twenty wall IDs.

    These issues point to the same class of problem: a multi-state, multi-branch interaction state machine. On mobile, UI copy, background lifecycle events (camera sleep), and recovery from mis-taps are tightly coupled. Reading code by eye rarely covers every branch.

    2. Method: Review the Plan Before Changing a Complex Screen

    I do not start by rewriting complex screens. The habit is review first, then code:

    1. Collect evidence. Number key-path screenshots in time order as a traceable record.
    2. Let the model reason over source. With the project code available locally, give the screenshots and one spoken prompt to an AI coding assistant so it can map issues to the implementation.
    3. Review diagrams first. Ask for a schematic flow or page sketch of the proposed change; only then change code.

    The point is to shift discovery cost onto model reasoning while keeping decisions with the developer. The model enumerates branches and surfaces risks; the person judges whether the product still feels right.

    A typical workflow:

    1. Device screenshots (evidence) + project source (context) + one shared prompt
    2. ↓
    3. AI output: issue list + state-machine sketch + proposed change
    4. ↓
    5. Human review → confirm plan → edit code → regression test

    3. Side-by-Side: Same Prompt, Different Models

    For a fair comparison, I sent the same five originals and the same spoken prompt to four mainstream AI coding assistants, using each client’s highest reasoning tier.

    I expected similar plans after they read the same source. The spread was larger than expected.

    1. Page noise and visualization: lighter models did well

    On issues like result-page overload—reducing twenty-plus wall IDs to readable wall-segment labels, or before/after layouts—the cheapest lightweight tier and the mid-tier model in the same family were strong: layouts were clear, the change set was small, and the ideas were easy to ship.

    Practical takeaway: UI noise reduction, grouping, and progressive disclosure do not need deep reasoning. Cheap, fast tiers are often enough; not every task needs the top model.

    2. Deep logic: only one model found the real bug

    On deeper logic, the gap was large. Three of four flagship models missed a hidden bug: in the “cross-space relocation” state, tapping Retry took the “create a new room only” branch, splitting rooms and failing to stitch to previously scanned areas.

    Only one flagship model walked the path through the code: click handler → current state-machine branch → gap in error recovery → data inconsistency, then suggested a fix. For complex interaction and state machines, flagship reasoning is not captured by leaderboard scores.

    3. Why most models missed it

    Likely causes:

    • Poor use of context. State-machine logic lived in several modules; some models concluded after the entry file.
    • No adversarial walkthrough. They followed the happy path instead of enumerating what the user can tap in each state.
    • Prompt density. One spoken sentence is enough for a colleague; for a model, the issue list was not structured.

    Prompt patterns that improved detection:

    1. 1. Require enumerating every user-triggerable event in each state.
    2. 2. Ask for a state × event transition matrix and mark suspicious branches.
    3. 3. Have the model restate the state machine first; confirm, then debug deeper.
    4. 4. Attach device screenshots as counterexamples to bound the discussion.

    4. Checklist: AI-Assisted Changes to Complex Screens

    I turned the practice into a reusable list:

    • Use models in layers. Lightweight tiers for UI cleanup; flagship reasoning for state machines, concurrency, and data consistency.
    • Lead with evidence. Screenshots, logs, and repro steps are the model’s fuel; vague descriptions work worst.
    • Compare with one prompt. Feeding the same input to several models often highlights the most hidden issues where they disagree.
    • Keep human review. Especially for product feel: models are strong at finding mines; people still decide what interaction feels right.
    • Sketch before code. Flowcharts and mockups kill plan-level disagreement before implementation and cut rework.

    5. Closing

    The main lesson: the value of AI coding assistants shows up where benchmarks do not. UI polish is widely available; the differentiator is walking a hidden error-recovery path through the code.

    For indie developers and small teams, a layered usage strategy and a review workflow matter more than “which model is strongest”: fast models for easy work, deep reasoning for hard problems, humans on the decision. That process is more durable than any single model.