Skip to content

Port and harden API-Route auto-translation integration - #111

Draft
Blackspirits wants to merge 2 commits into
upl/review-base-c77cfrom
fix/api-route-integration-c77c
Draft

Blackspirits wants to merge 2 commits into
upl/review-base-c77cfrom
fix/api-route-integration-c77c

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Purpose

Current-base audited port of upstream PR SubtitleEdit#14836 (API-Route auto-translator) onto c77c4b428649ce7030e6cf218b4d7c384b955232.

None of the original PR's six target files, nor the adjacent translate-settings UI, changed between its 40c97b2d... base and current upstream. The original provider changes can therefore be carried forward without overwriting later work.

Original integration retained

  • API-Route translator and endpoint support;
  • URL/model/API-key/prompt settings in both settings layers;
  • main auto-translate engine registration/configuration;
  • SE4 settings import mapping;
  • changelog entry.

Audit findings fixed

1. Stale first-use model

API-Route documents that model availability changes and that its pricing catalogue is the source of truth for current IDs. The original PR used claude-sonnet-4-5 as the first/default model and shipped an older static catalogue.

The model field in Subtitle Edit is already free-form, so the static array is now documented as suggestions rather than an exhaustive contract. The suggestions are refreshed to currently listed IDs, with gpt-5.6-sol first/default:

  • gpt-5.6-sol
  • claude-sonnet-4-6
  • gemini-3.1-pro
  • deepseek-v4-pro
  • grok-4.5
  • qwen/qwen3.5-plus-20260420

2. Divergent prompt defaults

ToolsSettings.ApiRoutePrompt preserved subtitle line breaks, but SeAutoTranslate.ApiRoutePrompt did not. AutoTranslate copies the persisted SeAutoTranslate value back into libse settings at startup, so the UI default could silently lose the line-break instruction.

Both defaults now preserve line breaks.

3. Missing advanced-settings integration

TranslateSettingsViewModel did not know about ApiRouteTranslate, so its prompt row was treated as unsupported/hidden and could not be reset or saved through the advanced settings dialog.

API-Route is now included in:

  • prompt placeholder validation;
  • prompt save/mirroring;
  • built-in/current prompt lookup.

4. Request JSON built by string concatenation

Prompt/text were escaped, but the user-editable model ID was interpolated directly into a JSON string. Quotes/backslashes in a custom model could produce invalid JSON or alter the payload structure.

The request body is now produced by System.Text.Json.JsonSerializer, with a focused helper covered by tests.

Tests

  • persistent default equals the provider's first current suggestion;
  • request-body JSON preserves a model containing quotes/backslashes as one string value and keeps the expected two-field root shape;
  • API-Route advanced prompt is visible;
  • reset restores the built-in line-break-preserving prompt;
  • save mirrors the prompt to both UI and libse settings.

Validation

  • based on current upstream c77c4b428649ce7030e6cf218b4d7c384b955232
  • upstream PR head ported: d47d366133e62a876b72c598289a537b41170235
  • final HEAD: cb6de2ce04cd12c3d93961c162417a4e2e5822f1
  • full solution restore passed
  • full solution build passed
  • full solution test suite passed on the first run
  • SeConvTests: 475 passed, 2 skipped, 0 failed (477 total)
  • LibUiLogicTests: 875 passed, 0 skipped, 0 failed
  • LibSETests: 2,008 passed, 0 skipped, 0 failed
  • UITests: 5,152 passed, 9 skipped, 0 failed (5,161 total)
  • retry step was not used
  • validation run: #34795889168
  • audit draft only; no merge/promotion intended

AI assistance: ChatGPT was used to audit provider defaults, settings integration, current model provenance and request serialization.

@Blackspirits
Blackspirits force-pushed the fix/api-route-integration-c77c branch from f2a4f44 to cb6de2c Compare September 14, 2026 01:25

@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.

Independent adversarial re-check on the final current-base port: all four integration defects found in upstream SubtitleEdit#14836 are addressed. The default/suggestion model list is refreshed against API-Route's current pricing catalogue while the UI remains free-form; the persisted prompt now preserves line breaks; ApiRouteTranslate is fully wired into the advanced prompt settings contract; and request JSON is serialized instead of interpolating a user-editable model string. Focused tests cover model/default consistency, safe JSON model serialization, prompt visibility/reset/save, and the full solution CI #34795889168 passed restore, build and tests on the first run: SeConvTests 475/2/0, LibUiLogicTests 875/0/0, LibSETests 2008/0/0, UITests 5152/9/0. Retry was not used. No blocker identified. Keep draft; no merge 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