Frontend Runtime Flow
This document describes how the web app boots and where runtime responsibilities live.
Boot Sequence
Primary entrypoint:
apps/calendar-web/src/index.tsx
Boot order:
- initialize local storage through
initializeDatabaseWithErrorHandling() - initialize session tracking with
sessionInit() - render
<App /> - show a toast if local database initialization failed
This order matters because storage should be ready before listeners and repositories perform local operations.
App Provider Tree
apps/calendar-web/src/components/App/App.tsx renders:
- keyboard and movement event setup hooks
- optional providers
- required providers
- router provider
The route tree lazily loads feature views.
Router Flow
Files:
apps/calendar-web/src/routers/index.tsxapps/calendar-web/src/routers/loaders.ts
Important behavior:
- the root route loads
RootView - the day route redirects to today's date when needed
loadAuthenticated()checks whether a session exists- route loaders use shared date parsing from
core
Root View Responsibilities
apps/calendar-web/src/views/Root.tsx:
- blocks mobile-OS devices with
MobileGate(isMobileOSuser-agent check; narrow desktop windows get the responsive layout instead) - wraps authenticated layout with
UserProvider - wires SSE listeners through
SSEProvider
This is the shell for the main desktop app experience.
Welcome, Showcase, And First-Event Handoff
Files:
apps/calendar-web/src/components/RootShell/RootShell.tsxapps/calendar-web/src/components/RootShell/onboarding-surface.tsapps/calendar-web/src/components/WelcomeModal/WelcomeModal.tsxapps/calendar-web/src/components/WelcomeModal/WelcomeGuideModal.tsxapps/calendar-web/src/components/ShortcutShowcase/apps/calendar-web/src/components/FirstEventPrompt/apps/calendar-web/src/components/ConnectCalendarPrompt/ConnectCalendarPromptGate.tsx
RootShell builds onboarding flags and mounts at most one onboarding card or
modal at a time via selectActiveSurface (billing gate and checkout
celebration win first; then welcome, Block Party, welcome guide replay,
connect-calendar prompt, first-event prompt, and palette PointerHint). Global
navigation and calendar-shell shortcuts stay mounted separately. Calendar
onboarding overlays are skipped on /life and on mobile OSes (they would paint
over MobileGate, so a phone user sees the gate first instead of a walkthrough
they cannot use).
Welcome → signup → first-event contract:
- unauthenticated users who have not seen welcome get
WelcomeModal - welcome is four screens in one dialog for local explorers (three through
the account choice, then essential shortcuts), each with one focused primary
button so Enter (or a click) is always the obvious next thing: Get
started for free (headline, tagline, one-sentence pitch) → Next over
the five FAQ rows (digits
1–5toggle them, only on this screen) → the auth choices.Log in(i) and a three-dot step indicator sit on every screen. Back (Esc) sits left of Log in from the second screen on. Escape, the backdrop and Back step back one screen and are a no-op on the first, so a stray Escape never drops a first-timer into the practice game - the welcome overlay works with the mouse: a landing page should behave like a normal site, and keyboard-only starts once the visitor enters the calendar
- the last screen is titled Let's get started with the subtitle
Connect a calendar or start fresh. Its CTA order is Continue with Google
(
G, when Google is available), Sign up with email (U), then On this device only (S), all the same full-width height. Explore is a quieter secondary pill so signup stays the stronger choice. Social and legal links (6–0) sit below. Google leads because the scopes Compass requests include the calendar, so that one round trip signs the user up and connects it, the moment the product starts being worth keeping - On this device only opens a keyboard-shortcuts screen, then continues to the calendar without starting Block Party until the visitor opts in
- Log in opens the auth modal and leaves the showcase flags alone, so a returning user is not handed the practice or the first-event prompt
- Practice the shortcuts in the welcome footer (or
?play=1, or the command palette replay) is the opt-in entry to Block Party - signing up (either route) does not start or defer the showcase
- hosted signup with billing enforced continues to the Start your N-day free
trial auth step (
StartTrialStep,?auth=trial,N = billing.trialLengthDays):TrialStartAskshows charge-date copy (No charge until …), S and Mod+Enter open embedded Checkout (plain Enter does not), and Checkout usestrial_period_daysfrom config. While that step is open,RootShellsuppresses the billing gate and calendar onboarding surfaces. Closing without paying returns to read-onlyawaiting_checkoutand Finish starting your trial. After Checkout completes, Compass polls billing status, shows the checkout celebration, and runs anonymous IndexedDB event migration once (complete-checkout-session.ts), not at signup time - the Shortcut Showcase is Block Party: a practice-only game whose state
never reaches real calendar storage. A run clears a fixed queue of
scheduling tasks (create, typed quick-times, nudge, edge resize, delete,
undo, plus discovery beats for the
?legend,Fflash jump keys, Mod-hold page jump, andMod+Kpalette, all simulated inside the arena) against a ghost target slot, with scoring and streaks; task keycaps derive from the application's keymap and the exact next key pulses on the task card. The queue is authored one task per primitive with one press per key and never the same key twice in a row. The first run is untimed; the end screen offers a timed rematch, and a timed run whose clock expires keeps going with the score frozen at the buzzer. Esc skips the current task (leaving mid-run is the two-click Leave button), anonymous players get signup as the end screen's primary CTA, and graduation hands off toFirstEventPrompt. A reload mid-run re-offers a fresh run from the one-screen how-to card, and?play=1on any URL is a shareable deep link straight into the game (consumed, then stripped) FirstEventPromptis a non-blocking real-calendar card. It stays hidden while the auth modal is open and retires after the first genuine create. Users who finished or dismissed the retired onboarding checklist are read as already done via a legacy storage key, so they never see it- command palette can reopen practice (“Play Block Party”) or the welcome guide (“Show welcome guide”)
- users who already finished or skipped the retired guided tour are treated as having seen the showcase so it does not ambush them
Palette and pointer teaching (from RootShell):
- after a palette row with a shortcut runs,
PointerHintshows Next time, press … unless the user turned keyboard tips off - pointer intent on the grid and chrome click teach use the same pill and
tips-mutedflag; see Contextual Pointer Guidance
See Onboarding and Shortcuts for acceptance coverage and Feature File Map for file pointers.
Session Runtime
File:
apps/calendar-web/src/auth/compass/session/SessionProvider.tsx
Responsibilities:
- initialize SuperTokens recipes
- track auth state in a
BehaviorSubject - mark users as having authenticated
- open or close the SSE stream on session changes
- expose a React context for auth status
Important detail:
Once a user has ever authenticated, the app records that fact in local auth-state storage so repository selection can prefer remote data later.
When a user re-authenticates with Google, auth-state utilities also clear any in-memory "Google revoked" flag so normal remote sync can resume.
Google Authorization Redirect
Google sign-in/up and Google Calendar connect/reconnect leave Compass through a full-page Google redirect and return through /auth/google/callback.
Before redirecting, the web app stores a short-lived authorization intent in sessionStorage keyed by OAuth state. The callback validates that state, finishes the saved intent, removes it, and returns the user to the original same-origin path or the default calendar route (/week).
The old blocking overlay is not used for Google authorization.
User Bootstrap
File:
apps/calendar-web/src/auth/compass/user/context/UserProvider.tsx
Responsibilities:
- fetch the user profile only for users who have authenticated before
- avoid blocking unauthenticated users
- show a session-expired toast on auth failures
- identify the user in PostHog when enabled
Analytics Capture Filters
Files:
apps/calendar-web/src/auth/posthog/posthog.bootstrap.tsapps/calendar-web/src/auth/posthog/posthog-exception-filter.util.tsapps/calendar-web/src/auth/posthog/posthog-dead-click-filter.util.tsapps/calendar-web/src/auth/posthog/posthog-web-vitals-filter.util.tsapps/calendar-web/src/auth/posthog/posthog-booking-filter.util.tspackages/core/src/booking/booking-telemetry.ts
PostHog's before_send runs four filters, in order:
- unactionable exception signatures (SuperTokens/browser network blips, CefSharp scanner noise, opaque "Script error.", ResizeObserver loop warnings)
- dead clicks posthog's own mutation clock mis-scored (a click whose own
re-render posthog records as happening before it) — the mechanism and the
50ms window are documented in
posthog-dead-click-filter.util.tsitself - web vitals whose value is zero for LCP/FCP/INP (a missing measurement, not a perfect score)
- booking telemetry redaction: public
/meetand/bookURLs are rewritten to route categories, capability tokens and reservation ids are stripped, and replay/autocapture/exceptions on those pages are dropped because the DOM and error messages cannot be rewritten onto the allowlist
Calendar grid clicks are intentional keyboard-teaching gestures, not failed
UI. Timed and all-day grids carry ph-no-rageclick, capture_dead_clicks
ignores the same selectors, and posthog-grid-gesture-filter.util.ts drops
any $dead_click, $dead_swipe, or $rageclick whose element chain still
lands on the grid. Rageclicks on public booking pages are still dropped by
the booking filter.
local_mode_selected fires when an anonymous visitor chooses the sidebar
On this device only row (local IndexedDB mode). It must not be confused with
signup_started, which is reserved for explicit login or trial CTAs (OAuth,
email sign-up modal, command palette, and similar).
OAuth signup drop-off uses four named stages shared by Google, Microsoft, and
Apple (packages/core/src/analytics/oauth-signup.events.ts):
oauth_redirect_started(provider,intent) when the browser leaves for the provider consent screen.oauth_callback_received(provider) on the client when the provider redirect lands, plus serveroauth_callback(environment,provider,flow,outcome, optionalreason) from the backend routeGET /auth/:provider/callback. The SPA relays the query string withX-Compass-OAuth-Telemetry: 1so the server event is captured even when JavaScript fails later. OAuthstatecarries the PostHog anon distinct id and signup vs login flow when available.- Server
oauth_callbackfailures cover consent denial (access_denied), invalid state, missing code, token exchange failures, and user creation failures. Clientoauth_failedand legacysignup_failedstill fire for existing insights. signup_completedorlogin_completed(method) after a successful SuperTokens exchange (unchanged).
calendar_connected has two sources, distinguished by a source property:
signup_google from GoogleAuthCallback (a new user whose Google grant
included the calendar scopes) and connect_redirect from
apps/calendar-web/src/auth/providers/connect-status.util.ts (the sync service's
add-account round trip).
Only the second used to fire, so the activation metric missed the path most new
users actually take.