diff --git a/README.md b/README.md index 44a9ef2..5caaa22 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ the last one gets `LLM_MAX_RETRIES`, and a model that fails over is skipped for a 400 from a model that rejects `response_format`; set `LLM_JSON_MODE=false` if your models do not support JSON mode. Translations run as background jobs, and if a job still fails, the **Resume translation** button continues from the last finished batch instead of starting over. +Completed jobs disappear from the list after 24 hours; failed jobs stay until they are +resumed or dismissed. Finished jobs can also be dismissed one by one or with **Clear finished**. ```env LLM_MODEL=google/gemma-4-26b-a4b-it:free diff --git a/package-lock.json b/package-lock.json index e7b7805..fc247a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -344,15 +344,15 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.23.5", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", - "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "version": "0.23.6", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz", + "integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==", "dev": true, "license": "Apache-2.0", "dependencies": { "@eslint/object-schema": "^3.0.5", "debug": "^4.3.1", - "minimatch": "^10.2.4" + "minimatch": "^11.0.5" }, "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" @@ -494,6 +494,13 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -1093,6 +1100,72 @@ "node": ">=14.0.0" } }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.11.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.11.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { + "version": "1.2.2", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.4", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { + "version": "0.10.2", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": { + "version": "2.8.1", + "dev": true, + "inBundle": true, + "license": "0BSD", + "optional": true + }, "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz", @@ -1312,17 +1385,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.0.tgz", - "integrity": "sha512-aysKgysPX9XOv/dk95UkvUDe++Q3n3dJPG9CEWT3RUccxfkPJ+Qn6nhKPDhZXU6Ofo9kgwGWwKyQCnZIXTgngg==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.2.tgz", + "integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.72.0", - "@typescript-eslint/type-utils": "8.72.0", - "@typescript-eslint/utils": "8.72.0", - "@typescript-eslint/visitor-keys": "8.72.0", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/type-utils": "8.72.2", + "@typescript-eslint/utils": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -1335,15 +1408,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.72.0", + "@typescript-eslint/parser": "^8.72.2", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.13", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.13.tgz", - "integrity": "sha512-2E8Q6rh+1RRSq/YdaGsNfXsEZy9FVqv6BSSrkmZJP7BnaoPnRfKL+YaofPvP+5rzdk144qSm6i4+hvPgUcbV4Q==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", "dev": true, "license": "MIT", "engines": { @@ -1351,16 +1424,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.0.tgz", - "integrity": "sha512-0O+x3ynciD6zuXb1CKSu165haQV6ey53DKhHHUnujP7U+XlltJG+/keT0Xhd1HXCze+IHf7Tvt39ovyepX/LNw==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.2.tgz", + "integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.72.0", - "@typescript-eslint/types": "8.72.0", - "@typescript-eslint/typescript-estree": "8.72.0", - "@typescript-eslint/visitor-keys": "8.72.0", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "debug": "^4.4.3" }, "engines": { @@ -1376,14 +1449,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.0.tgz", - "integrity": "sha512-bzHngBbmIgzj6TsTjVUCntGx6FFLgE7mPjpO0PzHycOaZHXqS43XnrkFIHRS16LLr/xO6FHSXG3GJFo/F4bSBQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.2.tgz", + "integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.72.0", - "@typescript-eslint/types": "^8.72.0", + "@typescript-eslint/tsconfig-utils": "^8.72.2", + "@typescript-eslint/types": "^8.72.2", "debug": "^4.4.3" }, "engines": { @@ -1398,14 +1471,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.0.tgz", - "integrity": "sha512-JewPyJOYcXBSAS7PIgufscHOwZqhTGyBRiQJhhuDln66tMchxvvt7nJ90JKKIoOelmdHA3kAQbm9cEUHc4JSEA==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.2.tgz", + "integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.0", - "@typescript-eslint/visitor-keys": "8.72.0" + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1416,9 +1489,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.0.tgz", - "integrity": "sha512-0vbxCf7xLVPSjcOdm6eQbgViH8EDJ8xnl1laLT9yoqSz2YmcSfSg5Vdl0JUvZf6rcuJ0ZivJIuMD4edTg8obaA==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.2.tgz", + "integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==", "dev": true, "license": "MIT", "engines": { @@ -1433,15 +1506,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.0.tgz", - "integrity": "sha512-gEXxmmbSTSOVTC37IYYvremOM31v+UN2W772bJxmVYPhAOPSUxtacyb7wkm1EhkYKU6KzFJsdU44DCV4to0LWw==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.2.tgz", + "integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.0", - "@typescript-eslint/typescript-estree": "8.72.0", - "@typescript-eslint/utils": "8.72.0", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -1458,9 +1531,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.0.tgz", - "integrity": "sha512-Adfoy59kxNEjT5E5fnyrp7GpHYuWs8ONbdohu4ez6IU46qDq8LltG90tLmkucZB2uhYL8mqBjtXqGd8yhfjXqQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.2.tgz", + "integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==", "dev": true, "license": "MIT", "engines": { @@ -1472,16 +1545,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.0.tgz", - "integrity": "sha512-gwLfFgWcw15tN2KXDCJvxEOQjPn+P3j/n3eSqkZ5sX4VpW9Cosodr+tWwBZRvJT3TcKx6HnPRGZMCNAiP1Xhug==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.2.tgz", + "integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.72.0", - "@typescript-eslint/tsconfig-utils": "8.72.0", - "@typescript-eslint/types": "8.72.0", - "@typescript-eslint/visitor-keys": "8.72.0", + "@typescript-eslint/project-service": "8.72.2", + "@typescript-eslint/tsconfig-utils": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -1499,10 +1572,26 @@ "typescript": ">=4.8.4 <6.1.0" } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "dev": true, "license": "ISC", "bin": { @@ -1513,16 +1602,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.0.tgz", - "integrity": "sha512-0up3oArJZBYnzOaEXKo8DmI43QvMZyPoFEt9LWzRJcyl/RcJjfKKPebknN1VbTgXBf3M/KggUh5uUMdURLnseg==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.2.tgz", + "integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.72.0", - "@typescript-eslint/types": "8.72.0", - "@typescript-eslint/typescript-estree": "8.72.0" + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1537,13 +1626,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.0.tgz", - "integrity": "sha512-E2mroviasaWecDzTGiGMtuEguuLVOeRggnrIn93CJuxYJzQBHbyymlT08aVQydbBal5538o+JkBKXh2sRuCyIA==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.2.tgz", + "integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/types": "8.72.2", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -1741,9 +1830,9 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2193,9 +2282,9 @@ "license": "MIT" }, "node_modules/eslint": { - "version": "10.13.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.13.0.tgz", - "integrity": "sha512-UohDjD4zSzEwhf58M3O7vc/ycc8O1I7dNlhtD0WxE8Px8EHNJKtUwzBqrzeGhisRuv2ag4sAYswszCJRgKXYUg==", + "version": "10.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz", + "integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==", "dev": true, "license": "MIT", "workspaces": [ @@ -2204,11 +2293,11 @@ "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", - "@eslint/config-array": "^0.23.5", + "@eslint/config-array": "^0.23.6", "@eslint/config-helpers": "^0.7.0", "@eslint/core": "^1.2.1", "@eslint/plugin-kit": "^0.7.3", - "@humanfs/node": "^0.16.6", + "@humanfs/node": "^0.16.8", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", @@ -2229,7 +2318,7 @@ "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "minimatch": "^10.2.5", + "minimatch": "^11.0.5", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, @@ -2546,9 +2635,9 @@ "license": "ISC" }, "node_modules/follow-redirects": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz", - "integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==", + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.3.tgz", + "integrity": "sha512-toOSoqN6d51Wjf1aOFJYcoVv1aND9rj/CwjLU0Vz40oDuSpWDayCeKe4JpL5NL0WdFvoOOCI3BRo69HahjbR1A==", "funding": [ { "type": "individual", @@ -3410,16 +3499,17 @@ } }, "node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "version": "11.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz", + "integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^5.0.8" + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -4227,16 +4317,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.72.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.0.tgz", - "integrity": "sha512-r26Fkc8As+mZvqp7SLsMmNFyYUup/6CjK7/eHBHmhOw6GH6n6YFxHVFrG0jN1c5CMpDzelLPxvgeCOzx7BjN+A==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.2.tgz", + "integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.72.0", - "@typescript-eslint/parser": "8.72.0", - "@typescript-eslint/typescript-estree": "8.72.0", - "@typescript-eslint/utils": "8.72.0" + "@typescript-eslint/eslint-plugin": "8.72.2", + "@typescript-eslint/parser": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/server/routes/subtitle.js b/server/routes/subtitle.js index b950c8a..61f8571 100644 --- a/server/routes/subtitle.js +++ b/server/routes/subtitle.js @@ -2,7 +2,7 @@ import { Router } from 'express'; import { resolve, sep } from 'path'; import { existsSync } from 'fs'; import { getConfigError } from '../services/translator.js'; -import { createTranslationJob, getJob, listJobs, retryJob } from '../services/jobs.js'; +import { clearFinishedJobs, createTranslationJob, dismissJob, getJob, listJobs, retryJob } from '../services/jobs.js'; import { extractSubtitles } from '../services/ffmpeg.js'; import { DATA_DIR, MOVIES_DIR } from '../utils/paths.js'; const router = Router(); @@ -76,6 +76,20 @@ router.get('/jobs', (req, res) => { res.json(listJobs()); }); +// Removes all finished (done or failed) jobs +router.delete('/jobs', (req, res) => { + res.json({ removed: clearFinishedJobs() }); +}); + +router.delete('/jobs/:id', (req, res) => { + try { + dismissJob(req.params.id); + res.status(204).end(); + } catch (error) { + res.status(error.status || 500).json({ message: error.message }); + } +}); + router.post('/jobs/:id/retry', (req, res) => { try { res.status(202).json(retryJob(req.params.id)); diff --git a/server/services/jobs.js b/server/services/jobs.js index 7491996..c05ba44 100644 --- a/server/services/jobs.js +++ b/server/services/jobs.js @@ -5,6 +5,7 @@ import { isConfigured as isPlexConfigured, updateLibrary } from './plexService.j const MAX_FINISHED_JOBS = 20; const MAX_FAILED_JOBS = 50; // failed jobs keep resume progress, so they are pruned last +const DONE_JOB_TTL_MS = 24 * 60 * 60 * 1000; // completed jobs disappear after a day // In-memory job store: survives page reloads, not server restarts const jobs = new Map(); @@ -40,11 +41,24 @@ function pruneOldest(list, keep) { } } +/** + * Drops completed jobs older than DONE_JOB_TTL_MS. Failed jobs are kept until + * they are retried or dismissed, since they hold resumable progress. + */ +function dropExpired(now = Date.now()) { + for (const job of jobs.values()) { + if (job.status === 'done' && now - Date.parse(job.finishedAt) > DONE_JOB_TTL_MS) { + jobs.delete(job.id); + } + } +} + /** * Drops the oldest finished jobs. Completed jobs go first; failed jobs hold * resumable progress and get a separate, larger limit. */ function pruneFinished() { + dropExpired(); const all = [...jobs.values()]; const done = all.filter(job => job.status === 'done'); const failed = all.filter(job => job.status === 'error'); @@ -171,11 +185,47 @@ export function retryJob(id) { } export function getJob(id) { + dropExpired(); const job = jobs.get(id); return job ? toPublic(job) : null; } /** Most recent first. */ export function listJobs() { + dropExpired(); return [...jobs.values()].reverse().map(toPublic); } + +/** + * Removes a finished (done or failed) job. Dismissing a failed job discards + * its resume progress. + */ +export function dismissJob(id) { + const job = jobs.get(id); + if (!job) { + const error = new Error('Job not found'); + error.status = 404; + throw error; + } + if (isActive(job)) { + const error = new Error('Active jobs cannot be dismissed'); + error.status = 409; + throw error; + } + jobs.delete(id); +} + +/** + * Removes every finished (done or failed) job; queued and running ones stay. + * @returns {number} How many jobs were removed + */ +export function clearFinishedJobs() { + let removed = 0; + for (const job of jobs.values()) { + if (!isActive(job)) { + jobs.delete(job.id); + removed++; + } + } + return removed; +} diff --git a/src/components/TranslationJobs.tsx b/src/components/TranslationJobs.tsx index e4dbda6..7338722 100644 --- a/src/components/TranslationJobs.tsx +++ b/src/components/TranslationJobs.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef } from 'react'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { AlertCircle, CheckCircle2, Clock, Loader2, RotateCw } from 'lucide-react'; +import { AlertCircle, CheckCircle2, Clock, Loader2, RotateCw, X } from 'lucide-react'; import * as api from '../lib/api'; import type { TranslationJob } from '../types'; @@ -31,6 +31,26 @@ function JobProgress({ job }: { job: TranslationJob }) { ); } +function DismissButton({ job, className }: { job: TranslationJob; className: string }) { + const queryClient = useQueryClient(); + const dismissMutation = useMutation({ + mutationFn: () => api.dismissJob(job.id), + onSettled: () => queryClient.invalidateQueries({ queryKey: ['jobs'] }), + }); + + return ( + + ); +} + function JobItem({ job }: { job: TranslationJob }) { const queryClient = useQueryClient(); const retryMutation = useMutation({ @@ -57,7 +77,8 @@ function JobItem({ job }: { job: TranslationJob }) { if (job.status === 'done') { return ( -
+
+
Translation Complete!
@@ -70,7 +91,8 @@ function JobItem({ job }: { job: TranslationJob }) { } return ( -
+
+
Translation Failed
@@ -108,7 +130,8 @@ function JobItem({ job }: { job: TranslationJob }) { /** * Lists translation jobs kept by the server, so progress survives page reloads. - * Polls only while a job is queued or running. + * Polls only while a job is queued or running. Completed jobs expire on the + * server after a day; finished jobs can also be dismissed here. */ export function TranslationJobs() { const queryClient = useQueryClient(); @@ -119,6 +142,11 @@ export function TranslationJobs() { }); // Refresh API usage whenever a job finishes + const clearMutation = useMutation({ + mutationFn: api.clearFinishedJobs, + onSettled: () => queryClient.invalidateQueries({ queryKey: ['jobs'] }), + }); + const activeCount = jobs?.filter(isActive).length ?? 0; const previousActive = useRef(activeCount); useEffect(() => { @@ -134,8 +162,21 @@ export function TranslationJobs() { if (!jobs?.length) return null; + const finishedCount = jobs.length - activeCount; + return (
+ {finishedCount > 0 && ( +
+ +
+ )} {jobs.slice(0, 5).map(job => )}
); diff --git a/src/lib/api.ts b/src/lib/api.ts index 34faaa0..6dd6b2f 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -119,6 +119,16 @@ export const retryJob = async (id: string): Promise => { return data; }; +/** Removes a finished (done or failed) job from the list. */ +export const dismissJob = async (id: string): Promise => { + await api.delete(`/jobs/${id}`); +}; + +/** Removes every finished (done or failed) job; active jobs stay. */ +export const clearFinishedJobs = async (): Promise => { + await api.delete('/jobs'); +}; + export const getJobs = async (): Promise => { const { data } = await api.get('/jobs'); return data; diff --git a/test/jobs.test.js b/test/jobs.test.js index 3d4443b..94d269a 100644 --- a/test/jobs.test.js +++ b/test/jobs.test.js @@ -5,7 +5,7 @@ import { mockAxiosPost, httpError, deeplResponse, makeTempDir, writeSRT, waitFor delete process.env.TRANSLATION_PROVIDER; process.env.DEEPL_API_KEY = 'test-key'; -const { createTranslationJob, retryJob, getJob, listJobs } = await import('../server/services/jobs.js'); +const { createTranslationJob, retryJob, getJob, listJobs, dismissJob, clearFinishedJobs } = await import('../server/services/jobs.js'); const dir = makeTempDir(); @@ -99,3 +99,55 @@ test('prunes completed jobs before failed ones', async () => { assert.ok(list.some(job => job.id === failed.id), 'the failed job survives pruning'); assert.equal(list[0].file, 'bulk-24.en.srt', 'most recent first'); }); + +test('completed jobs expire after a day, failed ones stay', async (t) => { + clearFinishedJobs(); + let failing = true; + mockAxiosPost((url, body) => { + if (failing) throw httpError(456, { message: 'Quota exceeded' }); + return deeplResponse(body); + }); + const failed = startJob(newFile('expire-failed')); + await waitFor(() => isFinished(failed.id)); + failing = false; + const done = startJob(newFile('expire-done')); + await waitFor(() => isFinished(done.id)); + + const realNow = Date.now(); + t.mock.method(Date, 'now', () => realNow + 23 * 60 * 60 * 1000); + assert.ok(getJob(done.id), 'still listed before 24 hours'); + + t.mock.method(Date, 'now', () => realNow + 25 * 60 * 60 * 1000); + assert.equal(getJob(done.id), null); + assert.deepEqual(listJobs().map(job => job.id), [failed.id]); +}); + +test('dismisses finished jobs but not active ones', async () => { + clearFinishedJobs(); + let release; + const blocked = new Promise(resolve => { release = resolve; }); + mockAxiosPost(async (url, body) => { + await blocked; + return deeplResponse(body); + }); + const job = startJob(newFile('dismiss')); + + assert.throws(() => dismissJob(job.id), { status: 409 }); + assert.equal(clearFinishedJobs(), 0, 'active jobs are not cleared'); + + release(); + await waitFor(() => isFinished(job.id)); + dismissJob(job.id); + assert.equal(getJob(job.id), null); + assert.throws(() => dismissJob(job.id), { status: 404 }); +}); + +test('clears every finished job', async () => { + clearFinishedJobs(); + mockAxiosPost((url, body) => deeplResponse(body)); + const jobs = [startJob(newFile('clear-1')), startJob(newFile('clear-2'))]; + await waitFor(() => jobs.every(job => isFinished(job.id))); + + assert.equal(clearFinishedJobs(), 2); + assert.deepEqual(listJobs(), []); +}); diff --git a/test/routes.test.js b/test/routes.test.js index 036ff5d..9225460 100644 --- a/test/routes.test.js +++ b/test/routes.test.js @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import fs from 'fs'; import path from 'path'; import express from 'express'; -import { mockAxiosPost, deeplResponse, makeTempDir, writeSRT } from './helpers.js'; +import { mockAxiosPost, deeplResponse, makeTempDir, writeSRT, sleep } from './helpers.js'; // paths.js reads the media directories at import time const dataDir = makeTempDir(); @@ -86,3 +86,20 @@ test('rejects path traversal in extract_subtitles', async () => { assert.equal(response.status, 400); assert.match(response.body.message, /Invalid video path/); }); + +test('dismisses a job and clears finished jobs', async () => { + mockAxiosPost((url, body) => deeplResponse(body)); + const { body: job } = await post('/translate_subtitle', { ...valid, target_lang: 'IT' }); + while ((await (await fetch(`${baseUrl}/jobs/${job.id}`)).json()).status !== 'done') { + await sleep(10); + } + + const dismissed = await fetch(`${baseUrl}/jobs/${job.id}`, { method: 'DELETE' }); + assert.equal(dismissed.status, 204); + assert.equal((await fetch(`${baseUrl}/jobs/${job.id}`)).status, 404); + assert.equal((await fetch(`${baseUrl}/jobs/${job.id}`, { method: 'DELETE' })).status, 404); + + const cleared = await (await fetch(`${baseUrl}/jobs`, { method: 'DELETE' })).json(); + assert.equal(typeof cleared.removed, 'number'); + assert.deepEqual(await (await fetch(`${baseUrl}/jobs`)).json(), []); +});