Skip to content

feat(frontend): reactive error locale (#158), AOT i18n precompile + size gate (#159), image build smoke (#160) - #179

Merged
wangrh0909 merged 3 commits into
masterfrom
feat/i18n-followups
Sep 8, 2026
Merged

wangrh0909 merged 3 commits into
masterfrom
feat/i18n-followups

Conversation

@voidvec

@voidvec voidvec commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the three i18n follow-up issues from the PR #156 review in one tranche (frontend-only; no API/SDK/protocol impact):

#158 — errors re-translate on locale switch

Two stacked one-time resolutions caused the snapshot behavior: services/locale.ts held a plain module variable (not Vue-trackable), and error state stored the already-resolved string.

  • services/locale.ts gains an injectable getter (setLocaleGetter); getCurrentLocale() prefers it, falling back to the plain mirror so node-env tests and the cross-app property test keep exact pre-Errors do not re-translate on locale switch (reactive error locale — ADR-0013 follow-up) #158 behavior. The services layer stays vue-i18n-free.
  • src/i18n/index.ts injects setLocaleGetter(() => i18n.global.locale.value); under legacy: false that is a ref, so a getErrorMessage(code) call inside a render effect tracks the locale.
  • ~21 pages + both auth stores now store the NormalizedError (ref<NormalizedError | string | null>) and resolve at render time via an errorText computed. Plain strings (parameterized chrome copy via t('key', {param})) keep snapshot semantics by design. One deliberate exception stays imperative: window.alert(...) in the user SecurityPage link flow.
  • The two locking e2e specs now assert re-translation on locale switch; new locale.reactive.test.ts pins the getter contract (preference over the mirror, re-resolution, afterEach cleanup).

#159 — AOT precompile + bundle-size budget gate

  • @intlify/unplugin-vue-i18n@11.2.5 precompiles the UI catalogs (converted to export default per the plugin contract; explicit include paths so application code is never matched). Production builds bundle vue-i18n runtime-only: main chunk 251.7→133.8 KB (user) and 248.6→143.1 KB (admin); dev/vitest keep the full build (separate vitest config), so tests exercise identical message resolution semantics.
  • The error catalog (services/messages/*) is intentionally untouched — it is a plain lookup table that never goes through vue-i18n.
  • New scripts/check-frontend-size.mjs gates total + entry-chunk raw JS at baseline +10% (wired into _frontend.yml after builds). The entry-chunk cap doubles as the AOT guard: the compiler re-entering the bundle costs ~90-118 KB on the main chunk and trips the gate mechanically. Raise baselines only with written PR justification (coverage-ratchet discipline).
  • Production bundles of both apps functionally verified via vite preview + Playwright in en and zh-CN (dev-server e2e alone cannot see the runtime-only path).

#160 — frontend Docker image build smoke

New frontend-image-smoke job in _frontend.yml: path-filtered (frontends/**, deploy/docker/**, the workflow itself) docker build with push: false of exactly the two images release.yml builds — admin (context frontends/admin) and the user portal (deploy/docker/Dockerfile target frontend-runtime). GHA layer cache keeps warm runs cheap. If cold-cache runtime ever disappoints, the documented fallback is continue-on-error, not removal. Because ci.yml's build-test needs the frontend call, the smoke gates the main gate.

Testing

  • Both apps: tsc && vite build green; vitest green (user 37 incl. 3 new, admin 4); ESLint 0 errors (warning counts identical to master); Playwright e2e green (user 119 passed / 2 skipped, admin 190 passed / 6 skipped — both skip sets pre-existing).
  • node scripts/check-frontend-size.mjs green; check-ui-sync.mjs green (shared UI kit untouched).
  • Workflow YAML validated; subagent code review returned APPROVE (no blocker/major; info items addressed or documented).

Docs

ADR-0013 (limitation removed), docs/contribute/frontend-i18n.md (reactive resolution + plugin section), docs/contribute/ci-cd-guide.md (frontend gate section, sections renumbered), CHANGELOG [Unreleased].

…e, image build smoke

#158 — errors re-translate on locale switch: services/locale.ts takes an
injected reactive getter (setLocaleGetter) wired to the vue-i18n composer
ref; error state stores the NormalizedError and pages/banners resolve the
catalog message at render time (errorText computed). Services stay
vue-i18n-free (node tests use the plain-mirror fallback). Both locking
i18n e2e specs now assert re-translation; new locale.reactive unit test
pins the getter contract.

#159 — @intlify/unplugin-vue-i18n precompiles the UI catalogs (default-
export TS modules, explicit include paths) and production builds bundle
vue-i18n runtime-only; main chunk 251.7->133.8 KB (user) and 248.6->143.1
KB (admin). New scripts/check-frontend-size.mjs gates total + entry-chunk
raw JS at baseline +10% (wired into _frontend.yml); production builds of
both apps verified against vite preview in en + zh-CN.

#160 — frontend-image-smoke job in _frontend.yml builds both frontend
Docker images (push: false) on PRs touching frontends/** or
deploy/docker/**, mirroring release.yml's builds with GHA layer cache,
so image regressions fail the PR instead of the release.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…mage-smoke paths filter

A reusable workflow cannot escalate above the caller's permissions —
nested job 'frontend-image-smoke' requesting 'pull-requests: read' made
ci.yml fail startup validation ('only allowed pull-requests: none').
Set the ceiling on the calling job per GitHub's reusable-workflow model.
…t imports

#160 smoke caught a real, latent master break: the frontend-runtime image
builds in an isolated context copying ONLY frontends/user/, but tsc (via
npm run build) type-checks src tests that dynamically import
../../../admin/** — added in #156 and unbuildable in the container since.
No release has shipped an image build since #156, so it went unnoticed.

tsconfig.build.json excludes *.test.ts from the build type-check; tests
stay type-checked in-repo via the base tsconfig. Admin app is unchanged
(its image context is self-contained and its tests keep container
type-checking).
@voidvec

voidvec commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Finding: the #160 smoke caught a real, latent master break on its first run

The new frontend-image-smoke job failed on this PR's first CI round — and the failure was not caused by this PR's changes:

Fix in this PR: frontends/user/tsconfig.build.json excludes *.test.ts from the build type-check ("build": "tsc -p tsconfig.build.json && vite build"); tests stay type-checked in-repo via the base tsconfig (IDE + vitest). The admin app is unchanged — its image context is self-contained and its tests keep container type-checking. After the fix, both image builds pass in CI (frontend-image-smoke 1m27s with a cold GHA cache — well under the 5-minute bar, so the job stays blocking).

@wangrh0909
wangrh0909 merged commit 63cbc3a into master Sep 8, 2026
11 checks passed
@voidvec
voidvec deleted the feat/i18n-followups branch September 8, 2026 06:49
wangrh0909 pushed a commit that referenced this pull request Sep 10, 2026
… and hooks

Consolidates the recurring lessons from the 2026-08/09 engineering sessions
(previously only in AI-session memory) into versioned, tool-agnostic assets:

- skills: ci-gate-sync (sync-point policies for error codes/endpoints/
  migrations/headers), ci-failure-triage (cross-compiler WERROR blind spots,
  flake taxonomy), release-engineering (six-point + ~15 version carriers,
  tag recovery, PyPI first publish), pr-workflow (rebase-merge repair,
  rebase value-loss audit, PAT permission boundary), local-env-runbook
  (Windows/WSL/Docker/Mimosa/multi-session rules), test-methodology (two
  test layers, mock injection seam, Playwright pitfalls), and
  benchmark-methodology (wrk Lua model, A/B discipline, measurement-artifact
  taxonomy).
- rules (path-scoped): sync-points (8-point error-code and 5-point endpoint
  hard checklists), frontend-contract (verified frontend/backend contract
  facts), async-cpp-gotchas (traps beyond db-operations: Session::insert
  no-overwrite, callback double-move, ::drogon:: shadowing).
- commands: /preflight (local gate sweep before pushing), /ci-triage
  (failure classification workflow).
- hooks: local-gates.sh (wired to the git-commit PreToolUse hook, replacing
  the broken full-ctest gate), port-guard.sh, redis-watchdog.ps1.

Provenance (source retrospectives): ci-gate-sync/rules.sync-points from PR
#115/#141/#149/#157/#179/#180 CI post-mortems; release-engineering from the
v1.0.0-v1.1.0 release runs; test-methodology from the coverage push
(48.5%->57.2%) and PR #140/#156 e2e work; benchmark-methodology from the
four-product comparison campaign; local-env-runbook from environment
incident records. AGENTS.md indexes the new rules and skills.
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