diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index b2d8212..da30abc 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -68,3 +68,38 @@ verifiable by Authenticode signature (signed by namazso.eu) and by SHA-256: ``` a3a46226c5e2824f4cdd42be0eecbabfc672c86f7889710f5ab1e6ad385b47a0 PawnIO_setup.exe ``` + + +--- + +## Cuelume + +- Source: https://cuelume.dev/ +- Versions: 0.2.8 and 0.2.2 (installed as cuelume-legacy) +- Bundled in the settings frontend for interaction sound synthesis +- License: MIT + +``` +MIT License + +Copyright (c) 2026 Daniel Belyi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +``` diff --git a/docs/sound-effects.md b/docs/sound-effects.md new file mode 100644 index 0000000..8db2466 --- /dev/null +++ b/docs/sound-effects.md @@ -0,0 +1,55 @@ +# Interaction sounds and motion + +The app and Storybook share the same control implementations. Motion supports reduced-motion preferences, keyboard interaction, interrupted animations and preserved tab state. + +## Sound mapping + +| Interaction | Sound | +| --- | --- | +| Section and feature switches | Cuelume 0.2.2 `toggle`, the same cue in both directions | +| Metric, startup and diagnostics checkboxes | Cuelume 0.2.2 `press` | +| Changed selections | Cuelume 0.2.8 `select` | +| Open feedback | Cuelume 0.2.8 `open`, subtle emphasis, half gain | +| Submit feedback or reset settings | `success` or `error` after completion | +| Enable sounds | `toggle` | +| Disable sounds | Silent; cancels active and pending cues | +| Tabs, hover, accordions, tooltips, continuous sliders, telemetry | Silent | + +Both libraries use 35% global volume. A grouped switch produces one cue, even when it changes several sensors. Hydration and programmatic updates remain silent. Sound preferences persist across restarts; asynchronous actions cannot replay a cue cancelled by muting. + +## Audio implementation + +`src/lib/sound-effects.ts` gates explicit user-action cues and coordinates the two pinned library versions. `src/lib/settings-actions.ts` distinguishes switches, checkboxes and selections. Dependency patches retain the sound recipes while preparing audio nodes before reading the playback clock, with a 10 ms scheduling lead. The older engine also cancels active voices, echo tails and pending context resumes when muted. + +On Windows, a focused, visible and unmuted settings window maintains audio readiness through `src/lib/audio-session.ts`. It uses a 20 Hz signal at gain 0.0005, ramped over 50 ms. This is a low-level signal rather than mathematical silence. It stops on mute, blur, hide, page exit and hot reload, and does not run in the overlay or ordinary browser preview. Broader listening review across audio outputs remains required. + +## Motion + +- Tabs: 250 ms indicator and content transition; inactive panels stay mounted and inert. +- Switches: 350 ms bounce adapted to the existing control geometry. +- Checkboxes: 350 ms stroke drawing and 150 ms unchecking. +- Dropdowns and dialogs: 250 ms entry and 150 ms exit; preserve focus and dismissal behavior. +- Accordions: 250 ms expansion and collapse. +- Conditional panels: 300 ms measured-height changes; open height releases to auto. +- Toasts: 350 ms entry and 250 ms exit; repeated messages cancel stale exit timers. +- Tooltips: 80 ms delay, 150 ms entry and 50 ms exit. + +Reduced motion disables movement, blur and animation. Shared styles live in `src/app/motion.css` and `src/app/disclosure-motion.css`. + +## Local preview and validation + +From `tauri-app`, run `npm run dev -- --host 127.0.0.1 --port 1420`. Open `/sound-lab/` to compare both Cuelume versions without changing application settings. The playground optionally enables audio readiness while it is focused. + +- `npm run lint` +- `npm test` +- `npm run build` +- `npm run build-storybook` +- `cargo test --lib --manifest-path src-tauri/Cargo.toml` +- Browser checks: `scripts/test-sound-effects.mjs`, `test-checkbox-motion.mjs`, `test-control-motion.mjs`, `test-remaining-motion.mjs` and `test-storybook-motion.mjs`. +- `scripts/test-legacy-audio.mjs` checks active-tail cancellation and no replay after unmute in the sound playground. + +Use the scripts' URL environment variables when running on another port. Type checking currently reports five pre-existing diagnostics in overlay styling, Fluent button props, enum syntax and sensor-setting assignment. + +## Remaining validation + +Final visual/listening review and broader audio-output coverage are required before release. The native overlay stacking change also needs confirmation during normal taskbar use. diff --git a/tauri-app/.gitignore b/tauri-app/.gitignore index 08d0670..9096d35 100644 --- a/tauri-app/.gitignore +++ b/tauri-app/.gitignore @@ -10,6 +10,7 @@ lerna-debug.log* node_modules dist dist-ssr +test-results/ *.local # Tauri build artifacts @@ -26,3 +27,6 @@ src-tauri/gen/schemas/ *.njsproj *.sln *.sw? + +# Downloaded reference material stays local. +/transitions/ diff --git a/tauri-app/package-lock.json b/tauri-app/package-lock.json index 3b823d5..b50d038 100644 --- a/tauri-app/package-lock.json +++ b/tauri-app/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "cleanmeter", "version": "2.2.18", + "hasInstallScript": true, "license": "SEE LICENSE IN LICENSE", "dependencies": { "@fluentui/react-components": "^9.73.4", @@ -32,6 +33,8 @@ "@tauri-apps/plugin-updater": "^2.10.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "cuelume": "0.2.8", + "cuelume-legacy": "npm:cuelume@0.2.2", "lucide-react": "^1.8.0", "react": "^19.2.4", "react-dom": "^19.2.4", @@ -62,6 +65,7 @@ "eslint-plugin-react-refresh": "^0.5.2", "eslint-plugin-storybook": "^10.3.5", "globals": "^17.4.0", + "patch-package": "^8.0.1", "playwright": "^1.59.1", "storybook": "^10.3.5", "style-dictionary": "^5.5.1", @@ -6157,6 +6161,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true, + "license": "BSD-2-Clause" + }, "node_modules/@zip.js/zip.js": { "version": "2.8.26", "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.8.26.tgz", @@ -6411,6 +6422,19 @@ "concat-map": "0.0.1" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/browserslist": { "version": "4.28.7", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz", @@ -6642,6 +6666,22 @@ } } }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/class-variance-authority": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", @@ -6755,6 +6795,19 @@ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, + "node_modules/cuelume": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/cuelume/-/cuelume-0.2.8.tgz", + "integrity": "sha512-jnwAdMMUK4emaUWRd9l2RjpfixAMFOFrVkjoVK59FIfk7D3Vuvt+vBBJvU/J+2EiXrDlduialwDKJZorS5Nxqg==", + "license": "MIT" + }, + "node_modules/cuelume-legacy": { + "name": "cuelume", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/cuelume/-/cuelume-0.2.2.tgz", + "integrity": "sha512-TiNzJRjhddjC4jy4M7sv63V/86VaFhdIs6iHUCrc4CKhqypaxRBv1aedCBGebrz/cO7nroPkEfqHe/P7fOE2GQ==", + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -7409,6 +7462,19 @@ "node": ">= 10.4.0" } }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -7426,6 +7492,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "micromatch": "^4.0.2" + } + }, "node_modules/flat-cache": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", @@ -7463,6 +7539,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -7996,6 +8087,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -8060,6 +8161,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -8172,6 +8280,26 @@ "dev": true, "license": "MIT" }, + "node_modules/json-stable-stringify": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz", + "integrity": "sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -8205,6 +8333,16 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "license": "Public Domain", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/keyborg": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/keyborg/-/keyborg-2.6.0.tgz", @@ -8221,6 +8359,16 @@ "json-buffer": "3.0.1" } }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -8634,6 +8782,33 @@ "tslib": "2" } }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -8886,6 +9061,95 @@ "node": ">=6" } }, + "node_modules/patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", @@ -9690,6 +9954,16 @@ "node": ">=18" } }, + "node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -10057,6 +10331,29 @@ "node": ">=14.0.0" } }, + "node_modules/tmp": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -10661,6 +10958,22 @@ "dev": true, "license": "ISC" }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "devOptional": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/tauri-app/package.json b/tauri-app/package.json index d50f7a9..5154a9e 100644 --- a/tauri-app/package.json +++ b/tauri-app/package.json @@ -17,7 +17,8 @@ "tauri:build": "tauri build", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", - "deploy-storybook": "node scripts/deploy-storybook.cjs" + "deploy-storybook": "node scripts/deploy-storybook.cjs", + "postinstall": "patch-package" }, "dependencies": { "@fluentui/react-components": "^9.73.4", @@ -43,6 +44,8 @@ "@tauri-apps/plugin-updater": "^2.10.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "cuelume": "0.2.8", + "cuelume-legacy": "npm:cuelume@0.2.2", "lucide-react": "^1.8.0", "react": "^19.2.4", "react-dom": "^19.2.4", @@ -73,6 +76,7 @@ "eslint-plugin-react-refresh": "^0.5.2", "eslint-plugin-storybook": "^10.3.5", "globals": "^17.4.0", + "patch-package": "^8.0.1", "playwright": "^1.59.1", "storybook": "^10.3.5", "style-dictionary": "^5.5.1", diff --git a/tauri-app/patches/cuelume+0.2.8.patch b/tauri-app/patches/cuelume+0.2.8.patch new file mode 100644 index 0000000..8b6f439 --- /dev/null +++ b/tauri-app/patches/cuelume+0.2.8.patch @@ -0,0 +1,91 @@ +diff --git a/node_modules/cuelume/dist/audio/render.js b/node_modules/cuelume/dist/audio/render.js +index 7b82d07..7bffaaf 100644 +--- a/node_modules/cuelume/dist/audio/render.js ++++ b/node_modules/cuelume/dist/audio/render.js +@@ -26,34 +26,38 @@ function envelope(param, layer, startTime) { + param.linearRampToValueAtTime(layer.peak, startTime + layer.attack); + param.setTargetAtTime(0, startTime + layer.attack, fallTime(layer.decay)); + } +-function renderTone(context, destination, layer, startTime) { ++function renderTone(context, destination, layer) { + const oscillator = context.createOscillator(); + oscillator.type = layer.waveform; +- glide(oscillator.frequency, layer.frequency, layer, startTime); + if (layer.detune) + oscillator.detune.value = layer.detune; + const gain = context.createGain(); +- envelope(gain.gain, layer, startTime); + oscillator.connect(gain).connect(destination); ++ return (startTime) => { ++ glide(oscillator.frequency, layer.frequency, layer, startTime); ++ envelope(gain.gain, layer, startTime); + oscillator.start(startTime); + oscillator.stop(startTime + layer.attack + layer.decay + SOURCE_STOP_PADDING); ++ }; + } +-function renderNoise(context, bus, destination, layer, startTime) { ++function renderNoise(context, bus, destination, layer) { + const duration = layer.attack + layer.decay + SOURCE_STOP_PADDING; + const source = context.createBufferSource(); + source.buffer = getNoise(context, bus); + source.loop = true; + const filter = context.createBiquadFilter(); + filter.type = layer.filterType; +- glide(filter.frequency, layer.filterFrequency, layer, startTime); + if (layer.filterQ !== undefined) + filter.Q.value = layer.filterQ; + const gain = context.createGain(); +- envelope(gain.gain, layer, startTime); + source.connect(filter).connect(gain).connect(destination); ++ return (startTime) => { ++ glide(filter.frequency, layer.filterFrequency, layer, startTime); ++ envelope(gain.gain, layer, startTime); + // a different stretch of the same noise every time + source.start(startTime, Math.random() * NOISE_SECONDS); + source.stop(startTime + duration); ++ }; + } + function sourceEnd(layers) { + return Math.max(...layers.map((layer) => (layer.offset ?? 0) + layer.attack + layer.decay + SOURCE_STOP_PADDING)); +@@ -124,8 +128,10 @@ export function renderRecipe(context, getBus, voices, sound, played, part) { + const layers = layersFor(played, part); + if (layers.length === 0) + return; +- const now = context.currentTime; + const bus = getBus(); ++ // Cold room/noise allocation must finish before scheduling short envelopes. ++ if (layers.some((layer) => layer.kind === "noise")) ++ getNoise(context, bus); + const { output, room } = bus; + const master = context.createGain(); + master.gain.value = recipe.masterGain * volume; +@@ -134,6 +140,11 @@ export function renderRecipe(context, getBus, voices, sound, played, part) { + send.gain.value = ROOM_SEND * (recipe.room ?? 1); + master.connect(send).connect(room); + bus.live.add(master); ++ // Allocate/connect every source before reading the shared playback clock. ++ const schedule = layers.map((layer) => layer.kind === "tone" ++ ? renderTone(context, master, layer) ++ : renderNoise(context, bus, master, layer)); ++ const now = context.currentTime + 0.01; + // a release rings with its press rather than replacing it + if (part !== "release") { + const last = voices.get(sound); +@@ -144,15 +155,9 @@ export function renderRecipe(context, getBus, voices, sound, played, part) { + const fade = recipe.layers.some((layer) => layer.note) ? NOTE_HANDOFF_TIME : HANDOFF_TIME; + voices.set(sound, { gain: master, fade }); + } +- for (const layer of layers) { +- const startTime = now + (layer.offset ?? 0); +- if (layer.kind === "tone") +- renderTone(context, master, layer, startTime); +- else +- renderNoise(context, bus, master, layer, startTime); +- } ++ layers.forEach((layer, index) => schedule[index](now + (layer.offset ?? 0))); + // the room rings on by itself once the last source has fed it +- const cleanupAfterMs = (sourceEnd(layers) + CLEANUP_MARGIN) * 1000; ++ const cleanupAfterMs = (0.01 + sourceEnd(layers) + CLEANUP_MARGIN) * 1000; + setTimeout(() => { + if (voices.get(sound)?.gain === master) + voices.delete(sound); diff --git a/tauri-app/patches/cuelume-legacy+0.2.2.patch b/tauri-app/patches/cuelume-legacy+0.2.2.patch new file mode 100644 index 0000000..f83716a --- /dev/null +++ b/tauri-app/patches/cuelume-legacy+0.2.2.patch @@ -0,0 +1,145 @@ +diff --git a/node_modules/cuelume-legacy/dist/audio/engine.js b/node_modules/cuelume-legacy/dist/audio/engine.js +index 4b33883..a0611f4 100644 +--- a/node_modules/cuelume-legacy/dist/audio/engine.js ++++ b/node_modules/cuelume-legacy/dist/audio/engine.js +@@ -9,9 +9,12 @@ const SOURCE_STOP_PADDING = 0.05; + const CLEANUP_MARGIN = 0.05; + const INAUDIBLE_GAIN = 0.001; + const OUTPUT_GAIN = 4; +-function renderTone(context, destination, layer, startTime) { ++function renderTone(context, destination, layer) { + const oscillator = context.createOscillator(); + oscillator.type = layer.waveform; ++ const gain = context.createGain(); ++ oscillator.connect(gain).connect(destination); ++ return (startTime) => { + oscillator.frequency.setValueAtTime(layer.frequency, startTime); + if (layer.detune) + oscillator.detune.value = layer.detune; +@@ -19,15 +22,14 @@ function renderTone(context, destination, layer, startTime) { + const glideTime = layer.glideTime ?? layer.attack + layer.decay; + oscillator.frequency.exponentialRampToValueAtTime(layer.glideTo, startTime + glideTime); + } +- const gain = context.createGain(); + gain.gain.setValueAtTime(0.0001, startTime); + gain.gain.exponentialRampToValueAtTime(layer.peak, startTime + layer.attack); + gain.gain.exponentialRampToValueAtTime(0.0001, startTime + layer.attack + layer.decay); +- oscillator.connect(gain).connect(destination); + oscillator.start(startTime); + oscillator.stop(startTime + layer.attack + layer.decay + SOURCE_STOP_PADDING); ++ }; + } +-function renderNoise(context, destination, layer, startTime) { ++function renderNoise(context, destination, layer) { + const duration = layer.attack + layer.decay + SOURCE_STOP_PADDING; + const length = Math.max(1, Math.floor(duration * context.sampleRate)); + const buffer = context.createBuffer(1, length, context.sampleRate); +@@ -42,12 +44,14 @@ function renderNoise(context, destination, layer, startTime) { + if (layer.filterQ !== undefined) + filter.Q.value = layer.filterQ; + const gain = context.createGain(); ++ source.connect(filter).connect(gain).connect(destination); ++ return (startTime) => { + gain.gain.setValueAtTime(0.0001, startTime); + gain.gain.exponentialRampToValueAtTime(layer.peak, startTime + layer.attack); + gain.gain.exponentialRampToValueAtTime(0.0001, startTime + layer.attack + layer.decay); +- source.connect(filter).connect(gain).connect(destination); + source.start(startTime); + source.stop(startTime + duration); ++ }; + } + /** Wires a soft echo/shimmer send off `source`, feeding back into `destination`. */ + function attachShimmer(context, source, destination, shimmer) { +@@ -83,7 +87,7 @@ function getOutput(context) { + if (sharedOutput) + return sharedOutput; + const output = context.createGain(); +- output.gain.value = OUTPUT_GAIN; ++ output.gain.value = enabled ? OUTPUT_GAIN : 0; + const limiter = context.createDynamicsCompressor(); + limiter.threshold.value = -8; + limiter.knee.value = 6; +@@ -95,7 +99,6 @@ function getOutput(context) { + return output; + } + function renderRecipe(context, recipe, volume) { +- const now = context.currentTime; + const output = getOutput(context); + const master = context.createGain(); + master.gain.value = recipe.masterGain * volume; +@@ -103,22 +106,27 @@ function renderRecipe(context, recipe, volume) { + const shimmerNodes = recipe.shimmer + ? attachShimmer(context, master, output, recipe.shimmer) + : []; +- for (const layer of recipe.layers) { +- const startTime = now + (layer.offset ?? 0); +- if (layer.kind === "tone") +- renderTone(context, master, layer, startTime); +- else +- renderNoise(context, master, layer, startTime); +- } +- const cleanupAfterMs = (sourceEnd(recipe) + shimmerTail(recipe.shimmer) + CLEANUP_MARGIN) * 1000; +- setTimeout(() => { ++ // Preserve recipes while preparing all nodes before scheduling short cues. ++ const schedule = recipe.layers.map((layer) => layer.kind === "tone" ++ ? renderTone(context, master, layer) ++ : renderNoise(context, master, layer)); ++ const now = context.currentTime + 0.01; ++ recipe.layers.forEach((layer, i) => schedule[i](now + (layer.offset ?? 0))); ++ const stopVoice = () => { + master.disconnect(); +- for (const node of shimmerNodes) +- node.disconnect(); ++ for (const node of shimmerNodes) node.disconnect(); ++ }; ++ liveVoices.add(stopVoice); ++ const cleanupAfterMs = (0.01 + sourceEnd(recipe) + shimmerTail(recipe.shimmer) + CLEANUP_MARGIN) * 1000; ++ setTimeout(() => { ++ liveVoices.delete(stopVoice); ++ stopVoice(); + }, cleanupAfterMs); + } + let sharedContext = null; + let enabled = true; ++let generation = 0; ++const liveVoices = new Set(); + let globalVolume = 1; + function normalizeVolume(value, fallback) { + return typeof value === "number" && Number.isFinite(value) +@@ -127,8 +135,18 @@ function normalizeVolume(value, fallback) { + } + /** Enables or disables future playback. Preference storage stays with the app. */ + export function setEnabled(value) { +- if (typeof value === "boolean") +- enabled = value; ++ if (typeof value !== "boolean") return; ++ enabled = value; ++ if (!enabled) { ++ generation++; ++ for (const stopVoice of liveVoices) stopVoice(); ++ liveVoices.clear(); ++ } ++ // The output gate also silences existing shimmer tails. ++ if (sharedOutput && sharedContext) { ++ sharedOutput.gain.cancelScheduledValues(sharedContext.currentTime); ++ sharedOutput.gain.setValueAtTime(enabled ? OUTPUT_GAIN : 0, sharedContext.currentTime); ++ } + } + /** Sets the volume multiplier for future playback. Preference storage stays with the app. */ + export function setVolume(value) { +@@ -169,13 +187,14 @@ export function play(sound = "chime", options) { + if (!context) + return; + const recipe = RECIPES[sound]; ++ const startedGeneration = generation; + if (context.state === "running") { + renderRecipe(context, recipe, playVolume); + } + else { + try { + void context.resume().then(() => { +- if (enabled && context.state === "running") ++ if (enabled && generation === startedGeneration && context.state === "running") + renderRecipe(context, recipe, playVolume); + }, () => { }); + } diff --git a/tauri-app/scripts/test-checkbox-motion.mjs b/tauri-app/scripts/test-checkbox-motion.mjs new file mode 100644 index 0000000..fea310d --- /dev/null +++ b/tauri-app/scripts/test-checkbox-motion.mjs @@ -0,0 +1,41 @@ +import { chromium } from 'playwright'; +import assert from 'node:assert/strict'; +const browser = await chromium.launch(); +try { + for (const reducedMotion of ['no-preference', 'reduce']) { + const page = await browser.newPage({ reducedMotion, viewport: { width: 800, height: 1000 } }); + await page.goto(process.env.APP_URL ?? 'http://127.0.0.1:1420/'); + await page.getByRole('tab', {name:'Settings', exact:true}).click(); + const checkbox = page.getByRole('checkbox', {name:'Start minimized', exact:true}); + await checkbox.waitFor(); + const draw = checkbox.locator('.app-checkbox-draw'); + assert.equal(await draw.evaluate(el=>el.getAnimations().length), 0, 'No startup draw'); + if (await checkbox.isChecked()) await checkbox.click(); + await page.waitForTimeout(400); + await checkbox.focus(); + await page.keyboard.press('Space'); + const during = await draw.evaluate(el=>({offset:parseFloat(getComputedStyle(el).strokeDashoffset), animations:el.getAnimations().length})); + if (reducedMotion === 'reduce') { + assert.equal(during.offset, 0); + assert.equal(during.animations, 0); + } else { + assert.ok(during.offset > 0 && during.offset <= 15, 'Checking draws progressively'); + assert.ok(during.animations > 0); + } + await page.waitForTimeout(400); + assert.equal(await draw.evaluate(el=>parseFloat(getComputedStyle(el).strokeDashoffset)), 0); + for (let i=0; i<11; i++) await page.keyboard.press('Space'); + await page.waitForTimeout(400); + assert.equal(await checkbox.isChecked(), false); + assert.equal(await draw.evaluate(el=>parseFloat(getComputedStyle(el).strokeDashoffset)), 15); + assert.equal(await checkbox.locator('.app-checkbox-indicator').evaluate(el=>getComputedStyle(el).opacity), '1', 'No checkmark opacity fade'); + await checkbox.click(); + await page.waitForTimeout(400); + const length = await draw.evaluate(el=>el.getTotalLength()); + assert.equal(Math.ceil(length), 15, 'Dash length calibrated to reference path'); + await page.screenshot({path:`test-results/checkbox-${reducedMotion}.png`}); + console.log(`PASS checkbox: ${reducedMotion}; progressive stroke draw, rapid reversal, keyboard, no opacity fade`); + await page.close(); + } +} finally { await browser.close(); } + diff --git a/tauri-app/scripts/test-control-motion.mjs b/tauri-app/scripts/test-control-motion.mjs new file mode 100644 index 0000000..99f6d20 --- /dev/null +++ b/tauri-app/scripts/test-control-motion.mjs @@ -0,0 +1,96 @@ +// Run against the actual app: npm run dev, then node scripts/test-control-motion.mjs. +import { chromium } from "playwright"; +import assert from "node:assert/strict"; + +const browser = await chromium.launch(); +try { + for (const reducedMotion of ["no-preference", "reduce"]) { + const page = await browser.newPage({ reducedMotion, viewport: { width: 800, height: 1000 } }); + await page.goto(process.env.APP_URL ?? "http://127.0.0.1:1420/"); + const cpu = page.getByRole("switch", { name: "CPU", exact: true }); + await cpu.waitFor(); + const thumb = cpu.locator('[data-slot="switch-thumb"]'); + assert.equal(await thumb.evaluate(el => el.getAnimations().length), 0, "No entrance toggle on hydration"); + const initial = await cpu.getAttribute("aria-checked"); + assert.equal(await page.getByRole("tabpanel").count(), 1, "Only the active panel is accessible"); + await page.locator('#panel-stats').evaluate(el => { el.scrollTop = 120; }); + const savedScroll = await page.locator('#panel-stats').evaluate(el => el.scrollTop); + await cpu.focus(); + for (let i = 0; i < 11; i++) await page.keyboard.press("Space"); + await page.waitForTimeout(400); + assert.notEqual(await cpu.getAttribute("aria-checked"), initial); + const checked = await cpu.getAttribute("aria-checked") === "true"; + assert.equal(await thumb.evaluate(el => getComputedStyle(el).translate), checked ? "16px" : "0px"); + assert.equal(await thumb.evaluate(el => getComputedStyle(el).animationDuration), reducedMotion === "reduce" ? "0s" : "0.35s"); + if (reducedMotion === "no-preference") { + if (!checked) await cpu.click(); + await page.waitForTimeout(400); + assert.equal(await thumb.evaluate(el => el.style.getPropertyValue('--toggle-from')), '', 'Finished interaction must not leave a stale animation origin'); + await page.evaluate(async () => { + const { useSettingsStore } = await import('/src/stores/settings-store.ts'); + for (const key of Object.keys(useSettingsStore.getState().settings.sensors).filter(key => key.startsWith('cpu'))) { + useSettingsStore.getState().updateSensor(key, { isEnabled: false }); + } + }); + await page.waitForTimeout(400); + assert.equal(await cpu.getAttribute('aria-checked'), 'false'); + assert.equal(await thumb.evaluate(el => getComputedStyle(el).translate), '0px'); + } + await page.locator('#panel-stats').evaluate((el, top) => { el.scrollTop = top; }, savedScroll); + + for (const name of ["Help", "Style", "Stats", "Settings"]) { + // DOM clicks deliberately interrupt the transition without Playwright's stability wait. + await page.getByRole("tab", { name, exact: true }).evaluate(el => el.click()); + await page.waitForTimeout(25); + } + await page.waitForTimeout(300); + assert.equal(await page.getByRole("tab", { name: "Settings", exact: true }).getAttribute("aria-selected"), "true"); + const indicator = page.locator('.app-tab-indicator'); + const position = await indicator.evaluate(el => ({ x: new DOMMatrix(getComputedStyle(el).transform).m41, width: el.getBoundingClientRect().width })); + assert.ok(Math.abs(position.x - position.width * 2) < 1, "Rapid tab changes settle at latest tab"); + assert.equal(await indicator.evaluate(el => getComputedStyle(el).transitionDuration), reducedMotion === "reduce" ? "0s" : "0.25s"); + const panels = await page.locator('.app-tab-panel').evaluateAll(elements => elements.map(el => ({ + active: el.dataset.active === 'true', inert: el.inert, + opacity: getComputedStyle(el).opacity, visibility: getComputedStyle(el).visibility, + x: new DOMMatrix(getComputedStyle(el).transform).m41, + duration: getComputedStyle(el).transitionDuration, + }))); + assert.equal(panels.filter(p => p.active).length, 1); + for (const panel of panels) { + assert.equal(panel.inert, !panel.active); + assert.equal(panel.opacity, panel.active ? '1' : '0'); + assert.equal(panel.visibility, panel.active ? 'visible' : 'hidden'); + assert.equal(Math.abs(panel.x), panel.active ? 0 : 8); + if (reducedMotion === 'reduce') assert.equal(panel.duration, '0s'); + } + + const pixel = page.getByRole("switch", { name: "Pixel Shift", exact: true }); + if (await pixel.getAttribute("aria-checked") !== "true") await pixel.click(); + const trigger = page.getByRole("combobox", { name: "Shift by", exact: true }); + await trigger.focus(); + await page.keyboard.press("Space"); + const menu = page.locator('[data-slot="select-content"]'); + await menu.waitFor(); + assert.equal(await menu.evaluate(el => getComputedStyle(el).animationName), reducedMotion === "reduce" ? "none" : "app-select-enter"); + await page.waitForTimeout(300); + await page.keyboard.press("ArrowDown"); + await page.keyboard.press("Enter"); + await menu.waitFor({ state: "detached" }); + await page.waitForFunction(() => document.activeElement?.getAttribute("aria-labelledby") === "pixelShiftDistance-label"); + assert.equal(await trigger.evaluate(el => el === document.activeElement), true, "Selection restores trigger focus"); + await page.keyboard.press("Space"); + await menu.waitFor(); + await page.keyboard.press("Escape"); + await menu.waitFor({ state: "detached" }); + await page.waitForFunction(() => document.activeElement?.getAttribute("aria-labelledby") === "pixelShiftDistance-label"); + assert.equal(await trigger.evaluate(el => el === document.activeElement), true, "Escape restores trigger focus"); + await page.getByRole("tab", { name: "Stats", exact: true }).focus(); + await page.keyboard.press("Enter"); + assert.equal(await cpu.getAttribute("aria-checked"), String(checked), "Tab switches preserve state"); + assert.equal(await page.locator('#panel-stats').evaluate(el => el.scrollTop), savedScroll, "Tab switches preserve per-panel scroll position"); + console.log(`PASS app controls: ${reducedMotion}; rapid toggles/tabs, final positions, keyboard selection/Escape, focus and preserved state`); + await page.close(); + } +} finally { + await browser.close(); +} diff --git a/tauri-app/scripts/test-legacy-audio.mjs b/tauri-app/scripts/test-legacy-audio.mjs new file mode 100644 index 0000000..5ccc212 --- /dev/null +++ b/tauri-app/scripts/test-legacy-audio.mjs @@ -0,0 +1,2 @@ +import {chromium} from 'playwright';import assert from 'node:assert/strict'; +const b=await chromium.launch();try{const p=await b.newPage();await p.addInitScript(()=>{window.outputs=[];const connect=AudioNode.prototype.connect;AudioNode.prototype.connect=function(destination,...args){if(destination===this.context.destination){const a=this.context.createAnalyser();a.fftSize=512;connect.call(this,a);window.outputs.push(a);}return connect.call(this,destination,...args)};window.level=()=>Math.max(0,...window.outputs.map(a=>{const data=new Float32Array(512);a.getFloatTimeDomainData(data);return Math.max(...data.map(Math.abs))}));});await p.goto(process.env.SOUND_LAB_URL ?? 'http://127.0.0.1:1430/sound-lab/');await p.locator('#ready').uncheck();await p.locator('#library').selectOption('legacy');await p.locator('#sounds button').filter({has:p.getByText('chime',{exact:true})}).click();await p.waitForFunction(()=>window.level()>0.001);await p.locator('#mute').click();await p.waitForTimeout(70);assert.ok(await p.evaluate(()=>window.level())<0.00001,'Mute stops ringing legacy voices');await p.locator('#mute').click();await p.waitForTimeout(70);assert.ok(await p.evaluate(()=>window.level())<0.00001,'Unmute does not revive the cancelled tail');console.log('PASS Legacy active-tail mute and no replay after unmute');}finally{await b.close()} diff --git a/tauri-app/scripts/test-remaining-motion.mjs b/tauri-app/scripts/test-remaining-motion.mjs new file mode 100644 index 0000000..487bdbd --- /dev/null +++ b/tauri-app/scripts/test-remaining-motion.mjs @@ -0,0 +1,75 @@ +import { chromium } from 'playwright'; +import assert from 'node:assert/strict'; +const browser = await chromium.launch(); +const url = process.env.APP_URL ?? 'http://127.0.0.1:1420/'; +try { + for (const reducedMotion of ['no-preference','reduce']) { + const page = await browser.newPage({reducedMotion, viewport:{width:800,height:1000}}); + const errors=[]; page.on('pageerror',e=>errors.push(e.message)); + await page.goto(url); + const tab = name => page.getByRole('tab',{name,exact:true}).click(); + const cpu = page.getByRole('switch',{name:'CPU',exact:true}); + await cpu.waitFor(); + const body = cpu.locator('xpath=ancestor::section').locator('.app-disclosure').first(); + const fullHeight=await body.evaluate(el=>el.getBoundingClientRect().height); + assert.ok(fullHeight > 0); + await cpu.click(); await page.waitForTimeout(500); + assert.equal(await body.evaluate(el=>el.getBoundingClientRect().height),0); + assert.equal(await body.getAttribute('inert'),''); + await cpu.click(); await page.waitForTimeout(500); + assert.ok(await body.evaluate(el=>el.getBoundingClientRect().height)>0); + assert.equal(await body.evaluate(el=>el.style.height),''); + const expand=page.getByRole('button',{name:/^Expand /}).first(); + if(await expand.count()) { + const name=await expand.getAttribute('aria-label'); + await expand.click(); await page.waitForTimeout(300); + assert.equal(await page.getByRole('button',{name:name.replace('Expand ','Collapse '),exact:true}).getAttribute('aria-expanded'),'true'); + } + await tab('Style'); + const collapse=page.getByRole('button',{name:'Collapse Position',exact:true}); + await collapse.click(); await page.waitForTimeout(300); + assert.equal(await page.getByRole('switch',{name:'Use custom position'}).count(),0); + await page.getByRole('button',{name:'Expand Position',exact:true}).click(); + const custom=page.getByRole('switch',{name:'Use custom position'}); + await custom.waitFor(); + if(await custom.isChecked()) { await custom.click(); await page.waitForTimeout(500); } + await custom.click(); await page.waitForTimeout(500); + assert.equal(await page.getByRole('button',{name:'Top left',exact:true}).count(),0); + await custom.click(); await page.waitForTimeout(500); + assert.equal(await page.getByRole('button',{name:'Top left',exact:true}).count(),1); + await tab('Settings'); + const pixel=page.getByRole('switch',{name:'Pixel Shift',exact:true}); + if(await pixel.isChecked()) await pixel.click(); + await pixel.click(); await page.waitForTimeout(500); + await page.getByRole('combobox',{name:'Shift by',exact:true}).waitFor(); + await pixel.focus(); + for(let i=0;i<10;i++) await page.keyboard.press('Space'); + await page.waitForTimeout(500); + assert.equal(await pixel.isChecked(),true); + await tab('Help'); + await page.getByRole('button',{name:'Collapse Frequently asked questions'}).click(); + await page.waitForTimeout(300); + assert.equal(await page.getByRole('button',{name:'Expand Frequently asked questions'}).locator('xpath=ancestor::div[contains(@class,"t-acc")]').locator('.app-disclosure').evaluate(el=>el.getBoundingClientRect().height),0); + await page.getByRole('button',{name:'Expand Frequently asked questions'}).click(); + await page.getByRole('button',{name:'Give feedback',exact:true}).click(); + const dialog=page.getByRole('dialog'); await dialog.waitFor(); + assert.equal(await dialog.evaluate(el=>getComputedStyle(el).animationName),reducedMotion==='reduce'?'none':'app-modal-enter'); + await page.keyboard.press('Escape'); await dialog.waitFor({state:'detached'}); + await page.waitForFunction(()=>document.activeElement?.textContent?.trim()==='Give feedback'); + const close=page.getByRole('button',{name:'Close to tray',exact:true}); + await close.hover(); const tip=page.getByRole('tooltip'); await tip.waitFor(); + assert.equal(await tip.textContent(),'Close to tray'); + await page.mouse.move(400,900,{steps:10}); + await tip.waitFor({state:'detached'}); + await page.evaluate(async()=>{const {useToastStore}=await import('/src/stores/toast-store.ts');useToastStore.getState().showToast('Motion check');}); + const toast=page.locator('.t-toast'); await toast.waitFor(); await page.waitForTimeout(400); + assert.equal(await toast.evaluate(el=>getComputedStyle(el).opacity),'1'); + await page.waitForTimeout(3700); + await page.evaluate(async()=>{const {useToastStore}=await import('/src/stores/toast-store.ts');useToastStore.getState().showToast('Motion check');}); + await page.waitForTimeout(500); assert.equal(await toast.count(),1,'Repeated toast survives prior exit timer'); + await toast.waitFor({state:'detached',timeout:5000}); + assert.deepEqual(errors,[]); + console.log(`PASS remaining app motion: ${reducedMotion}`); + await page.close(); + } +} finally {await browser.close();} diff --git a/tauri-app/scripts/test-sound-effects.mjs b/tauri-app/scripts/test-sound-effects.mjs new file mode 100644 index 0000000..f5c1c29 --- /dev/null +++ b/tauri-app/scripts/test-sound-effects.mjs @@ -0,0 +1,166 @@ +// Run against `npm run dev`: node scripts/test-sound-effects.mjs +// Exercises the actual app, not Storybook. Native persistence has separate tests. +import { chromium } from "playwright"; +import assert from "node:assert/strict"; +import { mkdir } from "node:fs/promises"; + +const browser = await chromium.launch({ headless: true }); +const page = await browser.newPage({ viewport: { width: 800, height: 1000 } }); +const errors = []; +page.on("pageerror", (error) => errors.push(error.message)); +await page.addInitScript(() => { + window.soundStarts = 0; + window.soundTiming = []; + window.soundDirections = []; + window.noiseFrequencies = []; + // Exercise cold output initialization under main-thread load. + const createConvolver = AudioContext.prototype.createConvolver; + AudioContext.prototype.createConvolver = function (...args) { + const until = performance.now() + 80; + while (performance.now() < until) { /* simulate expensive first setup */ } + return createConvolver.apply(this, args); + }; + window.soundPeak = 0; + const connect = AudioNode.prototype.connect; + AudioNode.prototype.connect = function (destination, ...args) { + if (destination === this.context.destination) { + const analyser = this.context.createAnalyser(); + analyser.fftSize = 32768; + connect.call(this, analyser); + const samples = new Float32Array(analyser.fftSize); + setInterval(() => { + analyser.getFloatTimeDomainData(samples); + for (const sample of samples) { + window.soundPeak = Math.max(window.soundPeak, Math.abs(sample)); + } + }, 5); + } + return connect.call(this, destination, ...args); + }; + const createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function (...args) { + const until = performance.now() + 30; + while (performance.now() < until) { /* simulate busy noise source setup */ } + const source = createBufferSource.apply(this, args); + const connectSource = source.connect.bind(source); + let filter; + source.connect = (destination, ...rest) => { filter = destination; return connectSource(destination, ...rest); }; + const startSource = source.start.bind(source); + source.start = (...values) => { + window.soundStarts++; + window.soundTiming.push(values[0] - this.currentTime); + window.noiseFrequencies.push(filter?.frequency?.value); + return startSource(...values); + }; + return source; + }; + const createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function (...args) { + // Source allocation must also precede the shared cue clock. + const until = performance.now() + 30; + while (performance.now() < until) { /* simulate busy node setup */ } + const oscillator = createOscillator.apply(this, args); + let from, to; + const setFrequency = oscillator.frequency.setValueAtTime.bind(oscillator.frequency); + const rampFrequency = oscillator.frequency.exponentialRampToValueAtTime.bind(oscillator.frequency); + oscillator.frequency.setValueAtTime = (value, time) => { from = value; return setFrequency(value, time); }; + oscillator.frequency.exponentialRampToValueAtTime = (value, time) => { to = value; return rampFrequency(value, time); }; + const start = oscillator.start.bind(oscillator); + oscillator.start = (...values) => { + window.soundStarts++; + window.soundTiming.push(values[0] - this.currentTime); + window.soundDirections.push(to > from ? "back" : "forward"); + return start(...values); + }; + return oscillator; + }; +}); +const count = () => page.evaluate(() => window.soundStarts); +const pause = () => page.waitForTimeout(800); +const tab = (name) => page.getByRole("tab", { name, exact: true }).click(); +async function audible(label, action) { + await pause(); + const before = await count(); + await page.evaluate(() => { window.soundPeak = 0; }); + await action(); + await pause(); + assert.ok(await count() > before, `${label} must synthesize a sound`); + assert.ok(await page.evaluate(() => window.soundPeak) > 0.001, + `${label} must produce a non-zero signal at the audio destination`); + const leads = await page.evaluate(() => window.soundTiming); + assert.ok(leads.every((lead) => lead >= 0), + `${label}: envelopes must not start in the past (${Math.min(...leads)}s)`); + console.log(`PASS audible: ${label}`); +} +async function silent(label, action) { + await pause(); + const before = await count(); + await action(); + await pause(); + assert.equal(await count(), before, `${label} must be silent`); + console.log(`PASS silent: ${label}`); +} + +try { + await page.goto(process.env.APP_URL ?? "http://127.0.0.1:1420/"); + await page.waitForTimeout(2500); + assert.equal(await count(), 0, "Startup and telemetry must be silent"); + for (const name of ["CPU", "GPU"]) { + await page.reload(); + await page.waitForTimeout(2500); + const control = page.getByRole("switch", { name, exact: true }); + for (const checked of [false, true, false, true]) { + await audible(`${name} ${checked}`, () => control.click()); + assert.equal(await control.getAttribute("aria-checked"), String(checked)); + assert.deepEqual(await page.evaluate(() => window.noiseFrequencies.slice(-2)), [2200, 3800], "Original Legacy toggle recipe in both directions"); + } + } + await silent("tab navigation", () => tab("Settings")); + const sound = page.getByRole("switch", { name: "Sound effects", exact: true }); + assert.equal(await sound.getAttribute("aria-checked"), "true"); + await audible("Pixel Shift toggle", () => page.getByRole("switch", { name: "Pixel Shift", exact: true }).click()); + const beforeRapid = await count(); + const pixelShift = page.getByRole("switch", { name: "Pixel Shift", exact: true }); + await pixelShift.focus(); + for (let i = 0; i < 10; i++) await page.keyboard.press("Space"); + assert.equal(await count() - beforeRapid, 20, "Ten rapid toggle events must produce ten cues"); + console.log("PASS ten rapid toggles: ten cues"); + await audible("temperature selection", () => page.getByRole("radio", { name: "Fahrenheit", exact: false }).click()); + await silent("same temperature selection", () => page.getByRole("radio", { name: "Fahrenheit", exact: false }).click()); + await audible("start minimized", () => page.getByRole("checkbox", { name: "Start minimized", exact: true }).click()); + assert.equal(await page.evaluate(() => window.noiseFrequencies.at(-1)), 1700, "Original Legacy press for checkbox"); + await silent("turn sound off", () => sound.click()); + await silent("muted Pixel Shift", () => page.getByRole("switch", { name: "Pixel Shift", exact: true }).click()); + await tab("Stats"); + await silent("muted CPU section", () => page.getByRole("switch", { name: "CPU", exact: true }).click()); + await tab("Settings"); + await audible("enable sound with keyboard", () => sound.press("Space")); + await tab("Stats"); + await pause(); + const beforeGroup = await count(); + await page.getByRole("switch", { name: "CPU", exact: true }).click(); + await pause(); + assert.equal(await count() - beforeGroup, 2, "Grouped CPU changes must produce one toggle cue"); + console.log("PASS grouped CPU section: one cue"); + await audible("CPU checkbox", () => page.getByRole("checkbox", {name:"CPU Usage",exact:true}).click()); + assert.equal(await page.evaluate(() => window.noiseFrequencies.at(-1)),1700); + await tab("Style"); + await audible("orientation", () => page.getByRole("button", { name: "Vertical", exact: false }).click()); + await silent("unchanged orientation", () => page.getByRole("button", { name: "Vertical", exact: false }).click()); + await silent("opacity slider keyboard", () => page.getByRole("slider").press("ArrowLeft")); + await tab("Help"); + await audible("feedback button", () => page.getByRole("button", { name: "Give feedback", exact: true }).click()); + await audible("feedback diagnostics checkbox", () => page.getByRole("checkbox", {name:"Include system specs and app logs"}).click()); + assert.equal(await page.evaluate(() => window.noiseFrequencies.at(-1)),1700); + await page.keyboard.press("Escape"); + await tab("Settings"); + await sound.click(); + await page.emulateMedia({ reducedMotion: "reduce", colorScheme: "dark" }); + await silent("muted keyboard change with reduced motion", () => page.getByRole("switch", { name: "Pixel Shift", exact: true }).press("Space")); + await mkdir("test-results", { recursive: true }); + await page.screenshot({ path: "test-results/sound-settings.png", fullPage: true }); + assert.deepEqual(errors, [], "No browser runtime errors"); + console.log("PASS no runtime errors"); +} finally { + await browser.close(); +} diff --git a/tauri-app/scripts/test-storybook-motion.mjs b/tauri-app/scripts/test-storybook-motion.mjs new file mode 100644 index 0000000..9284008 --- /dev/null +++ b/tauri-app/scripts/test-storybook-motion.mjs @@ -0,0 +1,59 @@ +import { chromium } from 'playwright'; +import assert from 'node:assert/strict'; +const browser = await chromium.launch(); +const base = process.env.STORYBOOK_URL ?? 'http://127.0.0.1:6006'; +try { + for (const theme of ['light', 'dark']) for (const reducedMotion of ['no-preference', 'reduce']) { + const page = await browser.newPage({ reducedMotion }); + const open = async id => { + await page.goto(`${base}/iframe.html?id=${id}&viewMode=story&globals=theme:${theme}`); + await page.locator('#storybook-root').waitFor(); + }; + await open('components-checkbox--with-label'); + const checkbox = page.getByRole('checkbox', {name:'Accept terms'}); + await checkbox.waitFor(); + assert.equal(await checkbox.getAttribute('data-slot'), 'checkbox'); + await page.getByText('Accept terms', {exact:true}).click(); + assert.equal(await checkbox.isChecked(), false, 'Label activates shared checkbox'); + await checkbox.press('Space'); + await page.waitForTimeout(400); + assert.equal(await checkbox.locator('path').evaluate(el=>parseFloat(getComputedStyle(el).strokeDashoffset)), 0); + + await open('components-toggle--off'); + const toggle = page.getByRole('switch'); + await toggle.waitFor(); + assert.equal(await toggle.getAttribute('data-slot'), 'switch'); + const thumb = toggle.locator('[data-slot="switch-thumb"]'); + assert.equal(await thumb.evaluate(el=>el.getAnimations().length), 0); + await toggle.press('Space'); + assert.equal(await thumb.evaluate(el=>getComputedStyle(el).animationName), reducedMotion === 'reduce' ? 'none' : 't-toggle-on'); + await page.waitForTimeout(400); + assert.equal(await thumb.evaluate(el=>parseFloat(getComputedStyle(el).translate)), 16); + + await open('components-select--with-label'); + const trigger = page.getByRole('combobox'); + await trigger.press('Space'); + const menu = page.locator('[data-slot="select-content"]'); + await menu.waitFor(); + assert.equal(await menu.evaluate(el=>getComputedStyle(el).animationName), reducedMotion === 'reduce' ? 'none' : 'app-select-enter'); + await page.keyboard.press('Escape'); + await menu.waitFor({state:'detached'}); + await page.waitForFunction(()=>document.activeElement?.getAttribute('role') === 'combobox'); + + await open('components-navigationtabs--default'); + const input = page.getByRole('textbox', {name:'Preserved input'}); + await input.fill('Keep this value'); + await page.locator('#panel-stats').evaluate(el=>{el.scrollTop=80;}); + for (const name of ['Style','Help','Settings','Stats']) { + await page.getByRole('tab',{name, exact:true}).evaluate(el=>el.click()); + await page.waitForTimeout(20); + } + await page.waitForTimeout(300); + assert.equal(await input.inputValue(), 'Keep this value'); + assert.equal(await page.locator('#panel-stats').evaluate(el=>el.scrollTop), 80); + assert.equal(await page.getByRole('tabpanel').count(), 1); + if (reducedMotion === 'reduce') assert.equal(await page.locator('#panel-stats').evaluate(el=>getComputedStyle(el).transitionDuration), '0s'); + console.log(`PASS Storybook shared components: ${theme}, ${reducedMotion}`); + await page.close(); + } +} finally { await browser.close(); } diff --git a/tauri-app/sound-lab/index.html b/tauri-app/sound-lab/index.html new file mode 100644 index 0000000..720cd8d --- /dev/null +++ b/tauri-app/sound-lab/index.html @@ -0,0 +1,12 @@ + +Cleanmeter Sound Lab
+

Sound lab

Listen, compare, and choose your favourites. These controls only affect this playground.

+
+

Audio readiness uses the same quiet output helper as Cleanmeter. It stops when this page loses focus or is muted. No sounds play automatically.

+

Compare Cleanmeter cues

These use the app's default sound theme. Volume follows the slider above.

+

Explore the library

+

+

Choose a sound to play it.

+
diff --git a/tauri-app/sound-lab/main.js b/tauri-app/sound-lab/main.js new file mode 100644 index 0000000..79e38be --- /dev/null +++ b/tauri-app/sound-lab/main.js @@ -0,0 +1,21 @@ +import * as current from 'cuelume'; +import * as legacyAudio from 'cuelume-legacy'; +import { createAudioSession } from '../src/lib/audio-session.ts'; +const $ = id => document.getElementById(id); +const session = createAudioSession(() => new AudioContext({latencyHint:'interactive'})); +let muted=false; +const sync = () => session.setActive(!muted && $('ready').checked && document.visibilityState==='visible' && document.hasFocus()); +function volume(){const value=Number($('volume').value)/100;current.setVolume(value);legacyAudio.setVolume(value);$('volume-label').textContent=`${Math.round(value*100)}%`;} +volume();current.setEnabled(true);legacyAudio.setEnabled(true); +$('volume').addEventListener('input',volume); +$('mute').onclick=()=>{muted=!muted;current.setEnabled(!muted);legacyAudio.setEnabled(!muted);$('mute').textContent=muted?'Unmute':'Mute';$('mute').setAttribute('aria-pressed',String(muted));sync();$('status').textContent=muted?'Muted.':'Ready to listen.';}; +$('ready').onchange=sync; +window.addEventListener('blur',()=>session.stop());window.addEventListener('pagehide',()=>session.stop());window.addEventListener('focus',sync);document.addEventListener('visibilitychange',sync); +function listen(engine,sound,options,label){if(muted){$('status').textContent='Unmute to preview sounds.';return;}sync();engine.play(sound,options);$('status').textContent=`Playing ${label} - ${$('volume-label').textContent} volume`;} +function button(parent,label,detail,action){const b=document.createElement('button');b.className='cue';const title=document.createElement('strong');title.textContent=label;const sub=document.createElement('small');sub.textContent=detail;b.append(title,sub);b.onclick=action;parent.append(b);} +const presets=[['Feedback - softer','open',{emphasis:'subtle',volume:.5},'Current - subtle, half gain'],['Feedback - previous','open',{},'Previous - normal, full gain'],['Toggle on','toggle',{},'Legacy original / current app'],['Toggle off','toggle',{},'Legacy original / current app'],['Checkbox','press',{},'Legacy original / current app'],['Selection','select',{},'Current app'],['Success','success',{},'Current app'],['Error','error',{},'Current app']]; +for(const [label,sound,opts,detail] of presets)button($('presets'),label,detail,()=>listen(sound==='toggle'||sound==='press'?legacyAudio:current,sound,{...opts,theme:'default'},label)); +for(const name of current.themes){const o=document.createElement('option');o.value=name;o.textContent=name;$('theme').append(o);} +function render(){const legacy=$('library').value==='legacy';for(const id of ['theme','emphasis','direction'])$(id).disabled=legacy;$('sounds').replaceChildren();$('library-note').textContent=legacy?'Original Cuelume 0.2.2 library. Use the volume slider to compare.':'Current library. Try "subtle" emphasis for softer variants. Direction affects supported cues such as toggle; themes change the sound character.';const engine=legacy?legacyAudio:current;for(const name of engine.sounds)button($('sounds'),name,legacy?'Legacy 0.2.2':'Cleanmeter 0.2.8',()=>listen(engine,name,legacy?{}:{theme:$('theme').value,emphasis:$('emphasis').value,direction:$('direction').value},`${name} (${legacy?'Legacy':$('theme').value+' / '+$('emphasis').value+' / '+$('direction').value})`));} +$('library').onchange=render;render(); +if(import.meta.hot)import.meta.hot.dispose(()=>session.stop()); diff --git a/tauri-app/src-tauri/src/commands.rs b/tauri-app/src-tauri/src/commands.rs index 5f21bb0..5c01108 100644 --- a/tauri-app/src-tauri/src/commands.rs +++ b/tauri-app/src-tauri/src/commands.rs @@ -307,7 +307,7 @@ pub fn set_overlay_visible(visible: bool, app: AppHandle) { if let Some(overlay) = app.get_webview_window("overlay") { if visible { let _ = overlay.show(); - let _ = overlay.set_always_on_top(true); + refresh_overlay_z_order(&overlay); // The overlay is created hidden and first shown on initial sensor // data, which can land after the gate was already decided. Recompute // so it never comes up interactive while Settings is unfocused. @@ -318,6 +318,34 @@ pub fn set_overlay_visible(visible: bool, app: AppHandle) { } } +/// Reassert native stacking, not just tao's cached always-on-top flag. Another +/// topmost window can move above the HUD without changing that cached flag. +#[cfg(windows)] +pub fn refresh_overlay_z_order(overlay: &tauri::WebviewWindow) { + use windows::Win32::Foundation::HWND; + use windows::Win32::UI::WindowsAndMessaging::{ + IsWindowVisible, SetWindowPos, HWND_TOPMOST, SWP_ASYNCWINDOWPOS, + SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOOWNERZORDER, SWP_NOSIZE, + }; + let Ok(raw) = overlay.hwnd() else { return }; + let hwnd = HWND(raw.0 as _); + unsafe { + if !IsWindowVisible(hwnd).as_bool() { + return; + } + // Never activate the HUD, change its geometry, or show a hidden window. + let _ = SetWindowPos( + hwnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER, + ); + } +} + +#[cfg(not(windows))] +pub fn refresh_overlay_z_order(overlay: &tauri::WebviewWindow) { + let _ = overlay.set_always_on_top(true); +} + #[tauri::command] pub fn set_overlay_position(x: i32, y: i32, app: AppHandle) { if let Some(overlay) = app.get_webview_window("overlay") { diff --git a/tauri-app/src-tauri/src/lib.rs b/tauri-app/src-tauri/src/lib.rs index cf6dd54..9435e39 100644 --- a/tauri-app/src-tauri/src/lib.rs +++ b/tauri-app/src-tauri/src/lib.rs @@ -580,8 +580,8 @@ pub fn run() { // Only reasserts when overlay is currently visible (user hasn't hidden it). // The click-through gate is recomputed on the same tick, which is what // makes it self-correcting rather than dependent on having seen every - // Focused event. Both calls are no-ops at the OS level when nothing - // changed (tao's apply_diff early-returns on an empty flag diff). + // Focused event. Refresh native Z order: repeating tao's cached + // always-on-top setter is a no-op and cannot recover lost stacking. { let app_handle_top = app.handle().clone(); tauri::async_runtime::spawn(async move { @@ -589,7 +589,7 @@ pub fn run() { tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; if let Some(overlay) = app_handle_top.get_webview_window("overlay") { if overlay.is_visible().unwrap_or(false) { - let _ = overlay.set_always_on_top(true); + commands::refresh_overlay_z_order(&overlay); commands::sync_overlay_interactive(&app_handle_top); } } diff --git a/tauri-app/src-tauri/src/settings.rs b/tauri-app/src-tauri/src/settings.rs index afcad08..9d7f86b 100644 --- a/tauri-app/src-tauri/src/settings.rs +++ b/tauri-app/src-tauri/src/settings.rs @@ -227,6 +227,21 @@ mod tests { dir } + #[test] + fn sound_mute_survives_a_manager_restart() { + let dir = scratch("sound-mute"); + let manager = SettingsManager::new(dir.clone()); + manager.save_preferences(AppPreferences { + sound_effects: false, + start_minimized: true, + ..AppPreferences::default() + }); + drop(manager); + let reloaded = SettingsManager::new(dir); + assert!(!reloaded.get_preferences().sound_effects); + assert!(reloaded.get_preferences().start_minimized); + } + #[test] fn reads_a_file_that_starts_with_a_utf8_bom() { let path = scratch("bom").join("settings.json"); diff --git a/tauri-app/src-tauri/src/types.rs b/tauri-app/src-tauri/src/types.rs index 683ce27..5c2d070 100644 --- a/tauri-app/src-tauri/src/types.rs +++ b/tauri-app/src-tauri/src/types.rs @@ -463,13 +463,18 @@ pub struct AppPreferences { pub admin_consent: bool, #[serde(rename = "startMinimized")] pub start_minimized: bool, + #[serde(rename = "soundEffects", default = "default_sound_effects")] + pub sound_effects: bool, } +fn default_sound_effects() -> bool { true } + impl Default for AppPreferences { fn default() -> Self { AppPreferences { admin_consent: false, start_minimized: false, + sound_effects: true, } } } @@ -627,3 +632,23 @@ pub enum HardwareState { } fn default_pixel_shift_distance() -> u32 { 3 } fn default_pixel_shift_interval() -> u32 { 120 } + +#[cfg(test)] +mod sound_preferences_tests { + use super::AppPreferences; + + #[test] + fn old_preferences_keep_existing_values_and_default_sound_on() { + let prefs: AppPreferences = serde_json::from_str(r#"{"adminConsent":true,"startMinimized":true}"#).unwrap(); + assert!(prefs.admin_consent && prefs.start_minimized && prefs.sound_effects); + } + + #[test] + fn muted_preferences_survive_serialization() { + let prefs = AppPreferences { sound_effects: false, ..AppPreferences::default() }; + let json = serde_json::to_string(&prefs).unwrap(); + let restored: AppPreferences = serde_json::from_str(&json).unwrap(); + assert!(!restored.sound_effects); + assert!(json.contains("soundEffects")); + } +} diff --git a/tauri-app/src/App.tsx b/tauri-app/src/App.tsx index 4409f10..7666c77 100644 --- a/tauri-app/src/App.tsx +++ b/tauri-app/src/App.tsx @@ -1,6 +1,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { TopBar } from "@/components/settings/TopBar"; import { TabNav, type SettingsTab as TabKey } from "@/components/settings/TabNav"; +import { TabPanels } from "@/components/settings/TabPanels"; import { StatsTab } from "@/components/settings/stats/StatsTab"; import { StyleTab } from "@/components/settings/style/StyleTab"; import { SettingsTab } from "@/components/settings/settings/SettingsTab"; @@ -150,7 +151,7 @@ export default function App() { // purpose: raising the refusal toast, the same message an in-app clash // raises from ShortcutField. From the user's side "the other row has it" // and "another app has it" are one fact, so they get one message and the - // field itself is left completely unmarked (Saad, 2026-08-28). + // field itself is left completely unmarked. // // Raised here rather than in the field because this is where the status // lands, and the failure is only known after the save round-trips through @@ -247,23 +248,13 @@ export default function App() { 20 between the tabs and the content. */}
-
- {/* Tabs stay mounted and hide via CSS so local UI state (expanded - collapsibles, dropdowns, scroll targets) survives tab switches — - conditional rendering reset it all on every switch. */} -
- -
-
- -
-
- -
-
- -
-
+ {/* Keep panels mounted, with independent scroll positions and state. */} + , + style: , + settings: , + help: , + }} />
); diff --git a/tauri-app/src/app/components/Checkbox.tsx b/tauri-app/src/app/components/Checkbox.tsx index db53c59..9ad9fe8 100644 --- a/tauri-app/src/app/components/Checkbox.tsx +++ b/tauri-app/src/app/components/Checkbox.tsx @@ -1,98 +1,21 @@ -import * as React from "react"; -import { cva, type VariantProps } from "class-variance-authority"; +import * as React from "react"; +import { Checkbox as AppCheckbox } from "@/components/shadcn/checkbox"; import { cn } from "@/lib/utils"; -const checkboxVariants = cva( - "inline-flex cursor-pointer items-center shadow-focus-default", - { - variants: { - disabled: { - true: "cursor-not-allowed opacity-50", - }, - }, - defaultVariants: { - disabled: false, - }, - } -); +type CheckboxProps = Omit, "onCheckedChange"> & { + label?: string; + onCheckedChange?: (checked: boolean) => void; +}; -type CheckboxProps = Omit, "onChange"> & - VariantProps & { - checked?: boolean; - defaultChecked?: boolean; - onCheckedChange?: (checked: boolean) => void; - label?: string; - }; - -function Checkbox({ - className, - checked: controlledChecked, - defaultChecked = false, - disabled, - onCheckedChange, - label, - ...props -}: CheckboxProps) { - const [internalChecked, setInternalChecked] = React.useState(defaultChecked); - const isControlled = controlledChecked !== undefined; - const checked = isControlled ? controlledChecked : internalChecked; - - function handleClick() { - if (disabled) return; - const next = !checked; - if (!isControlled) setInternalChecked(next); - onCheckedChange?.(next); - } - - return ( - - ); +/** Labeled adapter; the app primitive owns all checkbox state and motion. */ +function Checkbox({ label, className, onCheckedChange, ...props }: CheckboxProps) { + const control = onCheckedChange?.(checked === true)} />; + return label ? ( + + ) : control; } - -export { Checkbox, checkboxVariants }; +export { Checkbox }; diff --git a/tauri-app/src/app/components/NavigationTabs.tsx b/tauri-app/src/app/components/NavigationTabs.tsx index c27b660..ff27f8b 100644 --- a/tauri-app/src/app/components/NavigationTabs.tsx +++ b/tauri-app/src/app/components/NavigationTabs.tsx @@ -1,109 +1,3 @@ -import * as React from "react"; -import { Slot } from "@radix-ui/react-slot"; -import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils"; - -const tabVariants = cva( - "inline-flex flex-1 min-w-0 cursor-pointer items-center justify-center gap-[var(--spacingXxxs)] rounded-[var(--cornerRound)] pl-[var(--spacingM)] pr-[var(--spacingL)] py-[var(--spacingSx)] text-body-md-medium transition-colors duration-150 shadow-focus-default", - { - variants: { - active: { - false: "bg-transparent text-[var(--componentTabsInactiveForeground)]", - true: "bg-[var(--componentTabsActiveBg)] text-[var(--componentTabsActiveForeground)] shadow-[var(--shadow-card)]", - }, - }, - defaultVariants: { - active: false, - }, - } -); - -type TabProps = React.ComponentProps<"button"> & - VariantProps & { - asChild?: boolean; - }; - -function Tab({ - className, - active, - asChild = false, - type, - ...props -}: TabProps) { - const Comp = asChild ? Slot : "button"; - return ( - - ); -} - -function TabIcon({ className, ...props }: React.ComponentProps<"span">) { - return ( -