Skip to content

fix[smartling]: ENG-12342 fix 'Clear translation metadata' button not working#4544

Open
Manish-Builder-io wants to merge 1 commit intomainfrom
fix/smartling-clear-translation-metadata
Open

fix[smartling]: ENG-12342 fix 'Clear translation metadata' button not working#4544
Manish-Builder-io wants to merge 1 commit intomainfrom
fix/smartling-clear-translation-metadata

Conversation

@Manish-Builder-io
Copy link
Copy Markdown
Contributor

@Manish-Builder-io Manish-Builder-io commented Apr 28, 2026

Problem

The Clear translation metadata content action in the Smartling plugin was silently broken. Clicking the button and confirming the dialog appeared to succeed (snackbar showed "Translation metadata cleared."), but the translation fields (translationStatus, translationJobId, etc.) were never actually removed from the content.

Root Cause

content.meta is a MobX observable Map. The button's onClick handler cloned it using fastClone:

const updatedMeta = fastClone(content.meta);
// fastClone = (obj) => JSON.parse(JSON.stringify(obj))

JSON.stringify on a MobX observable Map serialises it as {} (an empty plain object) — Map entries are not picked up by the default JSON serialiser. As a result:

  • updatedMeta was always {}
  • The subsequent delete updatedMeta.translationStatus (etc.) calls were no-ops on a field that didn't exist
  • updateLatestDraft was called with meta: {}, either leaving the translation fields untouched (if the API merges) or wiping all metadata (if the API replaces)

Fix

Replace fastClone(content.meta) with { ...content.meta?.toJS() }.

.toJS() is the correct MobX API for converting an observable Map to a plain JS object. The spread then creates a regular mutable copy, and the delete operations work as intended.

// Before
const updatedMeta = fastClone(content.meta);

// After
const updatedMeta = { ...content.meta?.toJS() };

This is exactly the same pattern already used in the backend's cleanupOrphanedTranslationMetadata helper (smartling.ts:465), confirming it's the correct approach.

Test Plan

  • Open a content entry that has stale translation metadata (e.g. translationStatus = completed or translationJobId set, not in pending/local)
  • Open the content actions menu — confirm Clear translation metadata is visible
  • Click it and confirm the dialog
  • Verify the snackbar shows "Translation metadata cleared."
  • Reload the content entry and confirm all 7 translation fields (translationStatus, translationJobId, translationBy, translationRevision, translationRevisionLatest, translationBatch, translationRequested) are gone from the meta
  • Confirm the Clear translation metadata button no longer appears for that entry

🤖 Generated with Claude Code


Note

Low Risk
Low risk: a small, localized change to how content.meta is converted to a plain object before deleting translation fields; no auth or data model changes beyond fixing the metadata update payload.

Overview
Fixes the Smartling “Clear translation metadata” content action to correctly remove translation fields by converting the MobX content.meta map to a plain object via content.meta?.toJS() instead of fastClone (JSON cloning).

This ensures the subsequent delete operations produce an updated meta payload that actually clears translationStatus, translationJobId, and related keys when calling updateLatestDraft.

Reviewed by Cursor Bugbot for commit e967d02. Bugbot is set up for automated code reviews on this repo. Configure here.

`content.meta` is a MobX observable Map; calling `fastClone` on it
(JSON.parse/JSON.stringify) serialises it as `{}`, so the subsequent
`delete` calls were no-ops and `updateLatestDraft` was called with an
empty meta object instead of the correctly-stripped one.

Replace `fastClone(content.meta)` with `{ ...content.meta?.toJS() }`
to match the identical pattern already used in the backend's
`cleanupOrphanedTranslationMetadata` helper in `smartling.ts`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

⚠️ No Changeset found

Latest commit: e967d02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Manish-Builder-io Manish-Builder-io changed the title fix[smartling]: fix 'Clear translation metadata' button not working fix[smartling]: ENG-12342 fix 'Clear translation metadata' button not working Apr 28, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 28, 2026

View your CI Pipeline Execution ↗ for commit e967d02

Command Status Duration Result
nx test @builder.io/react -- packages/react/src ✅ Succeeded 12s View ↗
nx test @builder.io/sdk ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-28 13:33:48 UTC

1 similar comment
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 28, 2026

View your CI Pipeline Execution ↗ for commit e967d02

Command Status Duration Result
nx test @builder.io/react -- packages/react/src ✅ Succeeded 12s View ↗
nx test @builder.io/sdk ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-28 13:33:48 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 28, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit e967d02

Command Status Duration Result
nx test @snippet/react ❌ Failed 4m 12s View ↗
nx test @e2e/nextjs-sdk-next-app ✅ Succeeded 7m 45s View ↗
nx test @e2e/angular-17 ✅ Succeeded 6m 39s View ↗
nx test @e2e/qwik-city ✅ Succeeded 7m 10s View ↗
nx test @e2e/nuxt ✅ Succeeded 6m 3s View ↗
nx test @e2e/gen1-next15-app ✅ Succeeded 5m 26s View ↗
nx test @e2e/angular-17-ssr ✅ Succeeded 6m 4s View ↗
nx test @e2e/angular-19-ssr ✅ Succeeded 5m 51s View ↗
Additional runs (38) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-04-28 13:41:35 UTC

Copy link
Copy Markdown
Contributor

@anaghav2023 anaghav2023 left a comment

Choose a reason for hiding this comment

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

@Manish-Builder-io changes look good.
Did you test it?

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.

3 participants