Skip to content

Content Translation: Skip blocks that are removed or replaced mid-translation - #1137

Merged
dkotter merged 4 commits into
WordPress:developfrom
yogeshbhutkar:content-translation/abort-on-template-change
Oct 14, 2026
Merged

dkotter merged 4 commits into
WordPress:developfrom
yogeshbhutkar:content-translation/abort-on-template-change

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What, Why, and How?

Closes #1138

While testing the Content Translation experiment, I found that toggling "Show template" during a translation doesn't stop it, but none of the remaining results are applied. Switching the editor view recreates the post's blocks with new client IDs. The translation keeps sending requests for the old IDs, and each result is silently dropped because those blocks no longer exist, so the requests and tokens are wasted. The same happens when a block is deleted or transformed mid-translation, and in every case the dropped blocks were still counted as translated.

Rather than watching for specific triggers like the rendering mode, this PR checks whether each block still exists:

  • Before sending a batch, blocks that no longer exist are dropped, so no requests are spent on them. After a template toggle, every remaining batch is empty and the translation finishes on its own.
  • Before applying a result, the block is checked again in case it was removed while its request was in flight.
  • Removed blocks are counted separately from failures, so they aren't offered for retry and don't inflate the progress count.

Also, Generate Editorial Notes seems to rely on block client IDs and may have the same problem (untested as of now). That should be handled in a separate PR.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Reviewing the code and stress testing the changes.

Screencast

screencast.mov

Changelog Entry

Fixed - Skip blocks that are removed or replaced mid-translation in Content Translation.

Open WordPress Playground Preview

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.17%. Comparing base (26322c3) to head (b716658).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1137   +/-   ##
==========================================
  Coverage      82.17%   82.17%           
  Complexity      3399     3399           
==========================================
  Files            136      136           
  Lines          13187    13187           
==========================================
  Hits           10837    10837           
  Misses          2350     2350           
Flag Coverage Δ
unit 82.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yogeshbhutkar
yogeshbhutkar marked this pull request as ready for review October 8, 2026 05:29
@yogeshbhutkar
yogeshbhutkar requested a review from a team October 8, 2026 05:29
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@yogeshbhutkar
yogeshbhutkar force-pushed the content-translation/abort-on-template-change branch from e843687 to 79ba562 Compare October 9, 2026 06:38
@jeffpaul jeffpaul added this to the 1.6.0 milestone Oct 9, 2026
@yogeshbhutkar yogeshbhutkar changed the title Content Translation: Stop batch processing when the template mode changes Content Translation: Skip blocks that are removed or replaced mid-translation Oct 12, 2026
@yogeshbhutkar
yogeshbhutkar force-pushed the content-translation/abort-on-template-change branch from 64047d6 to cb9f556 Compare October 12, 2026 05:04
@yogeshbhutkar
yogeshbhutkar requested a review from dkotter October 12, 2026 06:15
@yogeshbhutkar
yogeshbhutkar force-pushed the content-translation/abort-on-template-change branch from cb9f556 to 6fbdb9c Compare October 14, 2026 03:44
@dkotter
dkotter merged commit 4578cd4 into WordPress:develop Oct 14, 2026
40 checks passed
@yogeshbhutkar
yogeshbhutkar deleted the content-translation/abort-on-template-change branch October 14, 2026 14:43
@jeffpaul jeffpaul modified the milestones: 1.6.0, 1.5.0 Oct 28, 2026
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.

Content Translation: Results are silently dropped when "Show template" is toggled mid-translation

3 participants