Repository navigation
perf: lazy-load firebase auth and label dictionaries, memoize i18n context - #6
Merged
Merged
Conversation
…ntext - load firebase/app and firebase/auth with dynamic import only when real Firebase auth is configured - keep English bundled and load es/fr/de/it dictionaries on demand - memoize the I18nProvider context value and hoist the no-op setLanguage - use useVisibilityPolling for the AI diagnostics generator status refresh - make the service console metrics test independent of the runtime locale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Frontend performance, phase 2 (findings E1-E3 plus the diagnostics polling item from the runtime review).
firebase/appandfirebase/authare loaded with dynamicimport()only whenVITE_AUTH_MODE=firebaseand the config is complete.BackofficeAuth.modestays synchronous (derived from config), soLoginGateis unchanged. In dev auth mode the SDK is never downloaded. A failed chunk load can be retried; unsubscribing before the SDK arrives cancels the subscription.labels.tskeeps onlyen(the language hard-coded inApp.tsx, also the fallback).es,fr,de,itmoved toi18n/dictionaries/*and load on demand throughloadDictionary;I18nProvidershows English until the chunk arrives and caches loaded dictionaries. Every language inUiLanguagestays reachable through the provider; nothing was removed. The running app cannot switch language today (setLanguageis a no-op), so in production only English is ever requested.useMemofor the value, hoisted stablesetLanguage.setIntervalis replaced byuseVisibilityPolling(pauses while the tab is hidden, refreshes on return, no overlapping runs).Bundle size (
vite build, Vite 6.4.5)index-*.jsInitial JS in dev auth mode: gzip 119.45 kB -> 66.30 kB (-53 kB, -45 %). Entry
index.htmlhas no modulepreload for the new chunks. In firebase mode the SDK now loads in a second request after the entry instead of inside it.Behaviour notes
fr/de/itare partial and none is reachable in the app today.Tests
auth-lazy-firebase.test.ts: dev mode never loads the SDK, firebase mode loads it on first use, session forwarding, unsubscribe, dispose-before-load.i18n.smoke.test.tsx: stable context value across re-renders, async load of a language, English fallback, sync English.ai-diagnostics-panel.integration.test.tsx: 10 s refresh, paused while hidden, immediate refresh on return.test/setup.tspreloads the Spanish dictionary so the existing Spanish integration tests stay synchronous.service-console-panel.integration("summarizes AI telemetry metrics"): it also fails on pristinemainunder Node 24 on a machine with an es-ES locale, because the panel formats with the runtime locale (95,2%) while the test hard-coded95.2%. Test bug, fixed here by building the expectation with the sametoLocaleString.Local results:
npm ci,tsc -b,vite buildOK; vitest 19 files / 154 tests pass (144 before; 143 passed + that 1 locale failure on main); coverage thresholds pass (lines 93.3, branches 85.4). There is no lint script in this package. The Playwright e2e could not run here (installed Chromium does not match the Playwright version, and downloading browsers was not done).Overlaps with open PRs
None in source. #4 touches Dockerfile/CI files, #5 touches docs/PR template, #3 touches
service-overview-panel.integration.test.tsxand.env.example(this PR does not edit those).