Skip to content

Translate from preserved source, retry transient errors, parallel requests (v0.3.0) - #1

Merged
LockhartKZ merged 1 commit into
mainfrom
feat/parallel-requests-and-robustness
Jul 4, 2026
Merged

Translate from preserved source, retry transient errors, parallel requests (v0.3.0)#1
LockhartKZ merged 1 commit into
mainfrom
feat/parallel-requests-and-robustness

Conversation

@LockhartKZ

Copy link
Copy Markdown
Owner

What & why

Four fixes from a full-codebase review, plus the v0.3.0 bump so the next tag rebuilds the portable builds for all platforms:

  1. Preserve the source text — new Cue.source, set at parse time and never mutated. The engine now translates from it instead of cue.text, so the per-line ↻ retranslate and a Cancel-then-Translate re-run always start from the original text instead of re-translating a previous translation (previously the only copy of the source lived in a DOM cell).
  2. Retry transient errors — network blips, timeouts, 429s and 5xx now retry up to 2 extra times with a growing delay (isTransientLlmError in client.ts) instead of killing a long run. Auth/4xx errors still fail immediately. Also: cancelling mid-request (LlmError kind aborted) now shows the "Cancelled — partial result kept" toast instead of an error toast.
  3. Fix quadratic UI refresh — progress ticks fire once per translated line and each refreshed the whole preview table (full DOM scan + readability regexes per cue → ~4M operations on a 2,000-line file). Now coalesced to at most one refresh per animation frame.
  4. Parallel requests option — new engine concurrency param and a persisted "Parallel requests" setting (default 1 = exactly the old sequential behaviour). Higher values run that many batches in flight via a small worker pool: a large speedup on cloud endpoints. On failure the pool stops picking up new batches, in-flight batches finish (partial results kept), and the first error is rethrown.

Trade-off (documented in the UI hint): with parallel requests > 1, context continuity becomes best-effort — a batch sees whatever earlier lines have finished. 1 remains the right setting for local servers.

Releasing: the Windows portable exe in portable/ was rebuilt locally at 0.3.0. macOS/Linux portables can't be built from Windows — after merging, push the v0.3.0 tag and the release workflow builds all three platforms into a draft release.

Engine invariants (check the ones this PR touches)

  • Parse → serialize of an unchanged file is still byte-identical
  • The LLM still never sees timestamps or container formatting
  • Tag/⟦n⟧ placeholder masking is preserved (id-tag + token-set validation intact)
  • RTL text remains in logical order (never reversed); output stays UTF-8

Testing

  • npm run typecheck passes
  • npm test passes — 115 tests (4 new: translate-from-source, transient retry, no-retry-on-401, parallel overlap + correctness)
  • UI verified in the vite preview (new field renders, no console errors); full Windows build (npm run tauri build) completed at 0.3.0

Notes

concurrency: 1 takes the identical code path as before (worker pool degenerates to a sequential loop), so default behaviour is unchanged for existing users; saved settings without parallelRequests merge to 1.

🤖 Generated with Claude Code

… requests

- Cue.source keeps the original text: retranslate (per-line or full re-run)
  always starts from the source, never from a previous translation.
- Transient LLM errors (network/timeout/429/5xx) retry with backoff instead
  of killing a long run; cancel mid-request now shows the cancel toast.
- Progress refresh coalesced to one per animation frame (was quadratic on
  large files).
- New "Parallel requests" option (default 1 = old sequential behaviour):
  batches translated concurrently, big speedup on cloud endpoints.
- Bump version to 0.3.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LockhartKZ
LockhartKZ merged commit 9213db1 into main Jul 4, 2026
1 of 2 checks passed
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