
Onboarding looks like the easy part of a building-management product: a new account opens an eight-step wizard, describes a building, adds its units and names a manager. In Hamsayeh's commit history it is the heaviest feature I can find by name. 74 commit messages mention onboarding, against 39 for charge, 37 for ticket and 32 for payment, and 60 of the 74 are from May.
The title overstates it a little. May had 470 commits, and its first half went to the TypeScript work and the backend split that parts 4 and 6 cover. The wizard's week was 18 to 24 May, when 58 of 138 commits touched its folder. Hamsayeh is still in development and runs with Docker Compose and demo data, so everything below comes from commits, one test report and the code as it stands today. The second half of this post moves to a related problem: what a small building is supposed to see once it has been set up.
A waiting page that moved twice
The first version treated whoever registered as a future manager and sent them into building creation. Part 2 told the access side of that assumption. On the wizard side, a commit on 19 May titled "replace auto-manager assumption with waiting page" sent every new account without an invite token to /onboarding/waiting, where a button reading "I am the building manager" led into the wizard. The same commit removed the roleHint: 'builder' distinction at registration, so every account started as a resident.
Another commit that day reversed the order, under the subject "waiting page comes after wizard, not before registration". Its message spells out the flow that stayed:
Register -> Wizard -> (if resident) Waiting page
The wizard now runs first and asks for the role inside it. A resident lands on the waiting page once the building exists, and a board member goes on to the management portal. The commits record the two flows and give no reason for the change between them.
The draft that could not stay in the browser
The wizard creates a real Building row at step 1. From then on, a half-finished building has to survive a reload and a logout. The draft began in browser storage, and three days of commits show it failing in different ways:
- 18 May: the
sessionStoragedraft gained the user id in its key, "to prevent cross-user contamination". Until then, two accounts in one browser shared a draft. - 18 May, same commit: the call that updated a draft was removed because it returned 403. The creator had no manager access in the middle of onboarding, so a draft could be created once and never updated.
- 19 May: save-and-exit stored
buildingId: null, so the next login found no draft to resume. - 20 May: the check for whether an account still needed onboarding was
buildingAccess.length === 0, a heuristic that, in the commit's words, "broke as soon as step 1 created the building".
The 19 May bug is small enough to show. This is simplified from the commit's description:
const draftIdRef = useRef<string | null>(null)
useEffect(() => {
draftIdRef.current = draftBuildingId // runs after render
}, [draftBuildingId])
// onStepChange, in the same tick as setDraftBuildingId(created.id):
saveDraft({ step, buildingId: draftIdRef.current }) // still null
The ref lagged one render behind the state, so the draft was written without its building and hasOnboardingDraft() returned false on the next login. The fix was a wrapper that sets the ref and the state in one call.
The commits of 20 May stopped patching the browser copy and moved the state. Building gained three fields:
public bool IsOnboardingComplete { get; private set; } = false;
public int OnboardingStep { get; private set; } = 0;
public OnboardingParticipantRole OnboardingParticipantRole { get; private set; }
= OnboardingParticipantRole.None; // None, BoardMember, Resident
A PUT now records progress on each step change, and GET /buildings/onboarding/active replaced the local draft on resume. CreateBuildingHandler answers 409 when the account already has an unfinished building, and the front end reads whether onboarding is required from a value the server computes. A day later the old draft module was deleted, since nothing imported it any more.
My reading, which no commit states: once a wizard creates a real entity at step 1, "draft" is a server concept, and a front-end rule that infers the wizard's state from other data will be wrong the first time that data changes for a different reason. Moving the state did not make resume free. Restoring board members, the resident role and selected units still took their own commits that same day.
One default and a swallowed error
On 24 May a manual pass through the wizard on a local stack produced a test report listing five bugs and two API issues. The worst one shows how two small choices can combine.
On 19 May the role step had changed to independent toggles, and isBoardMember started as useState(true). The manager card therefore appeared already selected, and the first click on it cleared the selection. The wizard then followed the resident path and the server refused the completion call with a 409. The front end ignored that refusal, so the flow carried on to the waiting page, whose button for entering the management panel led back to the wizard. The report rates the default as critical and the swallowed error as medium, and the loop stopped once those two were fixed. Simplified, the error handling changed like this:
// before
try {
await completeOnboardingBuilding(building.id)
} catch {
/* non-critical */
}
// after
try {
await completeOnboardingBuilding(building.id)
} catch (err) {
setError(getApiErrorMessage(err, fallbackMessage, { prefer: 'error' }))
setLoading(false)
return
}
After the fixes the report records 16 scenarios passing. That is one local manual run, and the report lists what it could not reach: resident-only redirects, accounts with several buildings, system admins, invite links and concurrency, each for lack of seed data or tooling. One API issue also stayed open. A full run sends four to six progress PUT calls, and the debounce the report suggests was left for later.
The pattern behind the swallowed error survived too. useBuildingOnboardingController.ts still has four catch blocks marked non-critical, three around resident sync and one around unit creation, so a failed assignment there disappears the way the completion error used to. The wizard also ended large: the controller is 1,015 lines, its view file is 3,204, and the controller's Vitest file has 17 test cases.
One product for eight units and for two hundred
The wizard settles who you are in a building. Looking simple also depends on what that building shows afterwards, and a block of eight units should not carry the menus of a complex with two hundred.
The model arrived in steps. On 19 April Building got eight feature flags, all false by default: facilities, reservation, paid amenities, staff, board, governance, marketplace and large complex. Scenarios appeared on top of them the same day. Today five scenario keys resolve from the flags, each with a list of enabled modules, and a sixth, simple, was merged into amenity when their module lists turned out to be identical. On 28 May a simple or large edition, derived from the scenario, began branching the manager dashboard, the sidebar and core screens between a calm card layout and a dense table.
In June a document audited what the model did on screen. For an amenity building, enabledModules excluded reservations, tickets and governance, yet the desktop sidebar hid the marketplace and nothing else. The resident bottom navigation applied no scenario filter, and the mobile dashboard's quick actions were a fixed array. Three scenario-aware menu functions did filter correctly, but their only callers were tests, so the suite stayed green around code no screen used. They were deleted. The audit also found complete features with no way in, such as the do-not-disturb settings: a finished card with its state and API calls, behind a 'dnd' view that no route renders.
Some of that has moved since, and the audit document has aged with it:
| Surface | June audit | Code today |
|---|---|---|
| Manager desktop sidebar | Hid the marketplace only | Filters reservations, governance and marketplace by module |
| Resident bottom tabs | No scenario filter | No scenario filter |
| Mobile dashboard quick actions | Fixed array | Fixed array of four |
| Do-not-disturb settings | No route | No route |
amenity modules | No tickets | Includes tickets |
The bottom tabs show the gap most plainly, because the hook takes no building features at all:
export function useResidentTabs(): ResidentTab[] {
return useMemo(
() =>
buildingPortalRouteModel.routes
.filter((route) => Boolean(route.bottomNav))
.sort((a, b) => (a.bottomNav?.order ?? 0) - (b.bottomNav?.order ?? 0))
.map(/* value, label, icon, path */),
[],
)
}
The route definitions do declare a moduleKey on each tab, 'tickets' for the requests tab, and the route model carries it along, but nothing filters on it. A reservable building has no tickets module, and as far as the code shows it still gets the requests tab and the "report a problem" quick action. This limit is still open: the scenario model and its tests agree with each other, and on a phone the screens only partly follow them.
Two of the commits from that wizard week also carried backend fixes, for a foreign key failure and a 500 on CreateUnit. Both trace back to a split made a few days earlier, and part 4 starts there.
This note is also available in Persian: read the Persian version.
