From 592712e71fb046330bbeabed7c62a3be002f068c Mon Sep 17 00:00:00 2001 From: Joao Vilaca Date: Tue, 7 Jul 2026 11:17:18 +0200 Subject: [PATCH 1/4] Fix location.reload error and opencv mock warning --- application/ui/rsbuild.config.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/ui/rsbuild.config.ts b/application/ui/rsbuild.config.ts index 848c3ebf25..1eb50aab4f 100644 --- a/application/ui/rsbuild.config.ts +++ b/application/ui/rsbuild.config.ts @@ -135,7 +135,11 @@ export default defineConfig({ headers: { 'Cross-Origin-Embedder-Policy': 'credentialless', 'Cross-Origin-Opener-Policy': 'same-origin', - 'Cache-Control': 'public, max-age=31536000, immutable', + // Must NOT be 'immutable': dev async chunks are not content-hashed, so an + // immutable cache causes the browser to keep serving stale chunk/HMR runtime + // URLs after a rebuild (stale worker imports, mismatched hmr.js client). See + // /memories/repo/dev-server-immutable-cache-stale-worker.md. + 'Cache-Control': 'no-cache', 'Content-Security-Policy': "default-src 'self'; " + "script-src 'self' 'unsafe-eval' blob:; " + From aa1dfd76ab9a6d62a9594a46757bed49767d2fba Mon Sep 17 00:00:00 2001 From: Joao Vilaca Date: Tue, 7 Jul 2026 11:34:03 +0200 Subject: [PATCH 2/4] Fix webworker loading issue on rsbuild v2 --- application/ui/rsbuild.config.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/ui/rsbuild.config.ts b/application/ui/rsbuild.config.ts index 1eb50aab4f..57d125e1ea 100644 --- a/application/ui/rsbuild.config.ts +++ b/application/ui/rsbuild.config.ts @@ -128,6 +128,28 @@ export default defineConfig({ ...config, resolve: { ...config.resolve, extensions }, watchOptions: { ...config.watchOptions, ignored: ['**/src-tauri/**'] }, + // opencv.js (emscripten, under src/ so it's parsed) references + // `__dirname` for Node environment detection. Rspack's default + // `warn-mock` mocks it to '/' AND warns on every build. In the + // browser opencv takes the non-Node code path, so the mock value + // is never used — switch to 'mock' to keep the (identical) runtime + // behavior without the noisy build warning. + node: { ...config.node, __dirname: 'mock', __filename: 'mock' }, + optimization: { + ...config.optimization, + // Force deterministic (numeric) chunk IDs in dev too. Rspack's + // dev default is `chunkIds: 'named'`, which makes our module + // web workers (SAM / intelligent-scissors / SSIM) request a + // shared async vendor chunk by a long derived name + // (`vendors-node_modules_onnxruntime-web…polylabel_js.js`) that + // is never emitted under that name -> the dev server's SPA + // fallback returns index.html -> the worker's importScripts + // fails with "MIME type ('text/html') is not executable". + // Production already uses deterministic IDs (numeric chunks), + // which is why `npm run build` is unaffected. Matching dev to + // production keeps the worker chunk names consistent. + chunkIds: 'deterministic', + }, }; }, }, From b0381eaa8268e7357844f5a13cd26cda72947dfd Mon Sep 17 00:00:00 2001 From: Joao Vilaca Date: Tue, 7 Jul 2026 11:49:24 +0200 Subject: [PATCH 3/4] Revert optimization part --- application/ui/rsbuild.config.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/application/ui/rsbuild.config.ts b/application/ui/rsbuild.config.ts index 57d125e1ea..46f043c3c3 100644 --- a/application/ui/rsbuild.config.ts +++ b/application/ui/rsbuild.config.ts @@ -135,21 +135,6 @@ export default defineConfig({ // is never used — switch to 'mock' to keep the (identical) runtime // behavior without the noisy build warning. node: { ...config.node, __dirname: 'mock', __filename: 'mock' }, - optimization: { - ...config.optimization, - // Force deterministic (numeric) chunk IDs in dev too. Rspack's - // dev default is `chunkIds: 'named'`, which makes our module - // web workers (SAM / intelligent-scissors / SSIM) request a - // shared async vendor chunk by a long derived name - // (`vendors-node_modules_onnxruntime-web…polylabel_js.js`) that - // is never emitted under that name -> the dev server's SPA - // fallback returns index.html -> the worker's importScripts - // fails with "MIME type ('text/html') is not executable". - // Production already uses deterministic IDs (numeric chunks), - // which is why `npm run build` is unaffected. Matching dev to - // production keeps the worker chunk names consistent. - chunkIds: 'deterministic', - }, }; }, }, From 9ce22d9240ac73da76fae1eb55f57e0abfa217bb Mon Sep 17 00:00:00 2001 From: Joao Vilaca Date: Tue, 7 Jul 2026 11:50:16 +0200 Subject: [PATCH 4/4] Revert llm leftover --- application/ui/rsbuild.config.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/ui/rsbuild.config.ts b/application/ui/rsbuild.config.ts index 46f043c3c3..fc0e0f786e 100644 --- a/application/ui/rsbuild.config.ts +++ b/application/ui/rsbuild.config.ts @@ -144,8 +144,7 @@ export default defineConfig({ 'Cross-Origin-Opener-Policy': 'same-origin', // Must NOT be 'immutable': dev async chunks are not content-hashed, so an // immutable cache causes the browser to keep serving stale chunk/HMR runtime - // URLs after a rebuild (stale worker imports, mismatched hmr.js client). See - // /memories/repo/dev-server-immutable-cache-stale-worker.md. + // URLs after a rebuild (stale worker imports, mismatched hmr.js client). 'Cache-Control': 'no-cache', 'Content-Security-Policy': "default-src 'self'; " +