Port and harden API-Route auto-translation integration - #111
Blackspirits wants to merge 2 commits into
Conversation
f2a4f44 to
cb6de2c
Compare
Blackspirits
left a comment
There was a problem hiding this comment.
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.
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
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-5as 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-solfirst/default:gpt-5.6-solclaude-sonnet-4-6gemini-3.1-prodeepseek-v4-progrok-4.5qwen/qwen3.5-plus-202604202. Divergent prompt defaults
ToolsSettings.ApiRoutePromptpreserved subtitle line breaks, butSeAutoTranslate.ApiRoutePromptdid not. AutoTranslate copies the persistedSeAutoTranslatevalue 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
TranslateSettingsViewModeldid not know aboutApiRouteTranslate, 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:
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
Validation
c77c4b428649ce7030e6cf218b4d7c384b955232d47d366133e62a876b72c598289a537b41170235cb6de2ce04cd12c3d93961c162417a4e2e5822f1AI assistance: ChatGPT was used to audit provider defaults, settings integration, current model provenance and request serialization.