[PR #7805] [MERGED] feat(i18n): localize tracker slice validation errors #7933

Closed
opened 2026-10-24 04:08:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: feat/7738-localize-tracker-errors


📝 Commits (1)

  • e3ac4ee feat(i18n): localize tracker slice validation errors

📊 Changes

8 files changed (+241 additions, -51 deletions)

View changed files

📝 packages/client/src/components/chat/AgentSuiteModal.tsx (+8 -3)
📝 packages/client/src/components/modals/GameStateEditorModal.tsx (+4 -1)
📝 packages/client/src/lib/agent-suite-tracker-slices.ts (+86 -15)
📝 packages/client/src/lib/state-editor/game-state-editor-source.ts (+8 -5)
📝 packages/client/src/localization/locales/en.json (+17 -0)
📝 packages/shared/src/utils/inventory-tracker-rows.ts (+43 -10)
📝 scripts/regressions/open-issues.regression.ts (+70 -17)
📝 scripts/regressions/state-editor.regression.ts (+5 -0)

📄 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 #7738

Why this change

  • When a tracker block in Agent Suite, or a section in the State Editor, doesn't fit its expected shape (for example "Present characters must be a JSON array", or an Inventory Tracker row with no name), the error came straight from AGENT_SUITE_TRACKER_SLICES as hard-coded English. People using another language saw English in both editors.
  • CodeRabbit's "Localized UI text" check flagged this on #7737; it was left for this follow-up because Agent Suite shares the same strings and open-issues.regression.ts pinned their exact text.

What changed

  • buildPatch in packages/client/src/lib/agent-suite-tracker-slices.ts now returns a typed TrackerSliceError code (notObject / notArray with the field, missingInventoryGroups, or invalidInventoryRow with the group and the row problem) instead of an English sentence.
  • One shared mapper, trackerSliceErrorMessage, turns a code into a ui.trackerData.errors.* key with its parameters (group, index, field). Agent Suite (AgentSuiteModal.tsx) and the State Editor's game-state modal (GameStateEditorModal.tsx, still prefixed with the section label) both use it. trackerSlicePatchError replaces the two copies of the "error" in patch check.
  • Shared: findInventoryTrackerRowProblem returns the row problem as a code. findInvalidInventoryTrackerRow keeps its English string output (the server and prompt.regression.ts still use it) and is now built on the new function, so the row rules live in one place.
  • en.json: 17 new keys with the same English wording users see today. Community locale packs are untouched and fall back to English.
  • Regressions: the open-issues.regression.ts tracker assertions now pin exact codes (deep-equal, stricter than the old regex matches). New checks: every key in TRACKER_SLICE_ERROR_KEYS exists in en.json, and each error (all 17 cases) renders through the mapper to the exact English text from before. state-editor.regression.ts also checks the forwarded error code.

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

Commands run by the agent (results):

  • pnpm build:shared && node ./scripts/run-regressions.mjs --filter open-issues: 1/1 passed
  • node ./scripts/run-regressions.mjs --filter state-editor: 1/1 passed
  • node ./scripts/run-regressions.mjs --filter prompt: 17/17 passed (covers the shared row validator's English output)
  • pnpm check (includes pnpm localization:check): exit 0 (one pre-existing lint warning in HomeProfessorMariChat.tsx, unrelated)

Manual verification notes

  • Manually verify in Agent Suite (Roleplay chat, Present Characters tracker, Tracker Data block) that saving {} shows "Present characters must be a JSON array", as before.
  • Manually verify in Agent Suite (Inventory Tracker block) that saving {"currencies": [], "equipped": [], "inventory": [{"name": "Rope", "qty": 0}]} shows Inventory Tracker "inventory": row 0 has a "qty" below 1.
  • Manually verify in the State Editor (game-state modal) that saving an Active Quests section set to {} shows "Active Quests: Active quests must be a JSON array".
  • Manually verify in a community locale that these errors still show (in English, since no translations were added) and never as raw ui.trackerData.errors.* keys.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

No user-facing docs changed.

UI evidence (if applicable)

Error text is unchanged in English; no visual change.

Summary by CodeRabbit

  • Bug Fixes
    • Validation errors for tracker slices and game-state edits now display localized, more specific messages.
    • Inventory errors can identify the affected row and, when relevant, the field that needs attention.
    • Invalid tracker data is checked consistently when saving changes.

🔄 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/7805 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/7738-localize-tracker-errors` --- ### 📝 Commits (1) - [`e3ac4ee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e3ac4ee466673d318fdc997b2a028c2f52135cd6) feat(i18n): localize tracker slice validation errors ### 📊 Changes **8 files changed** (+241 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/AgentSuiteModal.tsx` (+8 -3) 📝 `packages/client/src/components/modals/GameStateEditorModal.tsx` (+4 -1) 📝 `packages/client/src/lib/agent-suite-tracker-slices.ts` (+86 -15) 📝 `packages/client/src/lib/state-editor/game-state-editor-source.ts` (+8 -5) 📝 `packages/client/src/localization/locales/en.json` (+17 -0) 📝 `packages/shared/src/utils/inventory-tracker-rows.ts` (+43 -10) 📝 `scripts/regressions/open-issues.regression.ts` (+70 -17) 📝 `scripts/regressions/state-editor.regression.ts` (+5 -0) </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 #7738 ## Why this change - When a tracker block in Agent Suite, or a section in the State Editor, doesn't fit its expected shape (for example "Present characters must be a JSON array", or an Inventory Tracker row with no name), the error came straight from `AGENT_SUITE_TRACKER_SLICES` as hard-coded English. People using another language saw English in both editors. - CodeRabbit's "Localized UI text" check flagged this on #7737; it was left for this follow-up because Agent Suite shares the same strings and `open-issues.regression.ts` pinned their exact text. ## What changed - `buildPatch` in `packages/client/src/lib/agent-suite-tracker-slices.ts` now returns a typed `TrackerSliceError` code (`notObject` / `notArray` with the field, `missingInventoryGroups`, or `invalidInventoryRow` with the group and the row problem) instead of an English sentence. - One shared mapper, `trackerSliceErrorMessage`, turns a code into a `ui.trackerData.errors.*` key with its parameters (`group`, `index`, `field`). Agent Suite (`AgentSuiteModal.tsx`) and the State Editor's game-state modal (`GameStateEditorModal.tsx`, still prefixed with the section label) both use it. `trackerSlicePatchError` replaces the two copies of the `"error" in patch` check. - Shared: `findInventoryTrackerRowProblem` returns the row problem as a code. `findInvalidInventoryTrackerRow` keeps its English string output (the server and `prompt.regression.ts` still use it) and is now built on the new function, so the row rules live in one place. - `en.json`: 17 new keys with the same English wording users see today. Community locale packs are untouched and fall back to English. - Regressions: the `open-issues.regression.ts` tracker assertions now pin exact codes (deep-equal, stricter than the old regex matches). New checks: every key in `TRACKER_SLICE_ERROR_KEYS` exists in `en.json`, and each error (all 17 cases) renders through the mapper to the exact English text from before. `state-editor.regression.ts` also checks the forwarded error code. ## 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` Commands run by the agent (results): - `pnpm build:shared && node ./scripts/run-regressions.mjs --filter open-issues`: 1/1 passed - `node ./scripts/run-regressions.mjs --filter state-editor`: 1/1 passed - `node ./scripts/run-regressions.mjs --filter prompt`: 17/17 passed (covers the shared row validator's English output) - `pnpm check` (includes `pnpm localization:check`): exit 0 (one pre-existing lint warning in `HomeProfessorMariChat.tsx`, unrelated) ### Manual verification notes - Manually verify in Agent Suite (Roleplay chat, Present Characters tracker, Tracker Data block) that saving `{}` shows "Present characters must be a JSON array", as before. - Manually verify in Agent Suite (Inventory Tracker block) that saving `{"currencies": [], "equipped": [], "inventory": [{"name": "Rope", "qty": 0}]}` shows `Inventory Tracker "inventory": row 0 has a "qty" below 1`. - Manually verify in the State Editor (game-state modal) that saving an Active Quests section set to `{}` shows "Active Quests: Active quests must be a JSON array". - Manually verify in a community locale that these errors still show (in English, since no translations were added) and never as raw `ui.trackerData.errors.*` keys. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) No user-facing docs changed. ## UI evidence (if applicable) Error text is unchanged in English; no visual change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Validation errors for tracker slices and game-state edits now display localized, more specific messages. * Inventory errors can identify the affected row and, when relevant, the field that needs attention. * Invalid tracker data is checked consistently when saving changes. <!-- 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-24 04:08:56 +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#7933
No description provided.