Skip to content

feat(ai-translation): translate Lexical Poll node - #2709

Merged
Innei merged 2 commits into
masterfrom
feat/lexical-poll-translation
May 12, 2026
Merged

feat(ai-translation): translate Lexical Poll node#2709
Innei merged 2 commits into
masterfrom
feat/lexical-poll-translation

Conversation

@Innei

@Innei Innei commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds AI translation for Lexical Poll nodes (type: 'poll'): the question and every non-empty option.label are now extracted as PropertySegments by the translation parser, translated, and written back in place. All non-translatable metadata (pollId, options[i].id, mode, closeAt, showResults, type, version) is preserved verbatim.
  • Implementation mirrors the existing Excalidraw special-case in walkNode: extract before the skip-block checks and emit segments with the appropriate node ref (the option object itself for labels) so the existing string-path restore writes back to option.label directly. No changes to restoreLexicalTranslation or the property-whitelist util.
  • Includes a build fix (fix(build): guard __DEV__/__TEST__ macros for non-vite contexts) — the vite define macros added in 1783b79 are not substituted in vitest's globalSetup (which runs outside vite), causing ReferenceError: __DEV__ is not defined and breaking the entire test suite. Guards added so the module works in both contexts.

Spec

docs/superpowers/specs/2026-05-12-lexical-poll-translation-design.md

Test plan

  • pnpm -C apps/core exec vitest run test/src/modules/ai/lexical-translation-parser.spec.ts — all 54 cases pass, including 4 new poll cases (parse, round-trip restore, empty-label skip, nested in details)
  • pnpm -C apps/core exec eslint --max-warnings 0 clean on all changed files
  • Translate a real post containing a poll end-to-end and verify the rendered translated post shows translated question + option labels

Innei added 2 commits May 12, 2026 19:40
The vite define macros added in 1783b79 are not substituted in
vitest's globalSetup (which runs in Node directly, not through vite),
causing a ReferenceError when env.global is imported via the
globalSetup -> path.constant chain. Add typeof guards with
process.env fallbacks so the module works in both contexts.
… labels

Parser walks Poll nodes (type: 'poll') and emits a PropertySegment for
the question and one per non-empty option label. Mirrors the existing
Excalidraw special-case: extract before skip-block checks and emit
segments against the appropriate node ref (option object for labels)
so the existing string-path restore writes back to option.label
directly. Restore path and property whitelist util are unchanged.

Spec: docs/superpowers/specs/2026-05-12-lexical-poll-translation-design.md
@safedep

safedep Bot commented May 12, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@Innei
Innei merged commit 9e5cdf6 into master May 12, 2026
11 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.

1 participant