State Machine Design for Multi-Room Scanning Workflows
Reliable multi-room scanning depends on more than clean floor plans. This article explains how explicit session states, stable room identifiers, completion checks, and separated delivery and debug views prevent retries, tracking interruptions, and accidental actions from breaking room connections. It also outlines a code-first review process, interaction improvements, regression tests, and privacy-conscious observability.
In custom interior projects, commercial site surveys, and space-planning discussions, verbal descriptions and hand-drawn sketches often fail to give clients an immediate sense of a space. A more practical approach is to walk through the site with a mobile device and quickly produce a 3D scene, a 2D floor plan, and dimensions that can be checked.
Once scanning a single room works, the harder problem is not necessarily producing a cleaner drawing. It is ensuring that scanning, saving, relocalizing between rooms, and presenting results all follow consistent state rules throughout a multi-room session.
Field Scanning Reveals More Than Isolated UI Defects
A typical multi-room workflow progresses through starting a scan, scanning a room, saving it, relocalizing near a doorway, and viewing the final 2D floor plan.
Overestimated area in a large space can be treated as a measurement or algorithm issue. Interaction problems, however, can turn measurement uncertainty into a result that is unusable for planning.
Four recurring problems illustrate this.
1. Completion criteria are too permissive. A frame covering only a fraction of a square meter of incomplete surface may still trigger a success indicator and an invitation to scan the next room. The user assumes the current room is complete, but later alignment lacks the walls and openings needed to connect it to adjacent rooms.
2. Sensor lifecycle and navigation guidance disagree. Near a doorway, the camera may become inactive or its preview may stop, while the next instruction tells the user to return to the original room. By the time the user follows that instruction, the session may have lost its pose information or room identifier.
3. Primary and branching actions are too close together. A slightly misplaced tap on a highlighted button can change “continue adding to this floor plan” into “create a separate space.” The new session has no shared parent with the earlier rooms. Adjusting wall lines afterward cannot restore that missing relationship.
4. The results page treats debugging data as deliverable content. More than twenty wall identifiers can fill the drawing, obscuring door openings, room dimensions, and circulation paths. The site discussion stops while someone explains the labels.
These problems often occur together because they share the same session state. They are not four independent page-level defects.
Review State Before Redesigning Screens
For a complex interface, changing layout and copy should not be the first step. Visual improvements can hide faulty branches: a button may have a clearer label while still creating a new room in the wrong state.
A safer sequence is to capture the complete screen sequence from a real multi-room scan, compare it with state definitions, events, and page bindings in the source code, and produce an interaction diagram. Implementation changes should follow review of that diagram.
Rather than asking only whether a screen looks good, review the workflow along its timeline:
- Which events are currently allowed?
- Which fields does each event change?
- Which committed fields must not be silently invalidated by the next tap?
- Where do failure, camera inactivity, back navigation, and retry return the session?
- Does the results page display a delivery model or a debug model?
Given the same screens and task description, different AI coding tools may suggest similar visual improvements: fewer wall labels, less prominent success indicators, and clearer separation between the primary action and the new-space entry point.
Those suggestions are useful, but insufficient. Deeper review requires tracing the call chain:
- Does retry reuse the room identifier, or allocate a new one and discard the existing pose?
- Does save commit a completed room, or merely preserve a draft that still needs work?
- When cross-room relocalization fails, does the application suspend the current room or move the user into a new root?
A review based only on before-and-after mockups can miss defects such as “retry disconnects the rooms.” On screen, retry appears to mean scanning the same room again. In code, it may mean ending the current room, creating another room, and clearing alignment relationships.
The user thinks they are filling in a missing wall. The system has already split the previous work into unrelated fragments.
Constrain the Workflow with an Explicit State Machine
Represent the multi-room session with explicit states rather than scattered page-level Boolean flags. The following stages provide a useful discussion model; their names do not need to be copied directly into an implementation.
- Idle: No active session. The user can start a new floor plan or open a previous result.
- Scanning: The current room is being captured. Pause and discard are allowed; saving is allowed once completion criteria are met.
- Pending rescan: Coverage is insufficient or tracking has been lost. The user cannot proceed to the next room, and the scan cannot be marked successful.
- Draft saved: The current room has a stable identifier and geometry suitable for alignment. The user can move toward the doorway to relocalize.
- Relocalizing: The camera may be inactive. Guidance should explain that tracking is being restored rather than vaguely instructing the user to return to the original room.
- Ready to connect: Relocalization has succeeded. The next room inherits the same floor plan identifier.
- Detached or new root: This state is allowed only after the user explicitly chooses not to merge with the current floor plan. An accidental tap or retry must not trigger it implicitly.
- Result delivery: The application displays the floor plan, dimensions, and a small number of essential annotations. Debug identifiers are hidden by default.
Put the key invariants in the review checklist, then enforce them through assertions or tests:
- If coverage area or room-completion quality is below the threshold, do not show success guidance or offer “scan the next room.”
- Retry must retain the original room identifier by default. Allocate a new identifier only after an explicit “discard and create new” action.
- Camera inactivity is a tracking-state change, not a rollback of business state. If recovery fails, remain in an understandable failure state and preserve the saved draft.
- Continuing the current floor plan and creating a separate space must be distinct actions, with explicit confirmation for the separate-space branch. A highlight change within the same touch target must not decide between them.
- The default results view must support client communication. Wall identifiers, tracking points, and debug layers belong in secondary views.
Illustrative transition constraints can be expressed as pure logic without tying them to a particular tool’s interface:
on Retry:require roomId unchangedrequire floorPlanId unchangedclear only transient trackingforbid createRoom()on Save:if coverage == insufficient:go PendingRescanelse:go DraftSavedon NewSpace:require explicitConfirmif merge == false:go NewRootelse:go Relocalizing
The purpose is to make “retry must not create a room” a checkable rule. In an actual implementation, map these constraints to existing event names and stored fields rather than inventing a new protocol.
Improve Interaction Without Slowing Down Field Work
Safety should not add so many steps that the workflow becomes impractical on site. Changes should reduce mistakes, not require more explanation.
Use Different Feedback for Partial and Complete Scans
An incomplete scan should show a warning and offer “continue scanning.” Success feedback should appear only after the completion criteria are met.
Do not use the same green checkmark for both “some points were captured” and “this room is ready for delivery.”
Explain Doorway Transitions
When the camera stops or the preview pauses, distinguish between recovery guidance and failure:
- “Keep the phone pointed at a previously scanned wall to restore tracking.”
- “Tracking could not be restored. Your draft is saved. Retry or finish this room.”
Avoid an instruction that tells the user to return to the original room while silently changing the session behind the scenes.
De-Emphasize Disruptive Branches
Place “create a separate space without merging” in a secondary menu or require confirmation. Keep the main workflow focused on:
- Save and scan the next room.
- Continue scanning the current room.
- Finish and view the floor plan.
An accidental tap on a highlighted control must not change the data model.
Separate Delivery and Debug Views
By default, show decision-relevant information: exterior walls, partitions, door openings, room width and depth, and total area.
Wall identifiers, confidence values, and raw trajectories should be available on demand for investigation, not spread across the drawing being shown to a client.
Handle Area Error Separately
Calibration, loop closure, occlusion, and incomplete contours can all contribute to overestimated area in large spaces.
At minimum, the interface should label the measurement as an estimate requiring verification. A visually authoritative presentation must not turn uncertain measurements into a promise.
Review Deliverables Before Changing Code
A useful review should leave at least three concrete artifacts, not just general advice.
A state diagram. Include the stages above and the retry, camera-inactivity, back-navigation, and accidental-new-space paths. For each path, indicate whether the room identifier and floor plan identifier change.
An evidence-based comparison. Map every screen in the captured sequence to a state. Identify incorrect instructions and button actions that violate invariants. This grounds the review in evidence rather than impressions.
A defined change boundary. Fix completion decisions and event behavior before changing copy and layout. If the proposed diagram still allows retry to create a new room, cleaner visuals do not make it ready for implementation.
AI coding tools can accelerate source review and diagram creation. Provide the continuous screen sequence, a description of the observed behavior, and relevant source code. Ask the tool to list states, events, and suspicious branches, and to distinguish code-supported findings from inferences based only on the interface.
A human still needs to verify the call sites. If a tool produces only visual simplification mockups, ask it to trace the data changes in retry, save, and new-space operations.
When tools disagree, use the source code and a reproducible operation as the deciding evidence—not a higher tool tier or a more polished diagram.
Testing and Observability
Regression testing should cover more than the appearance of the final floor plan. At minimum, verify that:
- Extremely small coverage cannot pass completion checks.
- After the camera becomes inactive mid-session, retry preserves the room identifier and allows continued connection to the floor plan.
- An accidental tap on a highlighted button does not create a new root.
- After the user explicitly creates a separate space, the previous draft can still be opened independently.
- The results page does not display all wall identifiers by default, and identifiers remain consistent with geometry when the debug layer is expanded.
Keep business logs limited to state names, whether room identifiers changed, coverage decisions, and failure reasons. Avoid unnecessarily copying imagery of client spaces into those logs.
Scan frames, thumbnails, and result images can use general-purpose object storage, isolated by session. Logs and monitoring can track state transitions and failure rates.
If the system runs on Baidu AI Cloud, plan around those same general categories—object storage, logging, and monitoring—without specifying unverified proprietary interfaces.
For permissions, field data should belong to the current project by default. Share result images and necessary dimensions with clients, not raw trajectories or debug identifiers.
Conclusion
Poor multi-room scanning experiences often occur because success indicators conceal violations of state-machine invariants.
Incomplete scans marked successful, misleading guidance after camera inactivity, accidental creation of separate spaces, and floor plans obscured by wall labels may look like four UI problems. Their underlying cause is a failure to separate completion decisions, session identity, and presentation models.
Before redesigning complex screens, compare a continuous capture from a real device with the source code. Map the transitions, enforce rules such as “retry must not disconnect rooms,” and only then revise copy and layout.
Validate measurement accuracy, visual clarity, and state correctness separately. The first two determine the quality and readability of the drawing. The third determines whether multiple rooms remain connected as a floor plan that can support a meaningful client discussion.
