Suno-style web UI for a self-hosted MiniMax-Music3 inference server
TypeScript ai-musicdiffusersdockerexpressminimaxminimax-musicmusic-generationreactself-hostedsgl-omnisunotailwindcsstext-to-musictypescriptvite
Add browserless web test suite
Adam B.d2cc4892d035
diff --git a/README.md b/README.mdindex 96fd813..dbb3940 100644--- a/README.md+++ b/README.md@@ -134,7 +134,7 @@ The inference server address is resolved in this order:```bashnpm run dev # server on :8787 (tsx watch) + Vite on :5173 with /api proxiednpm run dev:fake # same, plus a fake inference API on :7999 — no GPU needed-npm test # server tests (vitest) against the fake upstream+npm test # server tests against the fake upstream and web testsnpm run typecheck # both packages```diff --git a/package-lock.json b/package-lock.jsonindex 60e63fe..e47e21a 100644--- a/package-lock.json+++ b/package-lock.json@@ -20,6 +20,59 @@"typescript-eslint": "^8.72.0"}},+ "node_modules/@asamuzakjp/css-color": {+ "version": "7.1.7",+ "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.7.tgz",+ "integrity": "sha512-Q7ioeear07HwixdIitIn9KS1LZi97CEDFCSjPNm9v+y8KNbsu9q4Lrd4zUQW4faED+E7qxvfeVnbNRW46wFKuw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@csstools/css-calc": "^3.4.3",+ "@csstools/css-color-parser": "^4.2.6",+ "@csstools/css-parser-algorithms": "^4.0.2",+ "@csstools/css-tokenizer": "^4.0.2",+ "lru-cache": "^11.5.3"+ },+ "engines": {+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"+ }+ },+ "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": {+ "version": "11.5.3",+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",+ "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",+ "dev": true,+ "license": "BlueOak-1.0.0",+ "engines": {+ "node": "20 || >=22"+ }+ },+ "node_modules/@asamuzakjp/dom-selector": {+ "version": "10.0.5",+ "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-10.0.5.tgz",+ "integrity": "sha512-EgmJ7oEaGQECTn3H3wmnQpEy4hKY66VvM7VQndwPIQob3p877BgbyOUE3EX0LgXQCciF2H8KMdR+RznqjMNOLw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "bidi-js": "^1.1.0",+ "css-tree": "^3.2.1",+ "is-potential-custom-element-name": "^1.0.1",+ "lru-cache": "^11.5.3"+ },+ "engines": {+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"+ }+ },+ "node_modules/@asamuzakjp/dom-selector/node_modules/lru-cache": {+ "version": "11.5.3",+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",+ "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",+ "dev": true,+ "license": "BlueOak-1.0.0",+ "engines": {+ "node": "20 || >=22"+ }+ },"node_modules/@babel/code-frame": {"version": "7.29.7","resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",@@ -260,6 +313,19 @@"node": ">=6.9.0"}},+ "node_modules/@bramus/specificity": {+ "version": "2.4.3",+ "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz",+ "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "css-tree": "^3.2.1"+ },+ "bin": {+ "specificity": "bin/cli.js"+ }+ },"node_modules/@cacheable/memory": {"version": "2.2.0","resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz",@@ -284,6 +350,146 @@"keyv": "^5.6.0"}},+ "node_modules/@csstools/color-helpers": {+ "version": "6.1.2",+ "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz",+ "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT-0",+ "engines": {+ "node": ">=20.19.0"+ }+ },+ "node_modules/@csstools/css-calc": {+ "version": "3.4.3",+ "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz",+ "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-parser-algorithms": "^4.0.2",+ "@csstools/css-tokenizer": "^4.0.2"+ }+ },+ "node_modules/@csstools/css-color-parser": {+ "version": "4.2.6",+ "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.6.tgz",+ "integrity": "sha512-iiPQ3iRWwnJkeEn6RIu6SJPr7hYrLz6XZ9s/QZl+2/LI5KQVjpl2fdmDSZKuD4xP6GMmMPgHFFXg6k1Wkz0Trg==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "@csstools/color-helpers": "^6.1.2",+ "@csstools/css-calc": "^3.4.3"+ },+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-parser-algorithms": "^4.0.2",+ "@csstools/css-tokenizer": "^4.0.2"+ }+ },+ "node_modules/@csstools/css-parser-algorithms": {+ "version": "4.0.2",+ "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz",+ "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-tokenizer": "^4.0.2"+ }+ },+ "node_modules/@csstools/css-syntax-patches-for-csstree": {+ "version": "1.1.15",+ "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.15.tgz",+ "integrity": "sha512-J0u7HkVl2nzSlhsiTOp4AmwcUQ3D+mGEEKfBy/7To5/y7F2OHwyLrXfrhR0SMgr4p5Lo+eaMVSeai24zUcBIxA==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT-0",+ "peerDependencies": {+ "css-tree": "^3.2.1"+ },+ "peerDependenciesMeta": {+ "css-tree": {+ "optional": true+ }+ }+ },+ "node_modules/@csstools/css-tokenizer": {+ "version": "4.0.2",+ "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz",+ "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ }+ },"node_modules/@esbuild/aix-ppc64": {"version": "0.28.2","resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",@@ -854,6 +1060,24 @@"node": "^20.19.0 || ^22.13.0 || >=24"}},+ "node_modules/@exodus/bytes": {+ "version": "1.16.0",+ "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz",+ "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"+ },+ "peerDependencies": {+ "@noble/hashes": "^1.8.0 || ^2.0.0"+ },+ "peerDependenciesMeta": {+ "@noble/hashes": {+ "optional": true+ }+ }+ },"node_modules/@humanfs/core": {"version": "0.19.2","resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",@@ -2596,6 +2820,16 @@"node": ">=6.0.0"}},+ "node_modules/bidi-js": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz",+ "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "require-from-string": "^2.0.2"+ }+ },"node_modules/body-parser": {"version": "2.3.0","resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",@@ -2908,6 +3142,20 @@"node": ">= 8"}},+ "node_modules/css-tree": {+ "version": "3.2.1",+ "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz",+ "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "mdn-data": "2.27.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"+ }+ },"node_modules/csstype": {"version": "3.2.3","resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",@@ -2915,6 +3163,20 @@"dev": true,"license": "MIT"},+ "node_modules/data-urls": {+ "version": "8.0.0",+ "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz",+ "integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "whatwg-mimetype": "^5.0.0",+ "whatwg-url": "^17.1.2"+ },+ "engines": {+ "node": "^22.14.0 || >=24.0.0"+ }+ },"node_modules/debug": {"version": "4.4.3","resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",@@ -2932,6 +3194,13 @@}}},+ "node_modules/decimal.js": {+ "version": "10.6.0",+ "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",+ "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",+ "dev": true,+ "license": "MIT"+ },"node_modules/deep-is": {"version": "0.1.4","resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",@@ -3036,6 +3305,19 @@"node": ">=10.13.0"}},+ "node_modules/entities": {+ "version": "8.1.0",+ "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz",+ "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==",+ "dev": true,+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=20.19.0"+ },+ "funding": {+ "url": "https://github.com/fb55/entities?sponsor=1"+ }+ },"node_modules/es-define-property": {"version": "1.0.1","resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",@@ -3799,6 +4081,19 @@"dev": true,"license": "MIT"},+ "node_modules/html-encoding-sniffer": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz",+ "integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@exodus/bytes": "^1.15.1"+ },+ "engines": {+ "node": "^22.13.0 || >=24.0.0"+ }+ },"node_modules/http-errors": {"version": "2.0.1","resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",@@ -3893,6 +4188,13 @@"node": ">=0.10.0"}},+ "node_modules/is-potential-custom-element-name": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",+ "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",+ "dev": true,+ "license": "MIT"+ },"node_modules/is-promise": {"version": "4.0.0","resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",@@ -3923,6 +4225,56 @@"dev": true,"license": "MIT"},+ "node_modules/jsdom": {+ "version": "30.1.3",+ "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.3.tgz",+ "integrity": "sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@asamuzakjp/css-color": "^7.1.3",+ "@asamuzakjp/dom-selector": "^10.0.3",+ "@bramus/specificity": "^2.4.2",+ "@csstools/css-syntax-patches-for-csstree": "^1.1.15",+ "@exodus/bytes": "^1.16.0",+ "css-tree": "^3.2.1",+ "data-urls": "^8.0.0",+ "decimal.js": "^10.6.0",+ "html-encoding-sniffer": "^7.0.0",+ "is-potential-custom-element-name": "^1.0.1",+ "lru-cache": "^11.5.3",+ "parse5": "^8.0.1",+ "saxes": "^6.0.0",+ "tough-cookie": "^6.0.2",+ "undici": "^8.12.1",+ "w3c-xmlserializer": "^6.0.0",+ "webidl-conversions": "^8.0.1",+ "whatwg-mimetype": "^5.0.0",+ "whatwg-url": "^17.2.0",+ "xml-name-validator": "^5.0.0"+ },+ "engines": {+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"+ },+ "peerDependencies": {+ "canvas": "^3.2.3"+ },+ "peerDependenciesMeta": {+ "canvas": {+ "optional": true+ }+ }+ },+ "node_modules/jsdom/node_modules/lru-cache": {+ "version": "11.5.3",+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",+ "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",+ "dev": true,+ "license": "BlueOak-1.0.0",+ "engines": {+ "node": "20 || >=22"+ }+ },"node_modules/jsesc": {"version": "3.1.0","resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",@@ -4305,6 +4657,13 @@"node": ">= 0.4"}},+ "node_modules/mdn-data": {+ "version": "2.27.1",+ "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz",+ "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==",+ "dev": true,+ "license": "CC0-1.0"+ },"node_modules/media-typer": {"version": "1.1.1","resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz",@@ -4562,6 +4921,19 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/parse5": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz",+ "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "entities": "^8.0.0"+ },+ "funding": {+ "url": "https://github.com/inikulin/parse5?sponsor=1"+ }+ },"node_modules/parseurl": {"version": "1.3.3","resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",@@ -4772,6 +5144,16 @@"react": "^19.3.0"}},+ "node_modules/require-from-string": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },"node_modules/rolldown": {"version": "1.2.11","resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.11.tgz",@@ -4838,6 +5220,19 @@"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==","license": "MIT"},+ "node_modules/saxes": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",+ "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",+ "dev": true,+ "license": "ISC",+ "dependencies": {+ "xmlchars": "^2.2.0"+ },+ "engines": {+ "node": ">=v12.22.7"+ }+ },"node_modules/scheduler": {"version": "0.28.0","resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz",@@ -5180,6 +5575,26 @@"url": "https://github.com/sponsors/SuperchupuDev"}},+ "node_modules/tldts": {+ "version": "7.4.19",+ "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz",+ "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "tldts-core": "^7.4.19"+ },+ "bin": {+ "tldts": "bin/cli.js"+ }+ },+ "node_modules/tldts-core": {+ "version": "7.4.19",+ "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.19.tgz",+ "integrity": "sha512-goNXV6Ho9TIOfpJZanTd6CKG5DyYgYAL+k+22T0SLh8l6+KHIfBUPFuePuSZv05UttIaaLmI9tb7TmGIdK5AkQ==",+ "dev": true,+ "license": "MIT"+ },"node_modules/toidentifier": {"version": "1.0.1","resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",@@ -5189,6 +5604,32 @@"node": ">=0.6"}},+ "node_modules/tough-cookie": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",+ "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==",+ "dev": true,+ "license": "BSD-3-Clause",+ "dependencies": {+ "tldts": "^7.0.5"+ },+ "engines": {+ "node": ">=16"+ }+ },+ "node_modules/tr46": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz",+ "integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "punycode": "^2.3.1"+ },+ "engines": {+ "node": "^22.14.0 || >=24.0.0"+ }+ },"node_modules/tree-kill": {"version": "1.2.2","resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",@@ -5320,6 +5761,16 @@"typescript": ">=4.8.4 <6.1.0"}},+ "node_modules/undici": {+ "version": "8.12.3",+ "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz",+ "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=22.19.0"+ }+ },"node_modules/undici-types": {"version": "8.9.0","resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",@@ -5830,6 +6281,54 @@"@jridgewell/sourcemap-codec": "^1.6.0"}},+ "node_modules/w3c-xmlserializer": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",+ "integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "xml-name-validator": "^5.0.0"+ },+ "engines": {+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"+ }+ },+ "node_modules/webidl-conversions": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",+ "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==",+ "dev": true,+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/whatwg-mimetype": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",+ "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/whatwg-url": {+ "version": "17.3.0",+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz",+ "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@exodus/bytes": "^1.16.0",+ "tr46": "^7.0.0",+ "webidl-conversions": "^8.0.1"+ },+ "engines": {+ "node": "^22.14.0 || >=24.0.0"+ }+ },"node_modules/which": {"version": "2.0.2","resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",@@ -5893,6 +6392,23 @@"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==","license": "ISC"},+ "node_modules/xml-name-validator": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",+ "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/xmlchars": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",+ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/y18n": {"version": "5.0.8","resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",@@ -6047,9 +6563,11 @@"@types/react": "^19.2.14","@types/react-dom": "^19.2.3","@vitejs/plugin-react": "^6.0.5",+ "jsdom": "^30.1.3","tailwindcss": "^4.3.3","typescript": "^7.0.2",- "vite": "^8.2.1"+ "vite": "^8.2.1",+ "vitest": "^5.0.2"}},"web/node_modules/typescript": {diff --git a/package.json b/package.jsonindex 4074017..9d970aa 100644--- a/package.json+++ b/package.json@@ -11,7 +11,7 @@"dev:fake": "concurrently -k -n fake,server,web -c yellow,blue,magenta \"npm run fake -w server\" \"MUSIC_API=http://127.0.0.1:7999 npm run dev -w server\" \"npm run dev -w web\"","build": "npm run build -w server && npm run build -w web","start": "npm run start -w server",- "test": "npm test -w server",+ "test": "npm test -w server && npm test -w web","lint": "eslint \"server/**/*.{ts,tsx}\" \"web/**/*.{ts,tsx}\" && node scripts/check-lint-fixtures.mjs","typecheck": "npm run typecheck -w server && npm run typecheck -w web"},diff --git a/web/package.json b/web/package.jsonindex 35661e6..85c10bc 100644--- a/web/package.json+++ b/web/package.json@@ -6,6 +6,7 @@"scripts": {"dev": "vite","build": "tsc -p tsconfig.json --noEmit && vite build",+ "test": "vitest run --config vitest.config.ts","preview": "vite preview","typecheck": "tsc -p tsconfig.json --noEmit"},@@ -18,8 +19,10 @@"@types/react": "^19.2.14","@types/react-dom": "^19.2.3","@vitejs/plugin-react": "^6.0.5",+ "jsdom": "^30.1.3","tailwindcss": "^4.3.3","typescript": "^7.0.2",- "vite": "^8.2.1"+ "vite": "^8.2.1",+ "vitest": "^5.0.2"}}diff --git a/web/test/stage.test.ts b/web/test/stage.test.tsnew file mode 100644index 0000000..7b0a6a3--- /dev/null+++ b/web/test/stage.test.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from 'vitest';+import { parseStage, phasesFor, phaseIndex } from '../src/lib/stage';++describe('parseStage', () => {+ it.each(['semantic', 'denoise', 'download', 'mystery', ''])('keeps queued tracks queued regardless of stage (%s)', (stage) => {+ expect(parseStage(stage, 'queued', null)).toMatchObject({ phase: 'queued', real: false });+ });++ it('normalizes a semantic stage while running', () => {+ expect(parseStage(' SEMANTIC ', 'running', null)).toMatchObject({ phase: 'semantic', real: true });+ });++ it.each([null, 0])('labels a denoise stage without rendered audio (%s seconds)', (renderedSeconds) => {+ expect(parseStage('denoise', 'running', renderedSeconds)).toEqual({+ phase: 'denoise',+ label: 'Rendering audio',+ real: true,+ });+ });++ it('labels a denoise stage with rendered audio', () => {+ expect(parseStage('denoise', 'running', 1)).toEqual({+ phase: 'denoise',+ label: 'Rendering — you can listen now',+ real: true,+ });+ });++ it('classifies any stage containing download as a download phase', () => {+ expect(parseStage('upstream download complete', 'running', null)).toMatchObject({+ phase: 'download',+ real: false,+ });+ });++ it.each(['mystery', ''])('estimates denoise for an unknown stage (%s)', (stage) => {+ expect(parseStage(stage, 'running', null)).toMatchObject({ phase: 'denoise', real: false });+ });+});++describe('phasesFor', () => {+ it('omits semantic from estimated renders', () => {+ expect(phasesFor(false).map(({ id }) => id)).toEqual(['queued', 'denoise', 'download']);+ });++ it('returns -1 for a phase omitted from an estimated render', () => {+ expect(phaseIndex(phasesFor(false), 'semantic')).toBe(-1);+ });+});diff --git a/web/test/usePolling.test.ts b/web/test/usePolling.test.tsnew file mode 100644index 0000000..906e8d8--- /dev/null+++ b/web/test/usePolling.test.ts@@ -0,0 +1,245 @@+import { act, createElement, type ReactNode } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { api } from '../src/api';+import { useHealth, useLibrary } from '../src/hooks/usePolling';+import type { Health, Track } from '../src/types';++const lifecycle = vi.hoisted(() => ({+ watchUnmountedState: false,+ updatesAfterUnmount: 0,+}));++vi.mock('react', async (importOriginal) => {+ const actual = await importOriginal<typeof import('react')>();+ return {+ ...actual,+ useState: <State>(initialState: State | (() => State)) => {+ const [value, setValue] = actual.useState(initialState);+ const trackedSetValue: typeof setValue = (next) => {+ if (lifecycle.watchUnmountedState) lifecycle.updatesAfterUnmount += 1;+ setValue(next);+ };+ return [value, trackedSetValue] as const;+ },+ };+});++Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });++const doneTrack = (): Track => ({+ id: 'track-1',+ groupId: 'group-1',+ takeIndex: 0,+ title: 'Track',+ prompt: 'A song',+ lyrics: '',+ duration: 60,+ seed: null,+ format: 'wav',+ status: 'done',+ progress: 1,+ stage: 'done',+ eta: null,+ stream: false,+ renderedSeconds: null,+ error: null,+ file: null,+ createdAt: '2026-01-01T00:00:00.000Z',+ finishedAt: '2026-01-01T00:01:00.000Z',+});++const runningTrack = (): Track => ({ ...doneTrack(), status: 'running', stage: 'denoise', progress: 0.5, finishedAt: null });++let libraryState: ReturnType<typeof useLibrary>;+let healthState: ReturnType<typeof useHealth>;++function LibraryHarness() {+ libraryState = useLibrary();+ return null;+}++function HealthHarness({ intervalMs }: { intervalMs?: number }) {+ healthState = useHealth(intervalMs);+ return null;+}++const mountedRoots: { root: Root; mounted: boolean }[] = [];++async function mount(element: ReactNode) {+ const root = createRoot(document.createElement('div'));+ const mountState = { root, mounted: true };+ mountedRoots.push(mountState);+ await act(async () => {+ root.render(element);+ await Promise.resolve();+ await Promise.resolve();+ });++ return {+ unmount() {+ if (!mountState.mounted) return;+ act(() => root.unmount());+ mountState.mounted = false;+ lifecycle.watchUnmountedState = true;+ },+ };+}++async function advanceTimersBy(ms: number) {+ await act(async () => {+ await vi.advanceTimersByTimeAsync(ms);+ });+}++afterEach(() => {+ for (const mountState of mountedRoots.splice(0)) {+ if (mountState.mounted) act(() => mountState.root.unmount());+ }+ vi.useRealTimers();+ vi.restoreAllMocks();+ lifecycle.watchUnmountedState = false;+ lifecycle.updatesAfterUnmount = 0;+ libraryState = undefined as unknown as ReturnType<typeof useLibrary>;+ healthState = null;+});++beforeEach(() => {+ vi.useFakeTimers();+});++describe('useLibrary', () => {+ it('fetches the library once on mount', async () => {+ const tracks = [doneTrack()];+ const library = vi.spyOn(api, 'library').mockResolvedValue(tracks);++ await mount(createElement(LibraryHarness));++ expect(library).toHaveBeenCalledTimes(1);+ expect(libraryState).toMatchObject({ tracks, error: null });+ });++ it('refetches after one second while a track is in flight', async () => {+ const library = vi.spyOn(api, 'library').mockResolvedValue([runningTrack()]);++ await mount(createElement(LibraryHarness));+ await advanceTimersBy(999);+ expect(library).toHaveBeenCalledTimes(1);++ await advanceTimersBy(1);+ expect(library).toHaveBeenCalledTimes(2);+ });++ it('refetches after ten seconds when no track is in flight', async () => {+ const library = vi.spyOn(api, 'library').mockResolvedValue([doneTrack()]);++ await mount(createElement(LibraryHarness));+ await advanceTimersBy(9999);+ expect(library).toHaveBeenCalledTimes(1);++ await advanceTimersBy(1);+ expect(library).toHaveBeenCalledTimes(2);+ });++ it('exposes a failed fetch and clears the error after the next success', async () => {+ const tracks = [doneTrack()];+ const library = vi.spyOn(api, 'library')+ .mockRejectedValueOnce(new Error('network unavailable'))+ .mockResolvedValueOnce(tracks);++ await mount(createElement(LibraryHarness));+ expect(libraryState.error).toBe('network unavailable');+ await advanceTimersBy(4999);+ expect(library).toHaveBeenCalledTimes(1);+ await advanceTimersBy(1);++ expect(library).toHaveBeenCalledTimes(2);+ expect(libraryState).toMatchObject({ tracks, error: null });+ });++ it('refreshes immediately and replaces the pending timer', async () => {+ const library = vi.spyOn(api, 'library').mockResolvedValue([doneTrack()]);++ await mount(createElement(LibraryHarness));+ await advanceTimersBy(4000);+ await act(async () => libraryState.refresh());++ expect(library).toHaveBeenCalledTimes(2);+ await advanceTimersBy(9999);+ expect(library).toHaveBeenCalledTimes(2);+ await advanceTimersBy(1);+ expect(library).toHaveBeenCalledTimes(3);+ });++ it('does not fetch or update state after unmount', async () => {+ let resolvePending!: (tracks: Track[]) => void;+ const library = vi.spyOn(api, 'library')+ .mockResolvedValueOnce([doneTrack()])+ .mockImplementationOnce(() => new Promise((resolve) => { resolvePending = resolve; }));++ const mounted = await mount(createElement(LibraryHarness));+ await advanceTimersBy(10000);+ expect(library).toHaveBeenCalledTimes(2);+ mounted.unmount();++ await act(async () => {+ resolvePending([doneTrack()]);+ await Promise.resolve();+ await Promise.resolve();+ });+ await advanceTimersBy(10000);++ expect(library).toHaveBeenCalledTimes(2);+ expect(lifecycle.updatesAfterUnmount).toBe(0);+ });++ it('does not poll after unmount with a pending timer', async () => {+ const library = vi.spyOn(api, 'library').mockResolvedValue([doneTrack()]);++ const mounted = await mount(createElement(LibraryHarness));+ expect(library).toHaveBeenCalledTimes(1);+ mounted.unmount();++ await advanceTimersBy(10000);++ expect(library).toHaveBeenCalledTimes(1);+ expect(lifecycle.updatesAfterUnmount).toBe(0);+ });+});++describe('useHealth', () => {+ const onlineHealth: Health = {+ upstreamReachable: true,+ ready: true,+ busy: false,+ queued: 0,+ formats: ['wav'],+ };++ it('fetches on mount and every polling interval', async () => {+ const health = vi.spyOn(api, 'health').mockResolvedValue(onlineHealth);++ await mount(createElement(HealthHarness, { intervalMs: 5000 }));+ expect(health).toHaveBeenCalledTimes(1);+ await advanceTimersBy(4999);+ expect(health).toHaveBeenCalledTimes(1);+ await advanceTimersBy(1);+ expect(health).toHaveBeenCalledTimes(2);+ expect(healthState).toEqual(onlineHealth);+ });++ it('uses offline health when a health call fails', async () => {+ vi.spyOn(api, 'health').mockRejectedValue(new Error('offline'));++ await mount(createElement(HealthHarness, { intervalMs: 5000 }));++ expect(healthState).toEqual({+ upstreamReachable: false,+ ready: false,+ busy: false,+ queued: 0,+ formats: ['wav'],+ error: 'ui server unreachable',+ });+ });+});diff --git a/web/tsconfig.json b/web/tsconfig.jsonindex 69c5531..9034d80 100644--- a/web/tsconfig.json+++ b/web/tsconfig.json@@ -14,5 +14,5 @@"noEmit": true,"types": ["vite/client"]},- "include": ["src"]+ "include": ["src", "test"]}diff --git a/web/vitest.config.ts b/web/vitest.config.tsnew file mode 100644index 0000000..a44e73c--- /dev/null+++ b/web/vitest.config.ts@@ -0,0 +1,8 @@+import { defineConfig } from 'vitest/config';++export default defineConfig({+ test: {+ environment: 'jsdom',+ include: ['test/**/*.test.ts'],+ },+});