Skip to content

emrg: gui renderer Batch 1 remainder — i18n full dictionary (373 keys) + markdown port - #993

Merged
argszero merged 1 commit into
masterfrom
feature/gui-react-batch1-remainder
Aug 26, 2026
Merged

emrg: gui renderer Batch 1 remainder — i18n full dictionary (373 keys) + markdown port#993
argszero merged 1 commit into
masterfrom
feature/gui-react-batch1-remainder

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Batch 1 remainder of the GUI renderer React migration (design ~/.emrg/designs/gui-react-migration-design.md §5, rant 2026-08-26T12:16:48 — Batch 1 items 3 + 5). Completes the pure-logic port layer after #992 (commands/copywriting + preload API-surface guard).

1. i18n — full dictionary + vanilla logic port

  • src/lib/i18n-dicts.ts (auto-generated from vanilla renderer/js/i18n.js): full 373-key zh/en dictionaries, strict parity (guarded by test).
  • src/lib/i18n.tsx upgraded from Batch-0 skeleton to the full implementation:
    • detectLocale() (navigator, zh* → zh), getLocale()/setLocale() (localStorage emrg.locale override, "" = follow system), t(key, params) with zh fallback + {var} interpolation — semantics identical to vanilla.
    • React-shell-only keys (shell.batch0Notice etc.) kept as a provider-level extension so the vanilla dict stays pure.
  • Tests +11 (i18n.test.ts): mirror the old emrg/gui/test/i18n.test.js node:test assertions (detectLocale / en-zh strings / setLocale persistence / interpolation / unknown-key) + dictionary parity guard (373 keys aligned, no drift).

2. markdown — port with injectable vendor deps

  • src/lib/markdown.ts: createMarkdownRenderer({ marked, DOMPurify, hljs, t }) returns renderMarkdown / streamProject / streamFinalize — ports the vanilla marked-v12 code renderer (hljs exact-lang highlight, auto fallback), DOMPurify sanitize, the block-projection streaming logic (stable blocks cached, live tail block re-rendered, unclosed fence → plain text, FENCE_END_RE / isFenceClosed exported pure).
  • Key difference from vanilla: vendor deps are constructor-injected instead of read from window — testable in Vitest, wired to the browser entry when Batch 2 (chat) lands.
  • Tests +11 (markdown.test.ts): fence open/closed dual-state, no-marked escape fallback, fake-marked render + DOMPurify sanitize, hljs highlight path, copy-button i18n, block-projection DOM structure (jsdom).

Verification (all green)

  • renderer: npm run typecheck clean; npm test56/56 (was 34; +11 i18n +11 markdown)
  • gui: npm test 265 (257 pass + 8 skipped, 0 fail)
  • pytest: 1094 passed / 1 skipped; doc-count guard 4/4; import + CLI OK
  • Agent.md count sync (renderer vitest 34 → 56)

Vanilla files (js/i18n.js, js/markdown.js) stay untouched until Batch 5 switch (design D3).

…) + markdown port
- i18n-dicts.ts: full zh/en dictionary auto-generated from vanilla i18n.js
(373 keys, strict zh/en parity guard test)
- i18n.tsx: vanilla detectLocale/getLocale/setLocale/t logic ported;
zh-fallback + localStorage 'emrg.locale' override; React shell keys kept
as provider-level extension (vanilla dict stays pure)
- markdown.ts: marked/DOMPurify/hljs injectable wrapper (renderMarkdown,
block-projection streamProject/streamFinalize, fence-closed heuristic)
- vitest: +11 i18n (mirrors old node:test assertions + parity guard),
+11 markdown (dual-state fence, escaping, hljs, streaming) → 56 total
- Agent.md: renderer 34→56 vitest, Batch 1 remainder documented

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-140537 (1/3)

Verified this cycle:

  • Head 507977a unchanged since submission; PR MERGEABLE
  • CI green: test + test-windows pass (run 32936239914)
  • Diff review: 6 files / +1324 — i18n-dicts.ts full 373-key zh/en dict (mechanical generation, parity-guarded), i18n.tsx vanilla locale-logic port (detectLocale/getLocale/setLocale/t with zh fallback), markdown.ts injectable marked/DOMPurify/hljs wrapper with block-projection streaming, +22 vitest (i18n 11 + markdown 11)
  • Agent.md count sync (renderer vitest 34→56)

Batch 1 remainder ready for merge once 3 consecutive LGTMs accumulate.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-141311 (2/3)

Re-verified this cycle:

  • Head 507977a unchanged since submission; PR MERGEABLE / CLEAN
  • CI still green: test + test-windows pass (run 32936239914)
  • Diff unchanged (6 files / +1324); i18n full-dict + markdown port remain sound

Consecutive LGTMs so far: cyc20260826-140537 (1/3) → this cycle (2/3).

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-141945 (3/3)

Re-verified this cycle:

  • Head 507977a unchanged; mergeStateStatus CLEAN / MERGEABLE
  • CI still green: test + test-windows pass (run 32936239914)
  • Diff unchanged (6 files / +1324)

3 consecutive LGTMs from different cycles (140537 → 141311 → 141945), no ❌ in between. Merge condition satisfied.

@argszero
argszero merged commit 15b2c7d into masterAug 26, 2026
2 checks passed
Sign up for freeto 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

@argszero