Skip to content

feat(zcode-rtl-fixer): add Persian/English RTL fixer plugin for ZCode Desktop - #362

Open
sajjadyousefnia wants to merge 2 commits into
zai-org:mainfrom
sajjadyousefnia:feat/zcode-rtl-fixer
Open

sajjadyousefnia wants to merge 2 commits into
zai-org:mainfrom
sajjadyousefnia:feat/zcode-rtl-fixer

Conversation

@sajjadyousefnia

@sajjadyousefnia sajjadyousefnia commented Nov 28, 2026 •

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI) — does not provide MCP Apps interactive pages / 不提供 MCP Apps 交互页面
  • Not applicable / 不适用 — repository-only changes; no plugin content changed / 仅仓库级改动,不涉及插件内容

Affected plugin name(s) / 涉及的插件名称:zcode-rtl-fixer (Standard plugin)

What / 改动内容

Adds a new community plugin external_plugins/zcode-rtl-fixer (v0.2.0) plus its marketplace.json entry.

Problem. In ZCode Desktop, messages that mix Persian and English render with a hard LTR base direction: Persian paragraphs hug the left edge, embedded English terms scramble word order, list markers sit on the wrong side, and users resort to copy-pasting text into other editors to read it.

Solution. A small, dependency-free renderer bootstrap (settings baked at patch time) is injected into the app's out/renderer/index.html of an extracted AppImage copy. It provides:

  • per-paragraph automatic direction via unicode-bidi: plaintext (first-strong) — Persian aligns right, English stays left, even within one message;
  • a Persian font (default: Vazirmatn) on blocks containing Arabic-script glyphs, with optional size compensation;
  • RTL column order for Persian-dominant tables and RTL list markers for Persian items;
  • code blocks (code/pre/language-*/hljs), the terminal and editors are untouched;
  • streaming-safe MutationObserver with rAF batching.

Ships commands /rtl:install, /rtl:status, /rtl:font, /rtl:settings, /rtl:uninstall and a management skill. The original AppImage and the running instance are never modified: the patch targets ~/.local/share/zcode-rtl-fixer/app (extracted copy), keeps a pristine app.asar.orig backup (idempotent re-patch), and registers a "ZCode RTL" launcher + desktop entry.

How it was tested.

  • 23 dependency-free unit tests (node tests/run-tests.mjs): bidi heuristics, ASAR read/patch/extract round-trips (incl. symlink entries, header growth, integrity metadata), patcher idempotency and settings baking, engine/manifest/catalog version sync.
  • Live-verified on a ZCode Desktop AppImage (Linux): patched archive verified byte-level (bootstrap baked, script tag present), launcher and desktop entry created, app boots from the launcher.

Repo checks: python3 scripts/validate.py → OK: 59 plugin(s) validated. python3 scripts/build_dist.py cannot complete on a plain checkout because unbuilt UI plugins (e.g. excalidraw) require pnpm build first — unrelated to this PR. This plugin packages cleanly through the same pipeline functions (build_zip/build_index_entry): deterministic zip of 16 entries, sha256 2ac333…8b2, componentTypes: [command, skill], publisherType: community. git diff --check passes.

Dependencies, network, permissions, side effects (documented in both READMEs):

  • Runtime network: none, except the optional /rtl:font command downloading the Vazirmatn release zip from GitHub. No telemetry.
  • Writes: ~/.local/share/zcode-rtl-fixer/, ~/.local/bin/zcode-rtl, ~/.local/share/applications/zcode-rtl.desktop, ~/.fonts/ (font command only), ~/.zcode/rtl-fixer/settings.json.
  • Executes: --appimage-extract, unzip, fc-cache/fc-list, mv during install. All scripts are original and dependency-free (Node stdlib only).
  • Platform: Linux AppImage builds of ZCode Desktop.

Licensing / provenance. All plugin code is original, MIT (LICENSE included). The Vazirmatn font (SIL Open Font License 1.1) is downloaded at runtime only when the user requests a font install; no font binaries are committed.

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/ / 插件名唯一且 kebab-case,位于 external_plugins/<name>/
  • Usage category is set (utilities) / 分类已填写
  • Plugin type and affected names are declared above / 类型与插件名已声明
  • version is 0.2.0 in BOTH plugin.json and marketplace.json / 两处版本号一致
  • README.md (EN) and README_CN.md (中文) both present and equivalent / 中英文 README 均已提供
  • description_i18n has both en and zh-CN in both manifests / 两处均含 en 与 zh-CN
  • No secrets, machine-specific paths, or private dependencies / 无密钥与机器专属路径
  • Model/API/network dependencies documented / 网络依赖已写明
  • python3 scripts/validate.py passes locally; build_dist.py verified for this plugin (full dist blocked by pre-existing unbuilt UI plugins) / 本地校验通过

… Desktop

Community plugin v0.2.0 under external_plugins/: per-paragraph automatic RTL
(first-strong), Persian font, RTL tables and list markers in the ZCode Desktop
chat box; code blocks untouched. Ships commands /rtl:install|status|font|
settings|uninstall, a management skill, a dependency-free ASAR patcher and 23
unit tests. Marketplace entry registered with en/zh-CN description_i18n.
@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

…in ZCode desktop entry to the patched instance
@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
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