ADR-00046 — Tabs and Dual-Channel Status Strategy for the Tenant Migration Console
Status: Accepted Date: 2026-10-11 Authors: Engineering Team
Context
ui-admin-application’s Tenant Data Migration feature (MigrationPage.tsx) presents three views — Ingest & Validate, Live Execution Monitor, Historical Audits — and must get right-sized live status for two structurally different kinds of waiting: a short, bounded wait for something to merely start existing (a batch document materializing after upload; a verify pipeline finishing its three steps), and an open-ended wait for a potentially long-running, multi-stage execution to progress. Two implementation questions this raised, both visible directly in the current code:
- Does the feature need a sequential wizard, or can its three views stand alone?
MigrationPage.tsxwiresIngestPage/MonitorPage/HistoryPagebehind MUITabs/Tab, switched freely viactrl.setTab— there is noGetPage/step-index gating anywhere in the controller. - How does the console learn that server-side state changed, for each of these two waits?
pollForBatch/pollForVerification(MigrationController.ts) are short-livedsetTimeoutloops bounded atBATCH_POLL_MAX_ATTEMPTS(40) ×BATCH_POLL_INTERVAL_MS(1500ms).openMonitorStream/openMigrationStreaminstead open a long-lived SSE connection (core/http/sseClient’sopenEventStream) that stays open for the duration of execution, closed explicitly on unmount/tab change via astreamCloserRef.
Decision Drivers (FRs & NFRs)
- SR-030 FR-03, FR-05 — both the post-upload batch-materialization wait and the verify-progress wait are bounded, with a visible timeout error on expiry.
- SR-030 FR-08, FR-09 — live execution monitoring must reflect a four-stage, many-entity-type pipeline’s progress as it happens, not on a fixed poll cadence.
- SR-030 FR-18 — the three top-level views are independently reachable, in any order, with no combined final submit step.
ui-admin-application/CLAUDE.md— “A feature with independent, any-order sections (the user can freely jump between them, no inherent sequence, no final combined submit) stays on Tabs (MUITabs/Tab), not a wizard.”
Decision 1 — Tabs vs. a linear wizard
Option 1 — Linear wizard (Upload → Verify → Execute → Monitor → History, one step at a time)
The feature would gate each view behind completion of the previous one, matching the stock-entry/mobile-app-configure features’ wizard pattern already used elsewhere in this admin app.
Pros:
- Guides a first-time operator step by step, with no way to land on a view that doesn’t yet make sense for the current batch.
- Matches an established, already-documented pattern in this codebase (
StockEntryPage,mobile-app-configure’s 3-step configurator).
Cons:
- The three views don’t actually have a linear dependency on each other at the feature level — Historical Audits is a standing list independent of whatever batch is currently mid-flight on Ingest, and Live Execution Monitor is meaningful for any batch currently executing, including one resumed from History after a page refresh (SR-030 FR-07), not only one that just came from Ingest in the same session.
- A wizard’s “Next” gating would have to special-case re-entry from History (jumping straight to Monitor for a batch whose Ingest step never happened in this session) or from a bookmark/refresh mid-execution — exactly the kind of awkward state a wizard’s linear model fights against, where tabs simply don’t care how the operator arrived.
- Would contradict
ui-admin-application/CLAUDE.md’s own explicit rule (see Decision Drivers) that this exact shape — independent, any-order, no combined submit — belongs on Tabs.
Option 2 — Independent Tabs, no forced order (CHOSEN)
MigrationPage.tsx renders Ingest & Validate, Live Execution Monitor, and Historical Audits as three MUI Tabs, switchable at any time via ctrl.setTab, each reading whatever state is relevant to it off the shared controller.
Pros:
- Matches how the feature is actually used: an operator checks History while a different batch is mid-verify on Ingest, or jumps straight to Monitor for a batch resumed via
runExecutefrom History without ever visiting Ingest in the current session. - No artificial gating logic to maintain — a tab is just a tab, not a step with prerequisites to validate.
- Directly follows
ui-admin-application/CLAUDE.md’s own stated rule for this exact shape of feature, rather than defaulting to the wizard pattern used by this admin app’s other two documented features.
Cons:
- Nothing stops an operator from switching to Monitor while no batch is executing (handled with an explicit empty state in
MonitorPage.tsx, not a disabled tab) — slightly more per-view empty-state handling than a wizard would need, where an unreachable step simply couldn’t be visited.
Decision 2 — Bounded polling for “wait until it exists” vs. SSE for “watch it progress”
Option 1 — One mechanism for every wait (all polling, or all SSE)
Either poll on a fixed interval for every kind of status wait including live execution, or open an SSE connection even for the short post-upload and verify waits.
Pros (all-polling): one mechanism to reason about everywhere; no persistent connection management at all. Pros (all-SSE): one mechanism to reason about everywhere; no poll-interval tuning anywhere.
Cons (all-polling): a four-stage, many-entity-type execution that can run for minutes would either poll too slowly (stale progress) or too frequently (needless load) to feel “live” — and polling has no natural way to push a mid-stream update the instant a stage’s wave barrier clears, which is exactly the moment an operator watching Monitor cares about.
Cons (all-SSE): the post-upload and verify waits are both short, bounded, and end the moment a known terminal condition is reached (the batch document appears; verify reaches VERIFIED/VERIFICATION_FAILED) — opening and tearing down a persistent connection for a wait that resolves in well under a minute, every single upload, is unnecessary connection churn for no benefit over a handful of polls.
Option 2 — Bounded polling for upload/verify waits, SSE for live execution monitoring (CHOSEN)
pollForBatch/pollForVerification poll every 1.5s up to 40 attempts for the two short, self-terminating waits (FR-03, FR-05); openMigrationStream opens one SSE connection, scoped to the executing batch, for the open-ended Live Execution Monitor wait (FR-08), torn down explicitly on unmount/tab change.
Pros:
- Each wait gets the mechanism suited to its actual shape: a short wait with a known, boundable number of possible checks uses the simplest possible tool (a timed retry loop); a long, multi-stage, push-worthy wait uses a persistent channel that reflects server-side progress the instant it happens, without the console guessing a poll interval that’s either too chatty or too stale for a potentially minutes-long execution.
- The bounded polls have a built-in, visible failure mode for free (FR-03, FR-05’s timeout errors) — no separate “has this connection gone stale” detection logic needed for what are, by design, short-lived waits.
- The SSE stream’s lifecycle is tied to exactly one thing — one executing batch — making the
streamCloserRefguard (SR-030 FR-08) a small, single-purpose piece of state rather than a generalized multi-wait connection manager.
Cons:
- Two different asynchronous-status mechanisms exist in the same feature, which a contributor must learn are deliberately different rather than an inconsistency to “fix” by unifying them.
- If a third kind of wait is ever added to this feature, the choice between the two existing mechanisms isn’t automatic — it has to be reasoned about the same way this ADR reasons about the first two, using the same test: is the wait short-lived and self-terminating (poll), or open-ended and worth pushing incremental progress for (SSE)?
Final Decision
Keep the migration console’s three views as independent, freely-switchable Tabs (Decision 1, Option 2) — the feature has no genuine linear dependency between Ingest, Monitor, and History, and ui-admin-application/CLAUDE.md’s own rule for this shape of feature already settles it. Use bounded polling for the two short, self-terminating waits (post-upload batch materialization, verify-step progress) and a persistent SSE connection for the one open-ended, push-worthy wait (live execution monitoring) — matching each wait’s actual shape rather than forcing one mechanism to serve both (Decision 2, Option 2). A future wait added to this feature should be classified the same way before picking a mechanism, not defaulted to whichever of the two already exists in the codebase.