Skip to content

perf(i18n): lazy-load renderer locales#2003

Merged
zhangmo8 merged 3 commits into
devfrom
perf/settings-locale-lazy-loading
Jul 20, 2026
Merged

perf(i18n): lazy-load renderer locales#2003
zhangmo8 merged 3 commits into
devfrom
perf/settings-locale-lazy-loading

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace the eager 20-locale message aggregate with an explicit dynamic import registry and cached locale loader
  • bootstrap the main, Settings, and floating renderers with only the resolved locale plus the en-US fallback before mount
  • register messages before publishing runtime locale changes, with revision guards for event/action races and failure fallback
  • remove the redundant Settings locale IPC watcher and preserve RTL direction updates
  • include provider, ACP registry, and icon artifacts refreshed by the required production build

Startup Flow

BEFORE

renderer entry -> static locale aggregate -> parse all 20 locales -> createI18n -> mount

AFTER

renderer entry -> resolved language state -> load en-US + active locale -> createI18n -> mount
language change -> load chunk -> register messages -> publish locale/direction

Bundle Result

  • Settings synchronous JavaScript: 4.25 MB -> 917,504 B
  • Settings synchronous gzip: about 1.33 MB -> 300,498 B
  • all 20 locale payloads are separate async chunks (157-264 KB each)
  • the synchronous bootstrap chunk contains loader/runtime code but no translation body

Validation

  • pnpm run format
  • pnpm run i18n
  • pnpm run lint
  • pnpm run build (includes node/web typecheck)
  • locale/store tests: 9/9 passed
  • isolated MemorySettings suite: 11/11 passed
  • full renderer suite: 1333 passed, 16 failed. Fifteen failures come from the unchanged origin/dev App.startup.test.ts mock returning undefined for the Promise-based initAppStores; the remaining failure was a 10s full-suite concurrency timeout and passes in isolation.

Summary by CodeRabbit

  • New Features

    • Localized content now loads on demand, improving initial renderer startup performance.
    • Language switching is more reliable, including support for rapid changes and right-to-left languages.
    • Added fallback behavior when language settings or translation resources cannot be loaded.
    • Updated the available model catalog, capabilities, limits, pricing, and agent integrations.
  • Bug Fixes

    • Prevented outdated language requests from overwriting newer selections.
    • Preserved the last active language when a new translation resource fails to load.

zhangmo8 added 2 commits July 20, 2026 17:08
Load only the active locale and English fallback before mounting renderer apps. Guard runtime language switches against stale async loads and keep build-refreshed provider metadata current.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d2f6620d-45b0-42b8-ae4a-ed62bf2b9ff4

📥 Commits

Reviewing files that changed from the base of the PR and between bfb1e78 and e4c2ce4.

⛔ Files ignored due to path filters (2)
  • src/renderer/src/lib/icons/icon-collections.generated.ts is excluded by !**/*.generated.*
  • src/renderer/src/lib/icons/icon-whitelist.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (16)
  • docs/architecture/baselines/renderer-application-boundaries-baseline.json
  • docs/architecture/settings-locale-lazy-loading/plan.md
  • docs/architecture/settings-locale-lazy-loading/spec.md
  • docs/architecture/settings-locale-lazy-loading/tasks.md
  • resources/acp-registry/registry.json
  • resources/model-db/providers.json
  • src/renderer/floating/main.ts
  • src/renderer/settings/App.vue
  • src/renderer/settings/main.ts
  • src/renderer/src/i18n/bootstrap.ts
  • src/renderer/src/i18n/index.ts
  • src/renderer/src/i18n/pluralRules.ts
  • src/renderer/src/main.ts
  • src/renderer/src/stores/language.ts
  • test/renderer/i18n/localeLoading.test.ts
  • test/renderer/stores/languageStore.test.ts

📝 Walkthrough

Walkthrough

Changes

Renderer i18n lazy loading

Layer / File(s) Summary
Locale contracts and architecture documentation
docs/architecture/..., docs/architecture/baselines/...
Documents the lazy-loading design, fallback behavior, bootstrap sequencing, race protection, validation plan, and updated Settings import baseline.
Lazy locale loader and i18n bootstrap
src/renderer/src/i18n/*
Adds supported-locale normalization, dynamic locale imports with promise caching, separated plural rules, and fallback-aware createRendererI18n.
Renderer entry bootstraps
src/renderer/src/main.ts, src/renderer/settings/main.ts, src/renderer/floating/main.ts, src/renderer/settings/App.vue
Moves renderer mounting behind asynchronous i18n initialization and synchronizes document language direction and floating-widget subscriptions.
Race-safe language state transitions
src/renderer/src/stores/language.ts
Loads messages before publishing locale state, ignores stale asynchronous requests, preserves state on load failures, and removes listeners during disposal.
Loader and language-store validation
test/renderer/i18n/*, test/renderer/stores/*
Tests locale resolution, cache reuse, bootstrap fallback, listener cleanup, concurrent transitions, stale responses, and failed loads.

ACP registry releases

Layer / File(s) Summary
Agent release metadata
resources/acp-registry/registry.json
Updates versions and matching npm, uvx, binary archive, and checksum metadata for multiple registered agents.

Model catalog metadata

Layer / File(s) Summary
Provider model catalog updates
resources/model-db/providers.json
Adds model entries and revises capabilities, modalities, limits, reasoning metadata, release dates, and pricing tiers across providers.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RendererEntry
  participant createRendererI18n
  participant loadLocaleMessages
  participant VueI18n
  RendererEntry->>createRendererI18n: fetch language state
  createRendererI18n->>loadLocaleMessages: load en-US and requested locale
  createRendererI18n->>VueI18n: create i18n with loaded messages
  createRendererI18n-->>RendererEntry: return i18n and language state
  RendererEntry->>VueI18n: mount application
Loading

Possibly related PRs

Suggested reviewers: zerob13

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: lazy-loading renderer locales for i18n performance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/settings-locale-lazy-loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zhangmo8
zhangmo8 merged commit c302a99 into dev Jul 20, 2026
4 checks passed
@zhangmo8
zhangmo8 deleted the perf/settings-locale-lazy-loading branch July 20, 2026 09:43
zhangmo8 added a commit that referenced this pull request Jul 20, 2026
…e-optimization

Resolve language/i18n conflicts to preserve this PR's scope-boundary race
fixes (languageInitialization promise cache, listener-before-snapshot
registration, documentAppearance abstraction) alongside the lazy renderer
locale loading (#2003) and dashboard CPU reduction (#2004) perf wins from dev.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant