Frontend bootstrap and startup states
The frontend bootstrap turns a hidden Tauri webview into a usable Rowel screen. It applies the first theme and language, checks whether the install needs setup or unlock, prepares the React shell, and hands the visible window from the startup splash to the active flow. The wider journey is described in Application shell and user journeys, while the resulting workspace is covered in Main workspace interface.
Startup contract
Browser entrypoint
The browser entrypoint is src/main.tsx. It loads the base visual theme, blocks reload shortcuts that would discard an unlocked session, starts the boot sequence, and enables the development-only end-to-end bridge. Its job is to start the application without deciding which user flow should appear; that decision belongs to the boot and app shell layers.
The entrypoint also keeps the webview from behaving like a normal browser page. A reload key does not refresh the document because refresh would replace the current session with the lock screen. This preserves the desktop-app session model while still allowing the same frontend to run in a plain browser or test environment.
References: src/main.tsx• L1-29
Native window preparation
The native host creates the main window hidden and injects only the values needed for the first painted frame: the resolved locale and saved visual settings. The frontend then tells the host that the splash is ready. The host reveals the window at that point or after a short fallback delay, so a slow or broken bundle shows a resting branded screen instead of a blank window.
Platform preparation also keeps the shell aligned with the device. The page uses full-screen viewport rules and safe-area values for mobile cutouts, while compile-time platform values select mobile behavior and shortcut labels. These choices shape the first screen without making the frontend guess from a user-agent string.
References: src-tauri/…/window.rs• L9-31 src-tauri/…/window.rs• L97-113 src-tauri/…/app.rs• L132-172 index.html• L1-45 src/…/platform.ts• L1-19
Boot sequence
The boot sequence runs the first-frame work in parallel where possible. It uses the native payload for immediate visual state, loads the needed language catalogue, probes the application status, and renders React once the shell knows which flow should own the screen.
The sequence below shows the main hand-offs. The splash is not a readiness gate: it covers the window while the flow becomes ready, but it does not delay the native reveal or wait for optional work.
flowchart TD
A[Static HTML paints theme ground and splash] --> B[main.tsx starts boot]
B --> C[Apply injected theme and accent]
B --> D[Start splash and request window reveal]
B --> E[Load locale catalogue]
B --> F[Probe app status]
E --> G[Choose resolved locale]
F --> H{Vault initialized?}
H -->|No| I[Setup flow]
H -->|Yes| J[Lock flow]
F -->|Probe fails| J
G --> K[Render React shell]
I --> K
J --> K
K --> L[React commit finishes splash handoff]
First-frame preparation
The first frame has two layers. index.html supplies a literal background and static mascot before JavaScript runs. The native host supplies the saved theme and locale before the module bundle starts, and boot applies them to the document and preference state as soon as it runs. This prevents a white or wrong-language flash while the rest of startup is still in flight.
The locale catalogue is ready before the first React render. The default English catalogue is available immediately, and other supported catalogues load for the locale chosen by the host or by the application status response. The document language follows the active catalogue so the interface and assistive technology use the same language.
References: index.html• L19-45 src-tauri/…/app.rs• L132-164 src/boot.ts• L31-50 src/boot.ts• L73-102 src/…/index.ts• L36-89
Application status probe
The application status probe is the startup answer that tells the shell whether a vault exists and which platform features are available. It also carries the settings, locale, workspace context, sync snapshot, and biometric state needed by the first screen. The frontend stores this answer centrally so later screens do not repeat separate startup checks.
The boot path waits for the language and probe together, then renders even when the probe fails. A failed probe leaves the app on its safe default lock flow. The mounted shell can ask again, which gives a fresh install a second chance to reach setup without leaving the document unrendered.
References: src/…/app.ts• L51-100 src/boot.ts• L88-111 src/App.tsx• L52-67 src/…/app.ts• L51-63 src/…/app.ts• L181-196
Startup states
Setup flow
The setup flow is the first-run state for an install with no vault to unlock. Boot selects it before the first React render when the status probe reports an uninitialized install. The flow can create local data, connect to supported remote storage, restore an existing vault, or continue through the first-run security choices before entering the main workspace.
The setup screen is lazy-loaded. The splash remains in place until that screen has committed, so a fresh install does not briefly show the lock screen while the setup code is still loading. If the setup chunk or probe fails, the shell still has a rendered fallback path and does not wait forever for a successful backend answer.
References: src/boot.ts• L98-111 src/App.tsx• L11-18 src/App.tsx• L27-41 src/…/boot.test.ts• L154-173 src/…/start.test.tsx• L70-122
Lock flow
The lock flow is the normal startup state when a vault is present. The shell chooses a wide or compact lock screen from the current layout, then the user unlocks the active workspace with the available passphrase or biometric path. The lock screen can display the last known gate while a later status refresh completes, so a probe delay does not remove the basic access path.
Once unlock succeeds, the session enters the main flow and the workspace interface takes over. The startup page should therefore explain the handoff into Main workspace interface, not duplicate its list, detail, or navigation behavior.
References: src/…/app.ts• L116-138 src/App.tsx• L27-41 src/…/index.tsx• L16-48 src/…/LockScreen.tsx• L19-87
Main flow
The main flow is the authenticated state that follows unlock. It receives the unlocked entries and opens the vault workspace, while the shell continues to own app-wide events, update notices, file-open routing, and future lock transitions. The main workspace is kept out of the initial launch bundle and is prefetched after the lock screen has had time to settle.
This split keeps startup focused on reaching a safe access screen. Details about navigation, search, scopes, and entry actions belong in Main workspace interface, while the stores that hold the flow and session state belong in Client state and preferences.
References: src/App.tsx• L16-25 src/App.tsx• L43-94 src/…/app.ts• L264-279
Splash handoff
Static splash overlay
The splash is static HTML beside the React root, so it is visible from the first document frame while React mounts underneath it. The frontend starts its motion after the bundle is live, and the native host reveals the hidden window on the same startup turn. This makes the initial reveal a deliberate transition rather than a race between page load and window display.
The splash mirrors the lock screen's mascot position and background treatment. It can therefore cover a partially loaded flow without exposing a layout jump. Reduced-motion users receive the resting state without animation, and a removal timeout prevents an overlay from remaining in the document if no transition event arrives.
References: index.html• L46-67 index.html• L165-215 src/…/splash.ts• L1-28
React handoff
React ends the splash only after the selected flow has committed inside the suspense boundary. A lazy flow with no committed content keeps the splash visible; once the flow exists, the overlay fades and removes itself. This ordering is important for setup because the setup screen is loaded on demand, while the lock screen is the normal immediate fallback.
The handoff does not wait for optional startup work such as legacy preference migration or the delayed update check. Those tasks run after the first commit so they cannot make the interface feel unavailable. Preference ownership and later persistence are described in Client state and preferences.
References: src/App.tsx• L43-49 src/App.tsx• L84-94 src/boot.ts• L103-115 src/…/splash.ts• L19-28 src/…/boot.test.ts• L115-129
Platform launch inputs
Locale and visual settings
The host resolves the preferred locale and reads the saved visual settings before the webview runs. The frontend treats that payload as an early hint for the first frame, then accepts the full application status as the normal source for current state. This separation keeps the first paint fast without freezing values that may change during the session.
Theme and accent changes apply to the document root, while language changes update the document language and the preference state. The boot path also carries forward supported legacy local preferences after the first commit, so migration does not block startup or replace the first visible flow.
References: src/boot.ts• L36-71 src/boot.ts• L73-81 src/…/prefs.ts• L21-29 src/…/prefs.ts• L93-105 src/…/prefs.ts• L181-210
Opened-file handoff
A backup file opened by the operating system can arrive before the React event listener exists. The native side parks that path for one handoff, and the app shell collects it after subscribing to events. A locked app keeps the file pending until unlock; a fresh install sends it to the restore step; an unlocked app routes it to import.
This launch input is separate from the startup flow choice. It does not force the app into the workspace or bypass the lock. It only waits for the first screen that can safely use the file.
References: src/App.tsx• L52-81 src/…/app.ts• L111-117 src/…/app.ts• L93-99 src/…/app.ts• L264-299 src-tauri/…/app.rs• L175-180
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the prepaint theme in index.html, the injected boot payload, and the document theme application aligned. A mismatch can show as a flash before React renders.
- Keep the
AppStatuscontract aligned with the boot route and the central app store. A field that is present in the probe but not adopted can make the first screen disagree with later refreshes. - Keep the native reveal path and the splash start path paired. Changing either timing can expose a blank window or reveal the window before the branded overlay is ready.
- Keep the suspense handoff inside the selected flow boundary. Moving it outside can fade the splash before a lazy setup or workspace screen has committed.
- Keep early file collection after event subscription. Otherwise a file opened during launch can be missed or handled twice.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The application status probe rejects | The app has no current status and must not leave the root blank | Render the default lock flow and let App request the status again |
| The install reports no initialized vault but the setup chunk is still loading | The user could see a lock screen or an empty suspense frame before setup | Route to setup before the first render and keep the splash until the setup flow commits |
| The frontend never calls the native ready command | The hidden window stays hidden until the native fallback timer | The native host reveals the window after the fallback interval |
| The splash has no transition event | The overlay can cover the committed React tree | Remove it on transition end or by the bounded cleanup timer |
| A launch file is read before event subscription | A backup path can be lost before a screen claims it | Store it natively and consume it once after the shell subscribes |
| The injected locale or settings payload is malformed | The first frame could use invalid state or fail before boot | Validate the payload field by field and fall back to normal startup values |
Key files
| File | Why to read it |
|---|---|
| index.html | Defines the first painted theme, static splash, viewport behavior, and the DOM nodes used by the frontend root. |
| src/main.tsx | Shows the browser entrypoint and the small set of actions that start a session. |
| src/boot.ts | Defines the ordered and parallel parts of application startup. |
| src/App.tsx | Connects app flow state to setup, lock, main, event subscription, file handoff, prefetch, and splash completion. |
| src/…/splash.ts | Defines when the splash starts and how it is handed off and removed. |
| src/…/app.ts | Describes the status and readiness contract used between the frontend and native host. |
| src/…/app.ts | Holds the flow state and the app-level transitions used after boot. |
| src/…/index.ts | Defines supported startup locales and the catalogue loading behavior. |
| src-tauri/…/window.rs | Explains hidden-window creation, native reveal fallback, safe-area preparation, and launch-time window behavior. |
| src-tauri/…/app.rs | Shows the native boot payload and the commands that complete frontend startup. |
| src/…/boot.test.ts | States the startup guarantees for first-frame state, failed probes, splash timing, and fresh-install routing. |