From 0172253b4d99a3a0541bf75d65335602675a8483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 30 Sep 2026 11:31:07 +0200 Subject: [PATCH] Put invoke timing logs behind VITE_LOG_INVOKE_TIMINGS They flooded the dev console and test logs; perf work can turn them on. --- CLAUDE.md | 3 +++ README.md | 8 ++++++++ src/lib/invoke.ts | 2 +- src/vite-env.d.ts | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 092dec1f6..9843091be 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -28,6 +28,9 @@ npm run tauri dev # full Tauri dev build with hot reload npm run start:http # Vite dev server backed by test-http-api (no Tauri runtime) ``` +Set `VITE_LOG_INVOKE_TIMINGS=true` to log each command's duration +(`[invoke] ms`) to the browser console. It is off by default. + ### Checks and linting (tsc, svelte-check, eslint, prettier) ```sh diff --git a/README.md b/README.md index 7cbfa1ca0..041809db7 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,14 @@ To start the app in development mode with hot reload: npm run dev ``` +To log how long every backend command takes, for performance work, set +`VITE_LOG_INVOKE_TIMINGS=true`. Each call then prints `[invoke] ms` +to the browser console (visible at debug level): + +``` +VITE_LOG_INVOKE_TIMINGS=true npm run dev +``` + ## Releasing Releases are driven by an interactive, phased script. Start one with: diff --git a/src/lib/invoke.ts b/src/lib/invoke.ts index bc0dffde4..8e6caa6c9 100644 --- a/src/lib/invoke.ts +++ b/src/lib/invoke.ts @@ -16,7 +16,7 @@ export async function invoke( args?: tauri.InvokeArgs, options?: tauri.InvokeOptions, ): Promise { - if (import.meta.env.DEV) { + if (import.meta.env.VITE_LOG_INVOKE_TIMINGS === "true") { const start = performance.now(); try { return await withTestBackend(tauri.invoke, cmd, args, options); diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 4078e7476..8433e7809 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,2 +1,7 @@ /// /// + +interface ImportMetaEnv { + // eslint-disable-next-line @typescript-eslint/naming-convention + readonly VITE_LOG_INVOKE_TIMINGS?: string; +}