Multi-Room Scan Interaction and State Machine Debugging Practices

    This article examines why continuous multi-room scanning fails in field workflows and how to model the interaction as a state machine. It covers explicit state definitions, transition guards, rollback checkpoints, multi-metric quality gates, actionable prompts bound to each state, layered disclosure for result pages, and a structured workflow for using AI coding tools to find deep defects through code review. Readers will find a minimal state set, sample transition and prompt logic, a quality-gate metric table, and a verification checklist.

    1. Background: What Field Workflows Demand from Interaction

    In on-site work such as custom home furnishing, interior measurement, and commercial space renovation, the most time-consuming step is often not measurement itself but helping the customer “understand the space.” Verbal descriptions and hand-drawn sketches lose a great deal of information, and customers struggle to build an intuitive sense of spatial scale and relationships within a few minutes. The common industry approach is to walk through the interior with a mobile device, capture continuous images and pose data, and reconstruct a 3D scene and a 2D floor plan sketch in real time or near real time. The customer sees a tangible result first, and key dimensions are recorded afterward.

    The technical difficulty of such tools lies not in a single reconstruction but in continuous multi-room operation. A single room is a relatively closed problem. Once work spans rooms, four things must be handled: loop closure detection, cross-space relocalization, global consistency, and human-machine interaction feedback. If any one of them fails, the user does not see “slightly lower accuracy” but “an unusable result.”

    A typical multi-space field test exposed three high-frequency defects:

    • Failed quality gate: One room reconstructed only about 0.3 square meters of fragmented geometry, yet the system still showed a pass state and prompted the user to continue scanning the next room.
    • Self-contradictory state feedback: When the user reached the doorway, the capture module went to sleep. After it resumed, the prompt asked the user to return to the original room, and the highlighted button wavered between “Continue” and “New.” A mistaken tap produced new data that could not be stitched into the existing scene.
    • Poor result readability: More than twenty wall labels were visible at the same time on the output page, covering the entire floor plan. The excessive information density made it unreadable.

    There was also an accuracy issue: area estimation for large spaces was systematically too high. Such problems usually stem from scale drift and boundary expansion. They belong to the algorithm layer and are noted here only as background; the focus of this article is interaction and the state machine.

    2. Abstracting Interaction Defects as a State Machine Problem

    These phenomena look like UI copy and button issues, but they are essentially ambiguous state definitions, missing transition conditions, and side effects that cannot be rolled back. The workflow should be modeled explicitly before the interface is discussed.

    A usable minimal state set is:

    1. Idle // Not started
    2. Calibrating // Initialization / establishing the initial coordinate system
    3. Scanning // Capturing a single room
    4. RoomReview // Confirming the single-room result
    5. Relocalizing // Cross-space relocalization
    6. GlobalReview // Confirming the global result
    7. Exporting // Generating the 2D floor plan and exporting
    8. Fault // Recoverable error

    The key is to supply three elements for every transition: trigger condition, guard condition, and failure fallback.

    1. on TapNextRoom(from: RoomReview):
    2. guard coverage(currentRoom) >= θ and
    3. loopClosureResidual < ε
    4. else -> enter Fault(reason = LOW_COVERAGE)
    5. action: freeze currentRoom.id; push checkpoint()
    6. goto Relocalizing
    7. on RelocalizeTimeout:
    8. restore(checkpoint()) // Roll back to before entering relocalization
    9. goto RoomReview
    10. toast("Relocalization failed; the previous room result was kept")

    Comparing this with the field observations reveals three design gaps. First, there are no coverage and loopClosureResidual guards, so incomplete rooms are allowed through. Second, sleep and resume of the capture module have no corresponding events, so the state stays in Scanning while the copy shown is that of Relocalizing. Third, the “New” branch has no upfront naming and association decision, so a mistaken tap immediately creates orphaned data.

    3. Quality Gates: Do Not Pass on a Single Threshold

    A single coverage metric is easily “inflated” by locally texture-rich areas. A more reliable approach is a joint decision across multiple metrics:

    Metric Meaning Suggested handling
    Coverage Valid reconstructed area / estimated room area Block directly when below the threshold
    Key surface completeness Whether main walls and floor form a loop Prompt the user to rescan the specified area if missing
    Relocalization residual Loop closure error Prompt the user to walk the path again when above the threshold
    Scale consistency Deviation from a known reference object length Trigger a calibration review when the deviation is large
    Hole rate Share of pixels with missing depth Prompt for insufficient lighting or texture when high

    The interaction should follow the principle of “actionable prompts.” Do not just say “scan failed”; indicate which wall to rescan and which path to walk back along. Prompt text must be bound one-to-one to the current state, so the same state never issues opposite instructions from different entry points.

    1. if state == Scanning and sensorSleep == true:
    2. hint = "Capture is paused; keep the device raised and tap Continue"
    3. elif state == Relocalizing:
    4. hint = "Aligning with the existing scene; move slowly along the original path"

    4. Using AI Coding Tools for Code-Level Debugging

    Complex pages should not be modified by editing code directly. A more reliable path is to have an AI coding tool work with the repository source to map out the interaction and states first, produce a diagram and a transition table for human review, and only then implement changes. For this step to be effective, the prompt must be structured rather than a single natural-language sentence.

    1. Role: Senior client-side architect
    2. Input: 5 consecutive on-device screenshots (scan start / scanning / single-room save / cross-space relocalization / 2D result) + repository path
    3. Task:
    4. 1. Reconstruct the state transition path corresponding to the screenshots and output a state table;
    5. 2. Identify hidden defects that cause data to be unstitchable or states to be inconsistent;
    6. 3. For each defect, provide: trigger steps, code location, impact scope, fix, and regression case;
    7. 4. Show the diagram and transition table first, and wait for my confirmation before changing code.
    8. Constraints: Do not add third-party dependencies; do not change the semantics of public data model fields.

    During review, focus on three things: whether real code locations are cited rather than generic statements; whether exception and rollback paths are covered; and whether reproducible regression cases are provided. A typical difference observed in practice is that most models produce nice interface de-noising and before-and-after comparison images, but only a few follow the state-writing logic to find deep defects such as “retry breaks rooms apart.” The trigger point of that defect spans three parts of the code: relocalization failure, checkpoint restoration, and room identifier generation, so it cannot be noticed by looking at the interface alone.

    5. Result Page Readability: Layering and Progressive Disclosure

    More than twenty wall labels on one screen is typical information overload. A workable strategy is layering:

    • By default, show only room-level outlines and areas, hiding wall numbers.
    • After tapping a room, drill down to show that room’s wall numbers and dimensions.
    • Provide an “annotation toggle + adaptive font size + collision avoidance,” where labels automatically degrade to aggregated markers when they overlap.
    • Switch by purpose on export: the customer communication version removes technical annotations, while the construction version keeps the full numbering.

    6. Implementation Advice and Verification Checklist

    1. Build the state machine and transition table before touching the UI; bind states tightly to prompt text.
    2. Put a checkpoint before every destructive operation (new, rescan, clear) and support one-click rollback.
    3. Use a joint multi-metric decision for quality gates, and make prompt text executable.
    4. Include capture module sleep/resume as explicit events; forbid silent state drift.
    5. Cover four scenarios in regression cases: letting an incomplete room pass, relocalization timeout, mistaken tap on New, and label occlusion.
    6. When cloud capabilities are involved, design by general categories, for example object storage for raw capture packages, a message queue for peak shaving and asynchronous reconstruction, and logging services with monitoring and alerts to track the relocalization failure rate, so stability problems are not left to surface on site.

    Treating interaction as a state machine to govern, and isolating accuracy issues for separate evaluation, can improve the usability of multi-room scanning by an order of magnitude. When using AI coding tools for code-level debugging, structured prompts and the human review step are the key to finding deep defects.