Skip to content

Keep empty Auto-Translate in-place results as no-ops - #155

Draft
Blackspirits wants to merge 1 commit into
upl/review-base-dda1from
audit/auto-translate-inplace-empty-dda1
Draft

Blackspirits wants to merge 1 commit into
upl/review-base-dda1from
audit/auto-translate-inplace-empty-dda1

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Purpose

Current-main follow-up to the new "Translate in place" path merged in upstream commit dda1fce8f9d4a605b1b6732acc072c7109dc6323 (SubtitleEdit#14956 follow-ups).

The existing selected-lines flow already treated an OK result containing no translated rows as a no-op when it was about to capture the current subtitle as the original. The new in-place mode accidentally made that guard conditional on captureOriginal.

Current upstream main was rechecked at dda1fce8f9d4a605b1b6732acc072c7109dc6323, exactly this PR's base.

Finding fixed

For a subtitle without an original column:

  1. choose Translate in place;
  2. let the Auto-Translate dialog return OK but with every TranslatedText empty (for example a partial/cancelled run that produced no row);
  3. no subtitle Text is changed;
  4. nevertheless AutoTranslateSelectedLines() continued into OnSubtitleLanguageChanged().

OnSubtitleLanguageChanged() is intentionally stateful: it clears the cached detected language, clears the dictionary explicitly selected for the current subtitle, drops an in-progress spell-check session and re-runs live-spell-check language selection.

That is correct after translated text replaces rows, but not when the operation produced zero changes.

The pre-existing default/capture-original mode did return early for this exact empty-result case; the new in-place branch bypassed that no-op guarantee.

Fix

After OK, selected-lines Auto-Translate now first checks whether any result row contains non-empty TranslatedText.

If none do, it returns immediately before:

  • copying rows into OriginalText;
  • changing any subtitle text;
  • clearing detected-language/spell-check state;
  • switching translator mode;
  • refreshing the audio visualizer.

Only after a real translation exists does the method decide whether this run should capture the original or remain in-place.

Regression coverage

A headless UI regression:

  • creates a normal subtitle with no original column;
  • seeds the private detected-language cache with a sentinel;
  • opens selected-lines Auto-Translate with Translate in place enabled;
  • returns OK with every translated row empty;
  • asserts text and original columns remain unchanged;
  • asserts translator mode remains off;
  • asserts the detected-language cache remains untouched.

The existing positive in-place translation and default capture-original tests remain unchanged.

Scope / branch state

Acceptance

  • full restore/build/test suite on this exact HEAD;
  • no new warning attributable to this tranche;
  • retry step unused;
  • final adversarial review must confirm zero-result behavior is a true no-op in both in-place and capture-original modes;
  • upstream drift rechecked before freeze.

AI assistance: ChatGPT was used for state-transition review of the new in-place path, spell-check/language side-effect tracing, and focused no-op regression design.

Final CI

Authoritative run: SubtitleEdit#313 on 95d3546056de205091f9fa4fd1475f01399a4f36

  • SeConv: 505 passed / 2 skipped / 0 failed
  • LibUiLogic: 918 passed / 0 skipped / 0 failed
  • LibSE: 2030 passed / 0 skipped / 0 failed
  • UI: 5411 passed / 10 skipped / 0 failed
  • build: 0 errors / 8 pre-existing warnings
  • retry step skipped
  • failure-artifact upload skipped

All eight warnings are outside the two-file #155 changed set.

Final drift gate

Upstream main was rechecked at dda1fce8f9d4a605b1b6732acc072c7109dc6323, exactly this PR's base. No post-base drift exists.

Final adversarial review was performed on this exact HEAD after CI; no blocker found.

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Final adversarial review on 95d3546056de205091f9fa4fd1475f01399a4f36 after CI SubtitleEdit#313: no blocker found. Verified zero-result OK is now a true no-op before original capture, row mutation, detected-language reset, dictionary/spell-check state reset, translator-mode switch and waveform refresh. Positive in-place and capture-original paths remain unchanged. All eight warnings are outside the changed set; upstream is still exactly dda1fce8.... No merge/promotion performed.

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