Skip to content

Frontend: late/foreign 'completed' event resets the UI mid-batch when currentJob is null #225

Description

@hydropix

Summary

When currentJob is null, any translation_update with a terminal status triggers resetUIToIdle(), which can kill a running batch mid-flight (during the window between finishing one file and the next file's start resolving), or react to a terminal event from a job started in another tab.

Where

  • src/web/static/js/translation/translation-tracker.js:400-406 (handleTranslationUpdate)
  • src/web/static/js/translation/batch-controller.js:317 (next file's await ApiClient.startTranslation)
  • finishCurrentFileTranslation sets currentJob = null at translation-tracker.js:571

Details

currentJob is legitimately null in the window between finishCurrentFileTranslation (null at :571) and the next file's startTranslation resolving (batch-controller.js:317). A duplicate/late terminal event for the just-finished file — or a terminal event from a job started in another tab — lands in that window and calls resetUIToIdle() (sets isBatchActive=false, clears localStorage, re-enables the Translate button), killing the running batch's state.

Suggested fix

Before resetting, verify the event's job id belongs to a job this tab actually owns (track owned job ids), and ignore terminal events for unknown/foreign ids. Don't treat "no current job" as "safe to reset everything."


Found during the June 2026 repo audit. Severity: medium. Confidence: likely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — bounded impactaudit-2026-06Found during the June 2026 repo auditbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions