Skip to content

perf(build): split renderer routes and locale assets - #1283

Merged
vastsa merged 5 commits into
mainfrom
fix/build-warnings
Oct 1, 2026
Merged

vastsa merged 5 commits into
mainfrom
fix/build-warnings

Conversation

@vastsa

@vastsa vastsa commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Lazy-load renderer surfaces, settings, plugins, locale catalogs, and changelog chunks to reduce startup payload and split build output by use.
  • Keep existing changelog APIs available while adding locale-specific loading.
  • Remove unused Rust permission timestamp state and update its tests.
  • Align the plugin launcher source-contract test with the lazy-loaded renderer branch.

Validation

  • pnpm build:js
  • pnpm --filter @pi-desktop/desktop typecheck
  • pnpm lint
  • node --test targeted desktop regression files: 67/67 passed
  • cargo fmt --check
  • cargo test -p host-core --locked: 711 passed
  • cargo clippy -p host-core --all-targets --locked
  • pnpm test:e2e:layout: 192/192 passed

Vite still reports several individual chunks above 500 KB; this change splits the renderer entry and routes, while those remaining vendor/content chunks can be optimized separately.

vastsa added 2 commits October 1, 2026 20:20
The renderer entry eagerly included chat, work panel, launcher, settings, and all changelog locales. Load these surfaces and catalogs on demand while preserving retained chat state and the existing changelog API.

Remove the unused permission timestamp and silence an unused lock guard binding without changing permission expiry or request-budget behavior.
Keep the renderer source contract aligned with lazy loading and its error boundary, so the plugin launcher regression check continues to verify the current rendering path.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:26
The extracted locale files contain declarative release notes and are loaded as independent chunks. Record that data boundary so the source-module budget only gates ordinary implementation modules.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Locale loading introduces an unhandled rejection path and lacks regression coverage for overlapping asynchronous language requests.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Splits renderer routes, locale catalogs, and release notes into lazy-loaded chunks to reduce startup payload while preserving existing APIs.

Changes:

  • Adds lazy loading for renderer surfaces, work panel, release notes, and locale assets.
  • Extracts changelog catalogs into locale-specific modules with caching.
  • Removes unused Rust permission timing state and updates regression tests.
File Description
packages/​shared/​src/​changelog.test.ts Tests lazy catalog loading and caching.
packages/​shared/​src/​changelog.ts Preserves synchronous changelog APIs.
packages/​shared/​src/​changelog-runtime.ts Extracts locale/version normalization.
packages/​shared/​src/​changelog-loader.ts Dynamically loads locale catalogs.
packages/​shared/​src/​changelog-en.ts English changelog catalog.
packages/​shared/​src/​changelog-zh-CN.ts Simplified Chinese catalog.
packages/​shared/​src/​changelog-zh-TW.ts Traditional Chinese catalog.
packages/​shared/​src/​changelog-de.ts German changelog catalog.
packages/​shared/​src/​changelog-es.ts Spanish changelog catalog.
packages/​shared/​src/​changelog-fr.ts French changelog catalog.
packages/​shared/​src/​changelog-ko.ts Korean changelog catalog.
packages/​shared/​src/​changelog-pt-BR.ts Brazilian Portuguese catalog.
packages/​shared/​src/​changelog-tr.ts Turkish changelog catalog.
packages/​shared/​package.json Exports the changelog loader.
packages/​i18n/​src/​locale-info.ts Extracts locale metadata and helpers.
packages/​i18n/​src/​index.ts Re-exports locale metadata.
packages/​i18n/​package.json Exports locale-specific entry points.
crates/​host-core/​src/​rpc/​mod.rs Retains lock lifetime without warning.
crates/​host-core/​src/​permissions.rs Removes unused monotonic timestamp state.
apps/​desktop/​test/​work-panel.test.mjs Updates work-panel lazy-loading contracts.
apps/​desktop/​test/​settings-general.test.mjs Tracks extracted language logic.
apps/​desktop/​test/​renderer-locale-loading.test.mjs Tests catalog loading and language switching.
apps/​desktop/​test/​plugin-launcher-window.test.mjs Updates launcher lazy-loading contract.
apps/​desktop/​test/​auto-update.test.mjs Verifies lazy release-note catalogs.
apps/​desktop/​test/​app-shell-settings-accessibility.test.mjs Verifies lazy chat mounting behavior.
apps/​desktop/​src/​styles/​work-panel.css Styles the work-panel loading fallback.
apps/​desktop/​src/​main.tsx Lazily loads secondary renderer surfaces.
apps/​desktop/​src/​lib/​renderer-language.ts Loads and applies locale catalogs asynchronously.
apps/​desktop/​src/​lib/​renderer-catalogs.ts Implements cached renderer catalog imports.
apps/​desktop/​src/​lib/​app-language.ts Connects asynchronous language loading to settings.
apps/​desktop/​src/​features/​settings/​agent-sections.tsx Lazily loads release notes.
apps/​desktop/​src/​features/​app/​AppShell.tsx Splits chat and work-panel code.
apps/​desktop/​src/​components/​ReleaseNotesDialog.tsx Loads localized changelogs on demand.
apps/​desktop/​electron.vite.config.ts Adds source aliases for locale chunks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +40 to +42
export async function applyAppLanguage(
language: AppSettings["language"],
): Promise<void> {
Comment on lines +44 to +48
const request = ++languageRequest;
const apply = languageApplyQueue.then(async () => {
if (request !== languageRequest) return;
const catalog = await loadRendererCatalog(target);
if (request !== languageRequest) return;
vastsa added 2 commits October 1, 2026 20:38
Keep source-contract checks aligned with the renderer startup refactor, where locale application and crash copy now flow through dedicated language and i18n helpers.
@vastsa
vastsa merged commit 2238d6f into main Oct 1, 2026
4 checks passed
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.

2 participants