[PR #7022] [MERGED] fix(game): show automatic translations of Game turns again #7431

Closed
opened 2026-10-23 04:19:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7022
Author: @SpicyMarinara
Created: 10/3/2026
Status: ✅ Merged
Merged: 10/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/game-auto-translate-7010


📝 Commits (5)

  • 0be7d07 fix: show server auto-translations of Game turns
  • 7951d53 fix: hide older Game translations and bound the shared parser
  • 198bae8 Merge remote-tracking branch 'origin/staging' into fix/game-auto-translate-7010
  • a8e2b75 Merge remote-tracking branch 'origin/staging' into fix/game-auto-translate-7010
  • 0151b82 fix(game): flatten dialogue whitespace in linear time

📊 Changes

8 files changed (+582 additions, -377 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/game-translation-edits.e2e.ts (+60 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+40 -343)
📝 packages/client/src/lib/dialogue-quotes.ts (+6 -28)
📝 packages/server/src/services/translation.service.ts (+6 -2)
📝 packages/shared/src/utils/game-narration-text.ts (+390 -0)
📝 scripts/regressions/background-translation.regression.ts (+8 -3)
📝 scripts/regressions/game-narration-text.regression.ts (+70 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7010

Why this change

Auto-Translate Responses stopped showing translations in Game mode. The translation was made and paid for, then hidden. Two changes built the "text to translate" for a Game turn in different ways:

  • #6420 moved automatic translation to the server. For a Game turn it translates the reply with its GM tags removed and saves that text as the translation's source.
  • #6688 changed the Game screen to rebuild GM turns segment by segment before translating, so the translator never sees tags like [main]. The server wasn't updated to match.

So the Game screen checks the saved source, finds that it matches neither its own rebuilt text nor the raw reply, and hides the translation. It also sees that the server owns the attempt, so it never retries. That happens on almost every real turn, because nearly all of them carry [choices:], [music:], [bg:], dialogue or note tags. Roleplay and Conversation are not affected. The existing Game auto-translate tests only used one-line plain prose, where all three texts are identical.

What changed

  • One builder for both sides: packages/shared/src/utils/game-narration-text.ts holds the text-only Game narration parser (moved from GameNarration.tsx), the dialogue-quote helpers, and buildGameTranslationSource. The server's translation service and the Game screen both use it, so they always send and compare the same text.
  • Translations already saved stay usable: the Game screen also accepts the older tag-stripped source for unedited turns, so translations saved since #6420 show. "Hide translation" and all three translate buttons use the same list of accepted sources (getGameTranslationSourceAliases).
  • Faster parser: it now runs on the server too, so runaway inputs are bounded. Long runs of whitespace and repeated [ used to take up to about 39 s for 40k characters; they now take 1–80 ms. Over 600k random inputs, the output is identical to the old parser's.
  • CHANGELOG: one entry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Run by the agent:

  • pnpm check and pnpm regression:prompt pass.
  • These regressions pass: game-narration-text (now with timing bounds), background-translation, game-shared-parser-bounds, tts-source-persistence, roleplay-vn-tts, capability-gm-verbs, open-issues and the assigned-issue sweeps.
  • e2e/game-translation-edits.e2e.ts passes on desktop-chromium and mobile-chromium (11 passed, 1 desktop-only skip).
  • With the Game screen change reverted, the tagged-turn tests and the "Hide translation" test fail. Against the old parser, the timing cases take 2–4.5 s each and fail.
  • After merging current staging: pnpm build:shared and the two translation regressions pass.
  • An adversarial review found three items:
    • "Hide translation" re-translating an older saved translation: fixed.
    • The slow parser on the server: fixed.
    • Older saved translations whose tags were also translated can show slightly out of line with the turn's beats: accepted. Those exist only on staging since 2026-09-20, and "Hide translation" then "Translate" fixes them.

Known and left alone:

  • Repeated unclosed [Note: openers still scale badly, about 0.6 s per 40k characters. This existed before, in the client and in the server's segment-edits.ts.

Still to verify by hand:

  • In a Game chat with Auto-Translate Responses on, let the GM reply with narration, character dialogue and choices. The translation shows in the text box and in Logs without pressing Translate.
  • Press Hide translation on that turn. The original returns, and nothing is translated again.

Not covered here: Game choices are never translated, and Translate My Messages isn't applied in the Game input. Both behave the same as before this PR.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG updated; no user docs change.

Summary by CodeRabbit

  • Bug Fixes
    • Auto-Translate now displays translations for Game turns containing character dialogue or game tags, including translations saved previously.
    • Internal dialogue tags are no longer included in text sent for translation, while readable text is retained.
    • Long stretches of blank space in Game replies no longer stall the Game screen or server.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7022 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/3/2026 **Status:** ✅ Merged **Merged:** 10/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/game-auto-translate-7010` --- ### 📝 Commits (5) - [`0be7d07`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0be7d072535fafac83db83dbe7929086f94cfd49) fix: show server auto-translations of Game turns - [`7951d53`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7951d53f91e8c02a7b7302fc9b974adb0b2eb8e6) fix: hide older Game translations and bound the shared parser - [`198bae8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/198bae8624f8e66b0d52cba842a54bb64a4cb380) Merge remote-tracking branch 'origin/staging' into fix/game-auto-translate-7010 - [`a8e2b75`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a8e2b750aaedcaa1d8ee37353bc9de573335202c) Merge remote-tracking branch 'origin/staging' into fix/game-auto-translate-7010 - [`0151b82`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0151b8281e160ca4567d2c9a0d4faff069430757) fix(game): flatten dialogue whitespace in linear time ### 📊 Changes **8 files changed** (+582 additions, -377 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/game-translation-edits.e2e.ts` (+60 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+40 -343) 📝 `packages/client/src/lib/dialogue-quotes.ts` (+6 -28) 📝 `packages/server/src/services/translation.service.ts` (+6 -2) 📝 `packages/shared/src/utils/game-narration-text.ts` (+390 -0) 📝 `scripts/regressions/background-translation.regression.ts` (+8 -3) 📝 `scripts/regressions/game-narration-text.regression.ts` (+70 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7010 ## Why this change **Auto-Translate Responses** stopped showing translations in Game mode. The translation was made and paid for, then hidden. Two changes built the "text to translate" for a Game turn in different ways: - **#6420** moved automatic translation to the server. For a Game turn it translates the reply with its GM tags removed and saves that text as the translation's source. - **#6688** changed the Game screen to rebuild GM turns segment by segment before translating, so the translator never sees tags like `[main]`. The server wasn't updated to match. So the Game screen checks the saved source, finds that it matches neither its own rebuilt text nor the raw reply, and hides the translation. It also sees that the server owns the attempt, so it never retries. That happens on almost every real turn, because nearly all of them carry `[choices:]`, `[music:]`, `[bg:]`, dialogue or note tags. Roleplay and Conversation are not affected. The existing Game auto-translate tests only used one-line plain prose, where all three texts are identical. ## What changed - **One builder for both sides:** `packages/shared/src/utils/game-narration-text.ts` holds the text-only Game narration parser (moved from `GameNarration.tsx`), the dialogue-quote helpers, and `buildGameTranslationSource`. The server's translation service and the Game screen both use it, so they always send and compare the same text. - **Translations already saved stay usable:** the Game screen also accepts the older tag-stripped source for unedited turns, so translations saved since #6420 show. "Hide translation" and all three translate buttons use the same list of accepted sources (`getGameTranslationSourceAliases`). - **Faster parser:** it now runs on the server too, so runaway inputs are bounded. Long runs of whitespace and repeated `[` used to take up to about 39 s for 40k characters; they now take 1–80 ms. Over 600k random inputs, the output is identical to the old parser's. - **CHANGELOG:** one entry. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Run by the agent: - `pnpm check` and `pnpm regression:prompt` pass. - These regressions pass: `game-narration-text` (now with timing bounds), `background-translation`, `game-shared-parser-bounds`, `tts-source-persistence`, `roleplay-vn-tts`, `capability-gm-verbs`, `open-issues` and the assigned-issue sweeps. - `e2e/game-translation-edits.e2e.ts` passes on desktop-chromium and mobile-chromium (11 passed, 1 desktop-only skip). - With the Game screen change reverted, the tagged-turn tests and the "Hide translation" test fail. Against the old parser, the timing cases take 2–4.5 s each and fail. - After merging current staging: `pnpm build:shared` and the two translation regressions pass. - An adversarial review found three items: - "Hide translation" re-translating an older saved translation: fixed. - The slow parser on the server: fixed. - Older saved translations whose tags were also translated can show slightly out of line with the turn's beats: accepted. Those exist only on staging since 2026-09-20, and "Hide translation" then "Translate" fixes them. Known and left alone: - Repeated unclosed `[Note:` openers still scale badly, about 0.6 s per 40k characters. This existed before, in the client and in the server's `segment-edits.ts`. Still to verify by hand: - In a Game chat with **Auto-Translate Responses** on, let the GM reply with narration, character dialogue and choices. The translation shows in the text box and in Logs without pressing Translate. - Press **Hide translation** on that turn. The original returns, and nothing is translated again. Not covered here: Game choices are never translated, and **Translate My Messages** isn't applied in the Game input. Both behave the same as before this PR. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG updated; no user docs change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Auto-Translate now displays translations for Game turns containing character dialogue or game tags, including translations saved previously. * Internal dialogue tags are no longer included in text sent for translation, while readable text is retained. * Long stretches of blank space in Game replies no longer stall the Game screen or server. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:19:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7431
No description provided.