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.
+Volume 35% Mute Keep audio ready while testing
+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 LibraryCleanmeter - Cuelume 0.2.8 Legacy - Cuelume 0.2.2 Theme Emphasisnormal subtle strong DirectionForward / on Back / off
+
+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 (
-
- {/* 24px hit area wrapping the visible 19.2px checkbox */}
-
-
- {checked ? (
-
-
-
- ) : (
-
- )}
-
-
- {label && (
-
- {label}
-
- )}
-
- );
+/** 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}
+ {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 (
-
- );
-}
-
-function TabLabel({
- className,
- asChild = false,
- ...props
-}: React.ComponentProps<"span"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "span";
- return (
-
- );
-}
-
-function NavigationTabs({
- className,
- asChild = false,
- ...props
-}: React.ComponentProps<"nav"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "nav";
- return (
-
- );
-}
-
-function NavigationTabsGroup({
- className,
- asChild = false,
- ...props
-}: React.ComponentProps<"div"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "div";
- return (
-
- );
-}
-
-export {
- Tab,
- TabIcon,
- TabLabel,
- NavigationTabs,
- NavigationTabsGroup,
- tabVariants,
-};
+// Navigation and content motion stay identical to the settings window.
+export { TabNav as NavigationTabs, type SettingsTab } from "@/components/settings/TabNav";
+export { TabPanels as NavigationTabPanels } from "@/components/settings/TabPanels";
diff --git a/tauri-app/src/app/components/Select.tsx b/tauri-app/src/app/components/Select.tsx
index 740fd11..58756d5 100644
--- a/tauri-app/src/app/components/Select.tsx
+++ b/tauri-app/src/app/components/Select.tsx
@@ -1,218 +1,25 @@
-import * as React from "react";
+import * as React from "react";
import * as SelectPrimitive from "@radix-ui/react-select";
-import { cva, type VariantProps } from "class-variance-authority";
+import { SelectTrigger as AppSelectTrigger } from "@/components/shadcn/select";
+import { SelectFieldTrigger } from "@/components/ui/SelectField";
import { cn } from "@/lib/utils";
-/* ------------------------------------------------------------------ */
-/* ChevronDown icon (matches Figma's keyboard_arrow_up rotated 180°) */
-/* ------------------------------------------------------------------ */
-function ChevronDown({ className }: { className?: string }) {
- return (
-
-
-
- );
-}
-
-/* ------------------------------------------------------------------ */
-/* Select (root re-export) */
-/* ------------------------------------------------------------------ */
-const Select = SelectPrimitive.Root;
-const SelectGroup = SelectPrimitive.Group;
-const SelectValue = SelectPrimitive.Value;
-
-/* ------------------------------------------------------------------ */
-/* Trigger */
-/* ------------------------------------------------------------------ */
-const selectTriggerVariants = cva(
- [
- "flex h-10 w-full items-center gap-[var(--spacingXs)]",
- "rounded-[var(--cornerL)] bg-[var(--bgSurfaceRaised)]",
- "px-[var(--spacingS)]",
- "group/trigger border text-body-sm-regular text-[var(--textHeading)]",
- "outline-none transition-shadow",
- "data-[placeholder]:text-[var(--textParagraph1)]",
- ].join(" "),
- {
- variants: {
- variant: {
- default: [
- "border-[var(--borderBolder)]",
- "shadow-[0px_1px_2px_0px_rgba(0,0,0,0.05)]",
-
- "focus:border-[var(--borderBrand)] focus:shadow-[0px_0px_0px_3px_var(--gray300),0px_1px_2px_0px_rgba(0,0,0,0.05)]",
- "data-[state=open]:border-[var(--borderBrand)] data-[state=open]:shadow-[0px_0px_0px_3px_var(--gray300),0px_1px_2px_0px_rgba(0,0,0,0.05)]",
- ].join(" "),
- disabled: [
- "border-[var(--borderSubtle)]",
- "text-[var(--textDisabled)] cursor-not-allowed",
- "data-[placeholder]:text-[var(--textDisabled)]",
- ].join(" "),
- },
- },
- defaultVariants: {
- variant: "default",
- },
- }
-);
-
-type SelectTriggerProps = React.ComponentProps &
- VariantProps & {
- label?: string;
- };
-
-const SelectTrigger = React.forwardRef<
- React.ComponentRef,
- SelectTriggerProps
->(({ className, label, variant, children, ...props }, ref) => (
-
- {label && (
-
- {label}
-
- )}
- {children}
-
-
-
-
-));
-SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
-
-/* ------------------------------------------------------------------ */
-/* Content (dropdown) */
-/* ------------------------------------------------------------------ */
-const SelectContent = React.forwardRef<
- React.ComponentRef,
- React.ComponentProps
->(({ className, children, position = "popper", sideOffset = 4, ...props }, ref) => (
-
-
-
- {children}
-
-
-
-));
-SelectContent.displayName = SelectPrimitive.Content.displayName;
-
-/* ------------------------------------------------------------------ */
-/* Item */
-/* ------------------------------------------------------------------ */
-const SelectItem = React.forwardRef<
- React.ComponentRef,
- React.ComponentProps
->(({ className, children, ...props }, ref) => (
-
-
-
- {children}
-
-
-
-));
-SelectItem.displayName = SelectPrimitive.Item.displayName;
+export { Select, SelectGroup, SelectValue, SelectContent, SelectItem } from "@/components/shadcn/select";
-/* ------------------------------------------------------------------ */
-/* Label (group label) */
-/* ------------------------------------------------------------------ */
-const SelectLabel = React.forwardRef<
- React.ComponentRef,
- React.ComponentProps
->(({ className, ...props }, ref) => (
-
-));
-SelectLabel.displayName = SelectPrimitive.Label.displayName;
-
-/* ------------------------------------------------------------------ */
-/* Separator */
-/* ------------------------------------------------------------------ */
-const SelectSeparator = React.forwardRef<
- React.ComponentRef,
- React.ComponentProps
->(({ className, ...props }, ref) => (
-
-));
-SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
-
-export {
- Select,
- SelectGroup,
- SelectValue,
- SelectTrigger,
- SelectContent,
- SelectItem,
- SelectLabel,
- SelectSeparator,
+type TriggerProps = React.ComponentProps & {
+ label?: string;
+ variant?: "default" | "disabled";
};
+
+/** Both forms render the same triggers used by the app. */
+export function SelectTrigger({ label, variant, disabled, ...props }: TriggerProps) {
+ return label
+ ?
+ : ;
+}
+export function SelectLabel({ className, ...props }: React.ComponentProps) {
+ return ;
+}
+export function SelectSeparator({ className, ...props }: React.ComponentProps) {
+ return ;
+}
diff --git a/tauri-app/src/app/components/Toggle.tsx b/tauri-app/src/app/components/Toggle.tsx
index d815f02..556b739 100644
--- a/tauri-app/src/app/components/Toggle.tsx
+++ b/tauri-app/src/app/components/Toggle.tsx
@@ -1,71 +1,2 @@
-import * as React from "react";
-import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "@/lib/utils";
-
-const toggleVariants = cva(
- "inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full px-[2px] transition-colors duration-150 shadow-focus-default",
- {
- variants: {
- checked: {
- false: "bg-[var(--bgSurfaceSunken)]",
- true: "bg-[var(--bgSuccessActive)]",
- },
- disabled: {
- true: "cursor-not-allowed opacity-50",
- },
- },
- defaultVariants: {
- checked: false,
- disabled: false,
- },
- }
-);
-
-type ToggleProps = Omit, "onChange"> &
- VariantProps & {
- checked?: boolean;
- defaultChecked?: boolean;
- onCheckedChange?: (checked: boolean) => void;
- };
-
-function Toggle({
- className,
- checked: controlledChecked,
- defaultChecked = false,
- disabled,
- onCheckedChange,
- ...props
-}: ToggleProps) {
- 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 (
-
- {/* Thumb */}
-
-
- );
-}
-
-export { Toggle, toggleVariants };
+// One implementation for the app and design-system consumers.
+export { Switch as Toggle } from "@/components/shadcn/switch";
diff --git a/tauri-app/src/app/components/stories/Checkbox.stories.tsx b/tauri-app/src/app/components/stories/Checkbox.stories.tsx
index b1f3c95..b46571d 100644
--- a/tauri-app/src/app/components/stories/Checkbox.stories.tsx
+++ b/tauri-app/src/app/components/stories/Checkbox.stories.tsx
@@ -7,6 +7,7 @@ const meta: Meta = {
component: Checkbox,
parameters: {
layout: "centered",
+ docs: { description: { component: "Uses the live app checkbox: transitions.dev stroke draw, rapid reversal and reduced motion. No sounds are played by the primitive; app action handlers own sound cues." } },
},
tags: ["autodocs"],
argTypes: {
@@ -22,7 +23,7 @@ type Story = StoryObj;
function InteractiveCheckbox({ defaultChecked = false, label }: { defaultChecked?: boolean; label?: string }) {
const [checked, setChecked] = useState(defaultChecked);
- return ;
+ return ;
}
export const Unchecked: Story = {
@@ -33,6 +34,10 @@ export const Checked: Story = {
render: () => ,
};
+export const Mixed: Story = {
+ render: () => ,
+};
+
export const WithLabel: Story = {
render: () => ,
};
diff --git a/tauri-app/src/app/components/stories/Interactions.stories.tsx b/tauri-app/src/app/components/stories/Interactions.stories.tsx
new file mode 100644
index 0000000..f78d699
--- /dev/null
+++ b/tauri-app/src/app/components/stories/Interactions.stories.tsx
@@ -0,0 +1,25 @@
+import { useState } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { CollapsibleCard } from "@/components/settings/style/CollapsibleCard";
+import { Disclosure } from "@/components/ui/Disclosure";
+import { Switch } from "@/components/shadcn/switch";
+import { TooltipHint } from "@/components/shadcn/tooltip";
+import { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogClose } from "@/components/shadcn/dialog";
+import { Toast } from "@/components/ui/Toast";
+import { useToastStore } from "@/stores/toast-store";
+
+const meta: Meta = {
+ title: "Components/Interactions",
+ parameters: { layout: "centered", docs: { description: { component: "The live app's accordion, panel, dialog, toast and tooltip implementations. Motion comes from transitions.dev snippets. Use the OS/browser reduced-motion setting to verify instant states. These demos do not emit sounds." } } },
+};
+export default meta;
+type Story = StoryObj;
+export const Accordion: Story = { render: () => Preserved input
};
+function PanelExample() {
+ const [open, setOpen] = useState(false);
+ return Show options
;
+}
+export const Panel: Story = { render: () => };
+export const Modal: Story = { render: () => Open dialog Example dialog Close };
+export const Tooltip: Story = { render: () => Hover or focus };
+export const ToastRepeat: Story = { render: () => useToastStore.getState().showToast("Shortcut already in use")}>Show or repeat toast
};
diff --git a/tauri-app/src/app/components/stories/NavigationTabs.stories.tsx b/tauri-app/src/app/components/stories/NavigationTabs.stories.tsx
index 811b155..b98d58c 100644
--- a/tauri-app/src/app/components/stories/NavigationTabs.stories.tsx
+++ b/tauri-app/src/app/components/stories/NavigationTabs.stories.tsx
@@ -1,120 +1,33 @@
-import { useState } from "react";
+import { useId, useState } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
-import {
- NavigationTabs,
- NavigationTabsGroup,
- Tab,
- TabIcon,
- TabLabel,
-} from "../NavigationTabs";
+import { NavigationTabs, NavigationTabPanels, type SettingsTab } from "../NavigationTabs";
const meta: Meta = {
title: "Components/NavigationTabs",
component: NavigationTabs,
parameters: {
layout: "centered",
+ docs: { description: { component: "Uses the live app's TabNav and TabPanels: sliding indicator and Page side-by-side content. State and scrolling survive navigation; reduced motion switches instantly." } },
},
tags: ["autodocs"],
};
-
export default meta;
type Story = StoryObj;
-/* ── Icons from Figma (Material Symbols, 20×20) ── */
-
-function StatsIcon() {
- return (
-
-
-
- );
-}
-
-function LayersIcon() {
- return (
-
-
-
- );
-}
-
-function SettingsIcon() {
- return (
-
-
-
- );
-}
-
-function HelpIcon() {
+function InteractiveTabs({ defaultTab = "stats" }: { defaultTab?: SettingsTab }) {
+ const idPrefix = useId();
+ const [activeTab, setActiveTab] = useState(defaultTab);
return (
-
-
-
- );
-}
-
-/* ── Interactive demo with state ── */
-
-const tabs = [
- { id: "stats", label: "Stats", icon: StatsIcon },
- { id: "style", label: "Style", icon: LayersIcon },
- { id: "settings", label: "Settings", icon: SettingsIcon },
- { id: "help", label: "Help", icon: HelpIcon },
-] as const;
-
-function InteractiveTabs({ defaultTab = "stats" }: { defaultTab?: string }) {
- const [active, setActive] = useState(defaultTab);
- return (
-
-
- {tabs.map(({ id, label, icon: Icon }) => (
- setActive(id)}
- >
-
- {label}
-
- ))}
-
-
+
+
+
Stats Preserved input Scroll this panel and return to verify its position.
,
+ style: Style controls
,
+ settings: Settings controls
,
+ help: Help content
,
+ }} />
+
);
}
-
-export const Default: Story = {
- render: () => ,
-};
-
-export const StyleActive: Story = {
- render: () => ,
-};
-
-export const AllVariants: Story = {
- render: () => (
-
-
-
- Default — icon + label (click tabs to switch)
-
-
-
-
-
- Individual tab states
-
-
-
-
- Inactive
-
-
-
- Active
-
-
-
-
- ),
-};
+export const Default: Story = { render: () => };
+export const StyleActive: Story = { render: () => };
diff --git a/tauri-app/src/app/components/stories/Select.stories.tsx b/tauri-app/src/app/components/stories/Select.stories.tsx
index 06f144f..0b3473a 100644
--- a/tauri-app/src/app/components/stories/Select.stories.tsx
+++ b/tauri-app/src/app/components/stories/Select.stories.tsx
@@ -15,6 +15,7 @@ const meta: Meta = {
component: Select,
parameters: {
layout: "centered",
+ docs: { description: { component: "Uses the live app's shared dropdown content and standard/pill triggers. Open/close timing, anchored origin and reduced-motion behavior come from the app stylesheet." } },
},
tags: ["autodocs"],
};
diff --git a/tauri-app/src/app/components/stories/Toggle.stories.tsx b/tauri-app/src/app/components/stories/Toggle.stories.tsx
index 78e2fb0..26a8a34 100644
--- a/tauri-app/src/app/components/stories/Toggle.stories.tsx
+++ b/tauri-app/src/app/components/stories/Toggle.stories.tsx
@@ -7,6 +7,7 @@ const meta: Meta = {
component: Toggle,
parameters: {
layout: "centered",
+ docs: { description: { component: "Re-exports the live app Switch. Uses transitions.dev double-bounce keyframes; no startup bounce, rapid reversals retarget and reduced motion disables animation." } },
},
tags: ["autodocs"],
argTypes: {
@@ -21,7 +22,7 @@ type Story = StoryObj;
function InteractiveToggle({ defaultChecked = false }: { defaultChecked?: boolean }) {
const [checked, setChecked] = useState(defaultChecked);
- return ;
+ return ;
}
export const Off: Story = {
@@ -35,8 +36,8 @@ export const On: Story = {
export const Disabled: Story = {
render: () => (
-
-
+
+
),
};
diff --git a/tauri-app/src/app/disclosure-motion.css b/tauri-app/src/app/disclosure-motion.css
new file mode 100644
index 0000000..d21fec8
--- /dev/null
+++ b/tauri-app/src/app/disclosure-motion.css
@@ -0,0 +1,153 @@
+/* Motion tokens from the CLI snippets retained in transitions/. */
+:root {
+ --acc-expand: 250ms;
+ --acc-collapse: 250ms;
+ --acc-chevron: 250ms;
+ --acc-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+/* Flip the chevron vertically to turn the "v" into a "^".
+ scaleY(-1) about the centre passes through a flat line at
+ the midpoint (same look as a `d:` path morph) but animates
+ in every browser, unlike CSS `d:` morphing (Chromium only).
+ The chevron path is symmetric about the 16x16 viewBox
+ centre, so the flip lands exactly on the "^"; non-scaling
+ -stroke keeps the stroke width constant through the flip. */
+.t-acc-chevron {
+ display: inline-flex;
+ transform: scaleY(1);
+ transform-origin: center;
+ transition: transform var(--acc-chevron) var(--acc-ease);
+}
+.t-acc-chevron path { vector-effect: non-scaling-stroke; }
+.t-acc[data-open="true"] .t-acc-chevron {
+ transform: scaleY(-1);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .t-acc-chevron {
+ transition: none !important;
+ }
+}
+
+:root {
+ --panel-open-dur: 400ms;
+ --panel-close-dur: 350ms;
+ --panel-translate-y: 100px;
+ --panel-blur: 2px;
+ --panel-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+.t-panel-slide {
+ transform: translateY(var(--panel-translate-y));
+ opacity: 0;
+ filter: blur(var(--panel-blur));
+ pointer-events: none;
+ transition:
+ transform var(--panel-close-dur) var(--panel-ease),
+ opacity var(--panel-close-dur) var(--panel-ease),
+ filter var(--panel-close-dur) var(--panel-ease);
+
+}
+.t-panel-slide[data-open="true"] {
+ transform: translateY(0);
+ opacity: 1;
+ filter: blur(0);
+ pointer-events: auto;
+ transition:
+ transform var(--panel-open-dur) var(--panel-ease),
+ opacity var(--panel-open-dur) var(--panel-ease),
+ filter var(--panel-open-dur) var(--panel-ease);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .t-panel-slide { transition: none !important; }
+}
+
+:root {
+ --resize-dur: 300ms;
+ --resize-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+:root {
+ --modal-open-dur: 250ms;
+ --modal-close-dur: 150ms;
+ --modal-scale: 0.96;
+ --modal-scale-close: 0.96;
+ --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+:root {
+ --toast-open: 350ms;
+ --toast-close: 250ms;
+ --toast-distance: 16px;
+ --toast-blur: 2px;
+ --toast-scale: 0.97;
+ --toast-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+.t-toast {
+ opacity: 0;
+ transform: translateY(var(--toast-distance)) scale(var(--toast-scale));
+ filter: blur(var(--toast-blur));
+
+ transition:
+ opacity var(--toast-close) var(--toast-ease),
+ transform var(--toast-close) var(--toast-ease),
+ filter var(--toast-close) var(--toast-ease);
+}
+.t-toast.is-open {
+ opacity: 1;
+ transform: translateY(0) scale(1);
+ filter: blur(0);
+ transition:
+ opacity var(--toast-open) var(--toast-ease),
+ transform var(--toast-open) var(--toast-ease),
+ filter var(--toast-open) var(--toast-ease);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .t-toast { transition: none !important; }
+}
+
+:root {
+ --tt-in-dur: 150ms;
+ --tt-out-dur: 50ms;
+ --tt-scale: 0.98;
+ --tt-delay: 80ms;
+ --tt-in-ease: ease-out;
+ --tt-out-ease: ease-out;
+}
+
+
+/* Keep existing measured-height behavior so open controls/focus rings aren't clipped.
+ Card resize supplies the height timing for feature panels, accordion for disclosures. */
+.app-disclosure { transition: height var(--acc-collapse) var(--acc-ease); }
+.app-disclosure[data-open="true"] { transition-duration: var(--acc-expand); }
+.app-disclosure[data-motion="panel"] { transition: height var(--resize-dur) var(--resize-ease); }
+.app-accordion-body { opacity: 0; filter: blur(2px); transition: opacity var(--acc-collapse) var(--acc-ease), filter var(--acc-collapse) var(--acc-ease); }
+.app-disclosure[data-open="true"] > .app-accordion-body { opacity: 1; filter: blur(0); transition-duration: var(--acc-expand); }
+/* Compact in-card disclosures use a short travel; no desktop window movement. */
+.app-panel-body { --panel-translate-y: 8px; }
+/* Radix presence uses keyframes for exit lifetime; geometry/tokens match the snippet.
+ CSS transform is independent of the centering translate utility. */
+[data-slot="dialog-content"] { transform-origin: center; }
+[data-slot="dialog-content"][data-state="open"] { animation: app-modal-enter var(--modal-open-dur) var(--modal-ease); }
+[data-slot="dialog-content"][data-state="closed"] { animation: app-modal-exit var(--modal-close-dur) var(--modal-ease); pointer-events: none; }
+[data-slot="dialog-overlay"][data-state="open"] { animation: app-backdrop-enter var(--modal-open-dur) var(--modal-ease); }
+[data-slot="dialog-overlay"][data-state="closed"] { animation: app-backdrop-exit var(--modal-close-dur) var(--modal-ease); }
+@keyframes app-modal-enter { from { opacity: 0; transform: scale(var(--modal-scale)); } to { opacity: 1; transform: scale(1); } }
+@keyframes app-modal-exit { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(var(--modal-scale-close)); } }
+@keyframes app-backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
+@keyframes app-backdrop-exit { from { opacity: 1; } to { opacity: 0; } }
+[data-slot="tooltip-content"] { transform-origin: var(--radix-tooltip-content-transform-origin); }
+[data-slot="tooltip-content"][data-state="delayed-open"],
+[data-slot="tooltip-content"][data-state="instant-open"] { animation: app-tooltip-enter var(--tt-in-dur) var(--tt-in-ease); }
+[data-slot="tooltip-content"][data-state="closed"] { animation: app-tooltip-exit var(--tt-out-dur) var(--tt-out-ease); }
+@keyframes app-tooltip-enter { from { opacity: 0; transform: scale(var(--tt-scale)); } to { opacity: 1; transform: scale(1); } }
+@keyframes app-tooltip-exit { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(var(--tt-scale)); } }
+@media (prefers-reduced-motion: reduce) {
+ .app-disclosure, .app-accordion-body, .t-panel-slide, .t-toast { transition: none !important; }
+ .app-accordion-body, .t-panel-slide, .t-toast { filter: none; transform: none; }
+ [data-slot="dialog-content"][data-state], [data-slot="dialog-overlay"][data-state], [data-slot="tooltip-content"][data-state] { animation: none !important; }
+}
diff --git a/tauri-app/src/app/globals.css b/tauri-app/src/app/globals.css
index 07beff8..df69b76 100644
--- a/tauri-app/src/app/globals.css
+++ b/tauri-app/src/app/globals.css
@@ -3,6 +3,8 @@
@import "./tokens.css";
@import "./tokens-dark.css";
@import "./tokens-typography.css";
+@import "./motion.css";
+@import "./disclosure-motion.css";
/* ============================================================
Semantic aliases
@@ -271,142 +273,6 @@ body {
}
}
- /* The hotkey-conflict toast, Figma 2819:9753. Beats are in Toast.tsx.
-
- Transitions rather than @keyframes: the toast can be re-raised while it
- is still animating (press an already-bound combo twice), and a
- transition carries on from wherever the element currently is, where a
- keyframe restarts at its first frame and reads as a jump back to
- hidden mid-exit.
-
- ## The entrance curve
-
- This started on the collapsible's cubic-bezier(0.165, 0.84, 0.44, 1) —
- easeOutQuart — and read as abrupt, which is what that curve is FOR:
- it is 13% through its travel in the first 3% of its time, so an element
- arriving from nothing appears to snap into place and then creep. Fine
- for a panel that is already on screen changing height. Wrong for
- something materialising.
-
- The replacement is a real critically-damped spring, sampled to
- linear(): omega*T = 9.2334 (the value where a bounce-0 spring is within
- 0.1% of target at t = duration), x(t) = 1 - (1 + omega*t)e^(-omega*t),
- 21 stops. Monotonic with zero overshoot by construction — the damping
- ratio is exactly 1 — so nothing wobbles; it just eases out of nothing
- and settles. 8% of travel in the first 5% of time, against easeOutQuart's
- 20%.
-
- ## The travel
-
- It used to be parked at `calc(-100% - 52px)` — entirely above the title
- bar's lower edge — and slide 104px out from under it, with the opaque bar
- acting as the mask. That is wrong, and the video shows exactly how
- (Saad, 2026-08-28):
-
- frame 66 pill's top half sheared flat by the bar, already dark
- frame 67 top edge flush on the bar's edge at ~0.84 opacity
- frame 70 fully out, opaque, still 5px of travel left
-
- An opaque mask does not soften anything — it CUTS. The pill spent its
- whole opacity ramp hidden behind the bar, then arrived at the edge
- already 84% opaque with a hard flat top where the chrome had clipped it.
- Adding a fade to that (the first attempt) changed nothing visible,
- because the fade was finishing in the part nobody could see. A mask is
- not a transition.
-
- So it no longer goes near the bar. It parks 16px above where it lands and
- fades in over that, which puts the whole animation in open space:
-
- resting top 76 (the positioner, Figma 2819:9753)
- bar lower edge 52
- headroom 24 76 - 52
- park -16px 8px of clearance, never intersects the bar
-
- 16 rather than the full 24 so the shadow clears too. `--shadow-large` is
- `0 4px 24px`, which reaches about 8px above the pill's top edge once the
- 4px downward offset is taken off the blur — at the park that puts its
- outer edge right on the bar's, and opacity is 0 there anyway.
-
- ## The fade
-
- Undelayed now, and it is the substance of the entrance rather than a
- coat on top of one. Nothing is hidden any more, so there is nothing to
- wait for — the pill is on screen from the first frame and every bit of
- the ramp is visible. The 50ms delay the previous attempt used existed
- only to skip the stretch behind the bar; with the bar out of the path it
- would just be dead air.
-
- Durations came down with the distance. 420ms was paced for 104px of
- travel; over 16px it crawls, so the move is 300ms and the fade 260ms,
- landing just before the spring settles onto its mark. The exit reverses
- it at 220/180, faster than the arrival because an exit nobody is waiting
- on should leave rather than be admired.
-
- The fade's curve is a plain ease-out, NOT the sharply front-loaded
- cubic-bezier(0.22, 1, 0.36, 1) the travel-based version used. That curve
- is 32% opaque within one frame, which at 16px of travel reads as the pill
- popping on and then sliding — the fade is over before the movement has
- started. Measured: 0.32 / 0.56 / 0.73 / 0.84 on the first four frames,
- essentially done in 67ms of a 220ms ramp. A curve that steep is right for
- covering distance, wrong for carrying an arrival on its own. ease-out is
- ~0.12 after one frame and tracks the slide the rest of the way down.
-
- The z-order below the title bar stays as it is. It is no longer load-
- bearing — nothing overlaps the bar now — but it is the right relationship
- if a longer message ever wraps to two lines and grows upward.
-
- prefers-reduced-motion keeps its own pair below: with the travel
- suppressed the fade carries the whole arrival on its own. */
- .cm-toast {
- transition:
- transform 300ms linear(
- 0, 0.0788, 0.2361, 0.403, 0.5509, 0.6711, 0.7638, 0.8329, 0.8832,
- 0.9191, 0.9445, 0.9621, 0.9743, 0.9827, 0.9884, 0.9922, 0.9948,
- 0.9965, 0.9977, 0.9985, 1
- ),
- opacity 260ms cubic-bezier(0, 0, 0.58, 1);
- }
- .cm-toast[data-state="open"] {
- opacity: 1;
- transform: translateY(0);
- }
- /* Also the mount state, so there is a closed frame to transition out of.
-
- The exit is one curve on both properties — faster than the arrival,
- because an exit nobody is waiting on should leave rather than be admired,
- and cubic-bezier(0.32, 0.72, 0, 1) rather than the spring because a
- spring's long settle is exactly wrong for going away: it would hold the
- toast creeping through its last few pixels instead of getting back under
- the bar.
-
- Opacity runs shorter than the transform (180 against 220) so the pill is
- gone before the move finishes, rather than sliding away solid and
- vanishing on unmount. Both stay at or under EXIT_MS in Toast.tsx, which
- is what holds the element mounted for the whole way out. */
- .cm-toast[data-state="closed"] {
- opacity: 0;
- transform: translateY(-16px);
- transition:
- transform 220ms cubic-bezier(0.32, 0.72, 0, 1),
- opacity 180ms cubic-bezier(0.32, 0.72, 0, 1);
- }
- /* Gentler, not off. With the travel suppressed the fade is all that is
- left, so it runs a touch longer than the motion path's to keep the
- arrival from reading as a pop. */
- @media (prefers-reduced-motion: reduce) {
- .cm-toast {
- transition: opacity 240ms cubic-bezier(0.32, 0.72, 0, 1);
- }
- .cm-toast[data-state="open"] {
- opacity: 1;
- transform: none;
- }
- .cm-toast[data-state="closed"] {
- opacity: 0;
- transform: none;
- transition: opacity 200ms cubic-bezier(0.32, 0.72, 0, 1);
- }
- }
}
/* ============================================================
diff --git a/tauri-app/src/app/motion.css b/tauri-app/src/app/motion.css
new file mode 100644
index 0000000..523e5f0
--- /dev/null
+++ b/tauri-app/src/app/motion.css
@@ -0,0 +1,138 @@
+/* Restrained adaptations of transitions.dev tabs, toggle and menu demos.
+ Transitions retarget from the current position when input is interrupted. */
+:root {
+ --motion-settle: cubic-bezier(0.22, 1, 0.36, 1);
+ --motion-toggle: cubic-bezier(0.34, 1.35, 0.64, 1);
+}
+
+.app-tab-indicator {
+ transition: transform 250ms var(--motion-settle);
+}
+
+/* transitions.dev Page side-by-side: 8px travel, 3px blur, 250ms settle.
+ Inactive pages stay mounted but cannot receive focus or pointer input. */
+.app-tab-panel {
+ opacity: 0;
+ filter: blur(3px);
+ visibility: hidden;
+ pointer-events: none;
+ transition: transform 250ms var(--motion-settle),
+ opacity 250ms var(--motion-settle), filter 250ms var(--motion-settle),
+ visibility 0s 250ms;
+}
+
+.app-tab-panel[data-active="true"] {
+ opacity: 1;
+ filter: blur(0);
+ visibility: visible;
+ pointer-events: auto;
+ transition-delay: 0s;
+}
+
+/* CLI snippets from transitions/; Radix supplies the state attributes. */
+:root {
+ --check-box: 150ms;
+ --check-draw: 350ms;
+ --check-delay: 0ms;
+ --check-uncheck: 150ms;
+ --check-ease: cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+.t-check-box {
+ transition:
+ background var(--check-box) var(--check-ease),
+ box-shadow var(--check-box) var(--check-ease);
+}
+.t-check svg path {
+ stroke-dasharray: var(--check-len, 15);
+ stroke-dashoffset: var(--check-len, 15);
+ transition: stroke-dashoffset var(--check-uncheck) var(--check-ease);
+}
+.t-check[aria-checked="true"] svg path {
+ stroke-dashoffset: 0;
+ transition: stroke-dashoffset var(--check-draw) var(--check-ease) var(--check-delay);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .t-check, .t-check svg path { transition: none !important; }
+}
+
+:root {
+ --toggle-dur: 350ms;
+ --toggle-travel: 14.66px;
+ --toggle-ov1: 1px;
+ --toggle-ov2: 0px;
+ --toggle-track: 0ms;
+ --toggle-ease: cubic-bezier(0.34, 1.35, 0.64, 1);
+}
+
+.t-toggle { transition: background var(--toggle-track) var(--toggle-ease); }
+.t-toggle-thumb { translate: 0 0; }
+.t-toggle[data-state="checked"] .t-toggle-thumb { translate: var(--toggle-travel) 0; }
+.t-toggle.is-init[data-state="checked"] .t-toggle-thumb { animation: t-toggle-on var(--toggle-dur) var(--toggle-ease) both; }
+.t-toggle.is-init[data-state="unchecked"] .t-toggle-thumb { animation: t-toggle-off var(--toggle-dur) var(--toggle-ease) both; }
+@keyframes t-toggle-on {
+ 0% { translate: var(--toggle-from, 0px) 0; }
+ 55% { translate: calc(var(--toggle-travel) + var(--toggle-ov1)) 0; }
+ 80% { translate: calc(var(--toggle-travel) - var(--toggle-ov2)) 0; }
+ 100% { translate: var(--toggle-travel) 0; }
+}
+@keyframes t-toggle-off {
+ 0% { translate: var(--toggle-from, var(--toggle-travel)) 0; }
+ 55% { translate: calc(0px - var(--toggle-ov1)) 0; }
+ 80% { translate: var(--toggle-ov2) 0; }
+ 100% { translate: 0 0; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .t-toggle-thumb { animation: none !important; }
+}
+
+/* Adapt travel to the existing 36x20 track; preserve the reference bounce. */
+.t-toggle { --toggle-travel: 16px; }
+.t-check { --check-len: 15; }
+.app-checkbox-inset { opacity: 1; transition: opacity var(--check-box) var(--check-ease); }
+[data-slot="checkbox"]:not([data-state="unchecked"]) .app-checkbox-inset { opacity: 0; }
+.app-checkbox-mixed { visibility: hidden; }
+[data-slot="checkbox"][data-state="indeterminate"] .app-checkbox-mixed { visibility: visible; }
+[data-slot="checkbox"][data-state="indeterminate"] .app-checkbox-check { visibility: hidden; }
+@media (prefers-reduced-motion: reduce) { .t-check-box { transition: none !important; } }
+
+[data-slot="select-content"] {
+ transform-origin: var(--radix-select-content-transform-origin, center);
+}
+
+[data-slot="select-content"][data-state="open"] {
+ animation: app-select-enter 250ms var(--motion-settle);
+}
+
+[data-slot="select-content"][data-state="closed"] {
+ animation: app-select-exit 150ms var(--motion-settle);
+ pointer-events: none;
+}
+
+@keyframes app-select-enter {
+ from { opacity: 0; transform: scale(0.96); }
+ to { opacity: 1; transform: scale(1); }
+}
+
+@keyframes app-select-exit {
+ from { opacity: 1; transform: scale(1); }
+ to { opacity: 0; transform: scale(0.96); }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .app-tab-indicator,
+ .app-tab-panel,
+ .app-checkbox-draw,
+ .app-checkbox-indicator,
+ .app-checkbox-inset,
+ [data-slot="switch"],
+ [data-slot="switch-thumb"] {
+ transition: none;
+ }
+
+ [data-slot="select-content"][data-state] {
+ animation: none;
+ }
+}
diff --git a/tauri-app/src/components/settings/TabNav.tsx b/tauri-app/src/components/settings/TabNav.tsx
index 57930f4..a0bbda9 100644
--- a/tauri-app/src/components/settings/TabNav.tsx
+++ b/tauri-app/src/components/settings/TabNav.tsx
@@ -4,6 +4,7 @@ import { StatsIcon, StyleIcon, SettingsIcon, HelpIcon } from "./tab-icons";
export type SettingsTab = "stats" | "style" | "settings" | "help";
interface TabNavProps {
+ idPrefix?: string;
activeTab: SettingsTab;
onTabChange: (tab: SettingsTab) => void;
}
@@ -19,7 +20,7 @@ const TABS: {
{ value: "help", label: "Help", Icon: HelpIcon },
];
-export function TabNav({ activeTab, onTabChange }: TabNavProps) {
+export function TabNav({ activeTab, onTabChange, idPrefix = "" }: TabNavProps) {
const activeIndex = TABS.findIndex((t) => t.value === activeTab);
return (
@@ -32,7 +33,7 @@ export function TabNav({ activeTab, onTabChange }: TabNavProps) {
className={cn(
"pointer-events-none absolute left-1 top-1 bottom-1 rounded-full bg-card",
"shadow-[0_4px_4px_0_rgba(0,0,0,0.02)]",
- "transition-transform duration-300 ease-out motion-reduce:transition-none",
+ "app-tab-indicator",
)}
style={{
width: `calc((100% - 0.5rem) / ${TABS.length})`,
@@ -45,6 +46,8 @@ export function TabNav({ activeTab, onTabChange }: TabNavProps) {
onTabChange(value)}
className={cn(
diff --git a/tauri-app/src/components/settings/TabPanels.tsx b/tauri-app/src/components/settings/TabPanels.tsx
new file mode 100644
index 0000000..44ec2de
--- /dev/null
+++ b/tauri-app/src/components/settings/TabPanels.tsx
@@ -0,0 +1,31 @@
+import type { ReactNode } from "react";
+import type { SettingsTab } from "./TabNav";
+
+const ORDER: SettingsTab[] = ["stats", "style", "settings", "help"];
+
+export function TabPanels({ activeTab, panels, idPrefix = "" }: {
+ idPrefix?: string;
+ activeTab: SettingsTab;
+ panels: Record;
+}) {
+ const activeIndex = ORDER.indexOf(activeTab);
+ return (
+
+ {ORDER.map((tab, index) => (
+
+ {panels[tab]}
+
+ ))}
+
+ );
+}
diff --git a/tauri-app/src/components/settings/TopBar.tsx b/tauri-app/src/components/settings/TopBar.tsx
index 4c3876e..dad42a2 100644
--- a/tauri-app/src/components/settings/TopBar.tsx
+++ b/tauri-app/src/components/settings/TopBar.tsx
@@ -1,6 +1,7 @@
import { Minus, X } from "lucide-react";
import { isBrowser } from "@/lib/tauri";
import { cn } from "@/lib/utils";
+import { TooltipHint } from "@/components/shadcn/tooltip";
const DEFAULT_HEIGHT = 900;
@@ -65,10 +66,10 @@ function ChromeButton({
children: React.ReactNode;
}) {
return (
-
{children}
-
+
);
}
diff --git a/tauri-app/src/components/settings/help/HelpTab.tsx b/tauri-app/src/components/settings/help/HelpTab.tsx
index 6933374..5d716db 100644
--- a/tauri-app/src/components/settings/help/HelpTab.tsx
+++ b/tauri-app/src/components/settings/help/HelpTab.tsx
@@ -1,4 +1,5 @@
import * as React from "react";
+import { playSound, beginSoundAction } from "@/lib/sound-effects";
import { cn } from "@/lib/utils";
import { FaqSection } from "./FaqSection";
import { AboutSection } from "./AboutSection";
@@ -23,16 +24,19 @@ function ResetSettingsPrompt() {
const reset = async () => {
if (pending) return;
+ const finishSound = beginSoundAction();
setPending(true);
setComplete(false);
setError(null);
try {
await clearSettings();
+ finishSound("success");
setComplete(true);
setOpen(false);
} catch (error) {
console.error("Reset settings failed:", error);
setError("Couldn't reset all settings. Please try again.");
+ finishSound("error");
} finally {
setPending(false);
}
@@ -81,7 +85,7 @@ function FeedbackPrompt() {
setOpen(true)}
+ onClick={() => { setOpen(true); playSound("open", "forward", { volume: 0.5, emphasis: "subtle" }); }}
className={cn(
helpButtonClassName,
"text-[var(--textHeading)]",
diff --git a/tauri-app/src/components/settings/settings/FeedbackDialog.tsx b/tauri-app/src/components/settings/settings/FeedbackDialog.tsx
index 6682d96..a320006 100644
--- a/tauri-app/src/components/settings/settings/FeedbackDialog.tsx
+++ b/tauri-app/src/components/settings/settings/FeedbackDialog.tsx
@@ -1,4 +1,5 @@
import * as React from "react";
+import { beginSoundAction, playSound } from "@/lib/sound-effects";
import {
Dialog,
DialogClose,
@@ -131,6 +132,7 @@ export function FeedbackDialog({
const handleSubmit = async () => {
if (!canSubmit) return;
+ const finishSound = beginSoundAction();
setStatus("submitting");
try {
await submitFeedback({
@@ -140,10 +142,12 @@ export function FeedbackDialog({
includeDiagnostics,
});
onOpenChange(false);
+ finishSound("success");
} catch (err) {
// Surface the underlying Rust error (e.g. "request failed", "portal
// returned 401") so failures are diagnosable instead of opaque.
console.error("submit_feedback failed:", err);
+ finishSound("error");
setError(`Couldn’t send feedback: ${errorText(err)}`);
setStatus("error");
}
@@ -257,7 +261,7 @@ export function FeedbackDialog({
{ setIncludeDiagnostics(value); playSound("press"); }}
disabled={submitting}
label="Include system specs and app logs"
className="w-full rounded-[4px] text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1"
diff --git a/tauri-app/src/components/settings/settings/PixelShiftControls.tsx b/tauri-app/src/components/settings/settings/PixelShiftControls.tsx
index afcf391..f95f13c 100644
--- a/tauri-app/src/components/settings/settings/PixelShiftControls.tsx
+++ b/tauri-app/src/components/settings/settings/PixelShiftControls.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { Select, SelectContent, SelectItem, SelectValue } from "@/components/shadcn/select";
import { SelectFieldTrigger } from "@/components/ui/SelectField";
import { useSettingsStore } from "@/stores/settings-store";
@@ -26,7 +27,7 @@ const FIELDS = [
/** Figma 3041:6501: the sunken panel under the Pixel Shift row. */
export function PixelShiftControls() {
const settings = useSettingsStore((s) => s.settings);
- const update = useSettingsStore((s) => s.updateSettings);
+ const update = settingsActions.updateSettings;
const { distance, interval } = pixelShiftOptions(settings);
const values = { pixelShiftDistance: distance, pixelShiftInterval: interval };
diff --git a/tauri-app/src/components/settings/settings/SettingsTab.tsx b/tauri-app/src/components/settings/settings/SettingsTab.tsx
index cad53a2..3b88539 100644
--- a/tauri-app/src/components/settings/settings/SettingsTab.tsx
+++ b/tauri-app/src/components/settings/settings/SettingsTab.tsx
@@ -1,3 +1,5 @@
+import { settingsActions } from "@/lib/settings-actions";
+import { playSound, beginSoundAction } from "@/lib/sound-effects";
import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import { Checkbox } from "@/components/shadcn/checkbox";
@@ -28,6 +30,7 @@ import {
} from "./icons";
import { ShortcutField } from "@/components/ui/ShortcutField";
import { PixelShiftControls } from "./PixelShiftControls";
+import { Disclosure } from "@/components/ui/Disclosure";
import { OVERLAY_SHORTCUT_DEFAULT, RECORDING_SHORTCUT_DEFAULT } from "@/lib/types";
function SectionCard({
@@ -49,9 +52,11 @@ function SectionCard({
function GeneralSection() {
const startMinimized = useSettingsStore((s) => s.preferences.startMinimized);
+ const soundEffects = useSettingsStore((s) => s.preferences.soundEffects);
+ const preferencesLoaded = useSettingsStore((s) => s.preferencesLoaded);
const updatePreferences = useSettingsStore((s) => s.updatePreferences);
const pixelShift = useSettingsStore((s) => s.settings.pixelShift);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const [startWithWindows, setStartWithWindows] = React.useState(false);
// Rapid toggles fire concurrent setAutoStart calls that can resolve out
// of order, leaving the checkbox out of sync with the OS registry.
@@ -67,9 +72,11 @@ function GeneralSection() {
}, []);
const handleStartWithWindows = (enabled: boolean) => {
+ const finishSound = beginSoundAction();
setAutoStartPending(true);
setStartWithWindows(enabled);
setAutoStart(enabled)
+ .then(() => finishSound("press"))
.catch(() => setStartWithWindows(!enabled))
.finally(() => setAutoStartPending(false));
};
@@ -91,16 +98,34 @@ function GeneralSection() {
- updatePreferences({ startMinimized: v === true })
+ { updatePreferences({ startMinimized: v === true }); playSound("press"); }
}
/>
Start minimized
+
+
+ Sound effects
+ Play subtle sounds when changing settings. Turn off to silence all effects.
+
+
{
+ updatePreferences({ soundEffects: value });
+ if (value) playSound("toggle");
+ }}
+ />
+
+
{/* Figma 3041:6524: the row and its settings panel sit 16 apart. */}
-
+
{/* No optical nudge: the exported glyph carries Figma's own 1.67
@@ -121,7 +146,7 @@ function GeneralSection() {
aria-label="Pixel Shift"
/>
- {pixelShift &&
}
+
);
@@ -151,7 +176,7 @@ function GeneralSection() {
*/
function ShortcutsSection() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const overlayAccelerator = settings.overlayShortcut ?? OVERLAY_SHORTCUT_DEFAULT;
const recordingAccelerator = settings.recordingShortcut ?? RECORDING_SHORTCUT_DEFAULT;
@@ -204,7 +229,7 @@ function FigmaRadio({ value }: { value: string }) {
function TemperatureUnitsSection() {
const temperatureUnit = useSettingsStore((s) => s.settings.temperatureUnit);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
return (
@@ -230,7 +255,7 @@ function TemperatureUnitsSection() {
function PollingRateSection() {
const pollingRate = useSettingsStore((s) => s.settings.pollingRate);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
return (
@@ -275,7 +300,7 @@ const THEME_OPTIONS: {
function AppearanceSection() {
const themeMode = useSettingsStore((s) => s.settings.themeMode);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const handleThemeChange = (value: ThemeChoice) => {
if (value === "light") {
diff --git a/tauri-app/src/components/settings/stats/CpuSection.tsx b/tauri-app/src/components/settings/stats/CpuSection.tsx
index 761e44b..3a3fe92 100644
--- a/tauri-app/src/components/settings/stats/CpuSection.tsx
+++ b/tauri-app/src/components/settings/stats/CpuSection.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useRef } from "react";
import type { Hardware, Sensor } from "@/lib/types";
import { HardwareType, SensorType } from "@/lib/types";
@@ -15,7 +16,7 @@ interface Props {
export function CpuSection({ sensors, hardwares }: Props) {
const settings = useSettingsStore((s) => s.settings);
- const updateSensor = useSettingsStore((s) => s.updateSensor);
+ const updateSensor = settingsActions.updateSensor;
const updateBoundary = useSettingsStore((s) => s.updateBoundary);
const graphEnabled = settings.progressType !== "none";
const { cpuUsage, cpuTemp, cpuConsumption, cpuClock } = settings.sensors;
diff --git a/tauri-app/src/components/settings/stats/FpsSection.tsx b/tauri-app/src/components/settings/stats/FpsSection.tsx
index 0757b1d..c788d87 100644
--- a/tauri-app/src/components/settings/stats/FpsSection.tsx
+++ b/tauri-app/src/components/settings/stats/FpsSection.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useRef } from "react";
import { Checkbox } from "@/components/shadcn/checkbox";
import {
@@ -26,7 +27,7 @@ type FpsReading = (typeof FPS_READINGS)[number];
export function FpsSection() {
const settings = useSettingsStore((s) => s.settings);
- const updateSensor = useSettingsStore((s) => s.updateSensor);
+ const updateSensor = settingsActions.updateSensor;
const presentMonApps = useSettingsStore((s) => s.presentMonApps);
const { framerate, frametime, onePercentLow, zeroPointOnePercentLow } = settings.sensors;
const anyEnabled = FPS_READINGS.some((key) => settings.sensors[key].isEnabled);
diff --git a/tauri-app/src/components/settings/stats/GpuSection.tsx b/tauri-app/src/components/settings/stats/GpuSection.tsx
index a46c9d6..500fd4c 100644
--- a/tauri-app/src/components/settings/stats/GpuSection.tsx
+++ b/tauri-app/src/components/settings/stats/GpuSection.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useRef } from "react";
import type { Hardware, Sensor } from "@/lib/types";
import { SensorType } from "@/lib/types";
@@ -22,10 +23,10 @@ interface Props {
export function GpuSection({ sensors, hardwares }: Props) {
const settings = useSettingsStore((s) => s.settings);
- const updateSensor = useSettingsStore((s) => s.updateSensor);
+ const updateSensor = settingsActions.updateSensor;
const updateBoundary = useSettingsStore((s) => s.updateBoundary);
const graphEnabled = settings.progressType !== "none";
- const selectGpu = useSettingsStore((s) => s.selectGpu);
+ const selectGpu = settingsActions.selectGpu;
const { gpuUsage, gpuTemp, gpuConsumption, gpuClock, vramUsage } = settings.sensors;
const gpus = listGpus(hardwares);
diff --git a/tauri-app/src/components/settings/stats/MonitorSection.tsx b/tauri-app/src/components/settings/stats/MonitorSection.tsx
index 0e61ef5..e9a7e6c 100644
--- a/tauri-app/src/components/settings/stats/MonitorSection.tsx
+++ b/tauri-app/src/components/settings/stats/MonitorSection.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useEffect, useState } from "react";
import {
Select,
@@ -13,7 +14,7 @@ import { SectionCard } from "./SectionCard";
export function MonitorSection() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const [monitors, setMonitors] = useState([]);
useEffect(() => {
diff --git a/tauri-app/src/components/settings/stats/NetworkSection.tsx b/tauri-app/src/components/settings/stats/NetworkSection.tsx
index fec3720..3144c49 100644
--- a/tauri-app/src/components/settings/stats/NetworkSection.tsx
+++ b/tauri-app/src/components/settings/stats/NetworkSection.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useRef } from "react";
import type { Sensor, Hardware } from "@/lib/types";
import { HardwareType, SensorType } from "@/lib/types";
@@ -20,7 +21,7 @@ interface Props {
export function NetworkSection({ sensors, hardwares }: Props) {
const settings = useSettingsStore((s) => s.settings);
- const updateSensor = useSettingsStore((s) => s.updateSensor);
+ const updateSensor = settingsActions.updateSensor;
const upRate = settings.sensors.upRate;
const downRate = settings.sensors.downRate;
const anyEnabled = upRate.isEnabled || downRate.isEnabled;
diff --git a/tauri-app/src/components/settings/stats/RamSection.tsx b/tauri-app/src/components/settings/stats/RamSection.tsx
index 3878564..af607c2 100644
--- a/tauri-app/src/components/settings/stats/RamSection.tsx
+++ b/tauri-app/src/components/settings/stats/RamSection.tsx
@@ -1,10 +1,11 @@
+import { settingsActions } from "@/lib/settings-actions";
import { useSettingsStore } from "@/stores/settings-store";
import { SectionCard, SubCollapsible } from "./SectionCard";
import { TempRangeControl } from "./TempRangeControl";
export function RamSection() {
const settings = useSettingsStore((s) => s.settings);
- const updateSensor = useSettingsStore((s) => s.updateSensor);
+ const updateSensor = settingsActions.updateSensor;
const updateBoundary = useSettingsStore((s) => s.updateBoundary);
const { ramUsage } = settings.sensors;
// RAM Usage has no sensor selector to fall back on, so when graphs are
diff --git a/tauri-app/src/components/settings/stats/SectionCard.tsx b/tauri-app/src/components/settings/stats/SectionCard.tsx
index 4716c4a..8c876ef 100644
--- a/tauri-app/src/components/settings/stats/SectionCard.tsx
+++ b/tauri-app/src/components/settings/stats/SectionCard.tsx
@@ -1,8 +1,10 @@
import * as React from "react";
+import { playSound } from "@/lib/sound-effects";
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";
import { Switch } from "@/components/shadcn/switch";
import { Checkbox } from "@/components/shadcn/checkbox";
+import { Disclosure } from "@/components/ui/Disclosure";
import {
Collapsible,
CollapsibleContent,
@@ -33,7 +35,7 @@ export function SectionCard({
return (
@@ -42,13 +44,16 @@ export function SectionCard({
{title}
{onToggle !== undefined && (
-
+ {
+ if (value !== !!enabled) playSound("toggle");
+ onToggle(value);
+ }} aria-label={title} />
)}
{/* When the section has a toggle and it's off, hide the body entirely
to match Figma "Stats / Off" — header row only. Sections without a
toggle (Monitor) always show their content. */}
- {(onToggle === undefined || enabled) && children}
+
{children}
);
}
@@ -98,6 +103,7 @@ export function SubCollapsible({
onCheckedChange(v === true)}
/>
{label}
@@ -106,10 +112,11 @@ export function SubCollapsible({
}
return (
-
+
onCheckedChange(v === true)}
/>
{label}
@@ -118,14 +125,14 @@ export function SubCollapsible({
same 200ms (paired elements move as a unit). */}
-
+
-
+
{/* Figma 2759:12229: a 2px rail 12 in from the left, then the blocks
20 across from it, stacked 12 apart. */}
diff --git a/tauri-app/src/components/settings/style/CollapsibleCard.tsx b/tauri-app/src/components/settings/style/CollapsibleCard.tsx
index 710c2c3..29d9995 100644
--- a/tauri-app/src/components/settings/style/CollapsibleCard.tsx
+++ b/tauri-app/src/components/settings/style/CollapsibleCard.tsx
@@ -1,138 +1,29 @@
-import * as React from "react";
+import * as React from "react";
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";
+import { Disclosure } from "@/components/ui/Disclosure";
-// Gentle ease-out (Emil: enter/exit = ease-out; large panels want a soft
-// curve, not an aggressive "shoot then settle"). Paired on chevron + panel.
-const EASE = "cubic-bezier(0.25, 0.46, 0.45, 0.94)";
-const DURATION = 250;
-
-// White section card with uppercase title, optional right-side control
-// (e.g. a switch for SHOW GRAPH), and a chevron that smoothly collapses the
-// body. Matches the Figma Style-tab section pattern.
-//
-// The body height is animated with a CSS *transition* (not a keyframe): a
-// transition never replays when a hidden tab is shown again (App keeps every
-// tab mounted and toggles `display`), so returning to a tab keeps the section
-// open with no re-run. Height animates 0 <-> measured px, then settles to
-// `auto` while open so dynamic content is never clipped. Overflow is only
-// hidden while the height is pinned, so an open body never crops edge-flush
-// controls (the opacity thumb at its minimum) or their focus rings.
-//
-// Pass `open` to drive the body from outside (SHOW GRAPH opens with its
-// switch); the chevron is then dropped, since the control already owns it.
-export function CollapsibleCard({
- title,
- defaultOpen = true,
- open: openProp,
- rightControl,
- children,
- bodyClassName,
-}: {
- title: string;
- defaultOpen?: boolean;
- open?: boolean;
- rightControl?: React.ReactNode;
- children: React.ReactNode;
- bodyClassName?: string;
+export function CollapsibleCard({title, defaultOpen = true, open: openProp, rightControl, children, bodyClassName}: {
+ title: string; defaultOpen?: boolean; open?: boolean; rightControl?: React.ReactNode;
+ children: React.ReactNode; bodyClassName?: string;
}) {
const controlled = openProp !== undefined;
const [openState, setOpen] = React.useState(defaultOpen);
const open = controlled ? openProp : openState;
- const [height, setHeight] = React.useState
(
- open ? "auto" : 0,
- );
const contentId = React.useId();
- const bodyRef = React.useRef(null);
- const firstRender = React.useRef(true);
-
- React.useLayoutEffect(() => {
- const el = bodyRef.current;
- if (!el) return;
- // Honour defaultOpen instantly: never animate the initial paint.
- if (firstRender.current) {
- firstRender.current = false;
- return;
- }
- if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
- setHeight(open ? "auto" : 0);
- return;
- }
- if (open) {
- // 0 (or a pinned px from an interrupted close) -> measured, then release
- // to auto. Release on transitionend, with a timeout fallback: if the
- // height doesn't actually change (reopened mid-close, same px) no
- // transition fires, and without the fallback the body would stay pinned
- // and later clip when its content grows.
- setHeight(el.scrollHeight);
- let released = false;
- const release = () => {
- if (released) return;
- released = true;
- setHeight("auto");
- };
- const onEnd = (e: TransitionEvent) => {
- if (e.propertyName === "height") release();
- };
- el.addEventListener("transitionend", onEnd);
- const t = setTimeout(release, DURATION + 50);
- return () => {
- el.removeEventListener("transitionend", onEnd);
- clearTimeout(t);
- };
- }
- // auto -> pin to current px, then next frame collapse to 0.
- setHeight(el.scrollHeight);
- const id = requestAnimationFrame(() => {
- void el.offsetHeight; // force reflow so the 0 target transitions
- setHeight(0);
- });
- return () => cancelAnimationFrame(id);
- }, [open]);
-
return (
-
+
-
- {title}
-
+ {title}
{rightControl}
- {!controlled && (
- setOpen((o) => !o)}
- aria-expanded={open}
- aria-controls={contentId}
- aria-label={open ? `Collapse ${title}` : `Expand ${title}`}
- className="flex items-center justify-center text-muted-foreground"
- >
-
-
- )}
-
-
-
{children}
+ {!controlled &&
setOpen(o => !o)}
+ aria-expanded={open} aria-controls={contentId} aria-label={open ? `Collapse ${title}` : `Expand ${title}`}
+ className="flex items-center justify-center rounded-sm text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+
+ }
+
{children}
);
}
diff --git a/tauri-app/src/components/settings/style/FontCard.tsx b/tauri-app/src/components/settings/style/FontCard.tsx
index 34db545..51d4954 100644
--- a/tauri-app/src/components/settings/style/FontCard.tsx
+++ b/tauri-app/src/components/settings/style/FontCard.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { CollapsibleCard } from "./CollapsibleCard";
import {
Select,
@@ -109,7 +110,7 @@ function FontRow({
export function FontCard() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
return (
diff --git a/tauri-app/src/components/settings/style/GraphTypePicker.tsx b/tauri-app/src/components/settings/style/GraphTypePicker.tsx
index 42cae61..f88dfec 100644
--- a/tauri-app/src/components/settings/style/GraphTypePicker.tsx
+++ b/tauri-app/src/components/settings/style/GraphTypePicker.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { CollapsibleCard } from "./CollapsibleCard";
import { Switch } from "@/components/shadcn/switch";
import { cn } from "@/lib/utils";
@@ -86,7 +87,7 @@ function GraphTile({
export function GraphTypePicker() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const isEnabled = settings.progressType !== "none";
diff --git a/tauri-app/src/components/settings/style/OrientationPicker.tsx b/tauri-app/src/components/settings/style/OrientationPicker.tsx
index 044167e..e2c9ac9 100644
--- a/tauri-app/src/components/settings/style/OrientationPicker.tsx
+++ b/tauri-app/src/components/settings/style/OrientationPicker.tsx
@@ -1,3 +1,4 @@
+import { settingsActions } from "@/lib/settings-actions";
import { CollapsibleCard } from "./CollapsibleCard";
import { cn } from "@/lib/utils";
import { useSettingsStore } from "@/stores/settings-store";
@@ -150,7 +151,7 @@ function OrientationTile({
export function OrientationPicker() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
return (
diff --git a/tauri-app/src/components/settings/style/PositionGrid.tsx b/tauri-app/src/components/settings/style/PositionGrid.tsx
index 8eb1dbd..d4d8093 100644
--- a/tauri-app/src/components/settings/style/PositionGrid.tsx
+++ b/tauri-app/src/components/settings/style/PositionGrid.tsx
@@ -1,5 +1,7 @@
+import { settingsActions } from "@/lib/settings-actions";
import { CollapsibleCard } from "./CollapsibleCard";
import { Switch } from "@/components/shadcn/switch";
+import { Disclosure } from "@/components/ui/Disclosure";
import { cn } from "@/lib/utils";
import { useSettingsStore } from "@/stores/settings-store";
@@ -44,12 +46,12 @@ function DragPanIcon({ className }: { className?: string }) {
export function PositionGrid() {
const settings = useSettingsStore((s) => s.settings);
- const updateSettings = useSettingsStore((s) => s.updateSettings);
+ const updateSettings = settingsActions.updateSettings;
const { useCustomPosition, positionIndex } = settings;
return (
-
+
- {!useCustomPosition && (
- <>
+
@@ -113,8 +114,7 @@ export function PositionGrid() {
);
})}
- >
- )}
+
);
diff --git a/tauri-app/src/components/shadcn/checkbox.tsx b/tauri-app/src/components/shadcn/checkbox.tsx
index 4807b5e..2859584 100644
--- a/tauri-app/src/components/shadcn/checkbox.tsx
+++ b/tauri-app/src/components/shadcn/checkbox.tsx
@@ -2,26 +2,13 @@ import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { cn } from "@/lib/utils";
-// Checkmark exported from Figma I2353:501;6914:107495 — native 11×8 viewBox,
-// path fills the box edge-to-edge so no off-center bias when centered inside
-// the parent. Replaces lucide-react `
` whose 24×24 viewBox carried
-// a slight upward shift that was visible at small sizes.
+// Stroke geometry supplied by transitions.dev Checkbox check.
function CheckmarkIcon({ className }: { className?: string }) {
return (
-
-
+
+
);
}
@@ -36,7 +23,7 @@ function Checkbox({
className={cn(
// 24 box, 19.2 visual: Figma's Checkbox [1.0] instance is 24 square
// and that is what sets the height of every row it sits in.
- "group flex size-[24px] shrink-0 items-center justify-center outline-none",
+ "t-check group flex size-[24px] shrink-0 items-center justify-center outline-none",
"disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
@@ -44,18 +31,18 @@ function Checkbox({
>
{/* Unchecked is a 15.6 raised square inside the 19.2 sunken one, which
is what leaves Figma's 1.8 ring rather than a 1px border. It gives
way to the check. */}
-
-
-
+
+
+
+
diff --git a/tauri-app/src/components/shadcn/collapsible.tsx b/tauri-app/src/components/shadcn/collapsible.tsx
index e3c95b0..32b344f 100644
--- a/tauri-app/src/components/shadcn/collapsible.tsx
+++ b/tauri-app/src/components/shadcn/collapsible.tsx
@@ -1,7 +1,24 @@
+import * as React from "react";
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
+import { Disclosure } from "@/components/ui/Disclosure";
+import { cn } from "@/lib/utils";
-const Collapsible = CollapsiblePrimitive.Root;
+const OpenContext = React.createContext(false);
+function Collapsible({open: controlled, defaultOpen = false, onOpenChange, className, children, ...props}: React.ComponentProps) {
+ const [internal, setInternal] = React.useState(defaultOpen);
+ const open = controlled ?? internal;
+ return
+ {setInternal(next); onOpenChange?.(next);}}>
+ {children}
+
+ ;
+}
const CollapsibleTrigger = CollapsiblePrimitive.Trigger;
-const CollapsibleContent = CollapsiblePrimitive.Content;
-
+function CollapsibleContent({children, className, ...props}: React.ComponentProps) {
+ const open = React.useContext(OpenContext);
+ return
+ {children}
+ ;
+}
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
diff --git a/tauri-app/src/components/shadcn/dialog.tsx b/tauri-app/src/components/shadcn/dialog.tsx
index b0d16f5..240b9c0 100644
--- a/tauri-app/src/components/shadcn/dialog.tsx
+++ b/tauri-app/src/components/shadcn/dialog.tsx
@@ -16,8 +16,6 @@ function DialogOverlay({
data-slot="dialog-overlay"
className={cn(
"fixed inset-0 z-50 bg-[var(--bgBrand)]/50",
- "data-[state=open]:animate-in data-[state=open]:fade-in-0",
- "data-[state=closed]:animate-out data-[state=closed]:fade-out-0",
"motion-reduce:transition-none motion-reduce:animate-none",
className,
)}
@@ -29,15 +27,28 @@ function DialogOverlay({
function DialogContent({
className,
children,
+ onOpenAutoFocus,
+ onCloseAutoFocus,
...props
}: React.ComponentProps) {
+ const opener = React.useRef(null);
return (
{
+ opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
+ onOpenAutoFocus?.(event);
+ }}
+ onCloseAutoFocus={(event) => {
+ onCloseAutoFocus?.(event);
+ const target = opener.current;
+ if (!event.defaultPrevented && target?.isConnected && !target.closest('[inert]')) {
+ event.preventDefault();
+ target.focus();
+ }
+ }}
className={cn(
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-[12px] bg-[var(--bgSurfaceRaised)] shadow-lg",
- "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
- "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
"motion-reduce:transition-none motion-reduce:animate-none",
className,
)}
diff --git a/tauri-app/src/components/shadcn/select.tsx b/tauri-app/src/components/shadcn/select.tsx
index b3e1c03..218d52c 100644
--- a/tauri-app/src/components/shadcn/select.tsx
+++ b/tauri-app/src/components/shadcn/select.tsx
@@ -45,7 +45,6 @@ function SelectContent({
data-slot="select-content"
className={cn(
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",
className,
diff --git a/tauri-app/src/components/shadcn/switch.tsx b/tauri-app/src/components/shadcn/switch.tsx
index d06f39a..de0765e 100644
--- a/tauri-app/src/components/shadcn/switch.tsx
+++ b/tauri-app/src/components/shadcn/switch.tsx
@@ -7,24 +7,39 @@ import { cn } from "@/lib/utils";
function Switch({
className,
+ onCheckedChange,
...props
}: React.ComponentProps) {
+ const thumbRef = React.useRef(null);
+ const [interacted, setInteracted] = React.useState(false);
return (
{
+ const thumb = thumbRef.current;
+ if (thumb) {
+ // Retarget the snippet from the visible position on rapid reversals.
+ const current = parseFloat(getComputedStyle(thumb).translate) || 0;
+ thumb.style.setProperty("--toggle-from", `${current}px`);
+ }
+ setInteracted(true);
+ onCheckedChange?.(checked);
+ }}
>
event.currentTarget.style.removeProperty("--toggle-from")}
className={cn(
- "pointer-events-none block size-[16px] rounded-full bg-white shadow-sm transition-transform",
- "data-[state=checked]:translate-x-[16px] data-[state=unchecked]:translate-x-0",
+ "t-toggle-thumb pointer-events-none block size-[16px] rounded-full bg-white shadow-sm",
)}
/>
diff --git a/tauri-app/src/components/shadcn/tooltip.tsx b/tauri-app/src/components/shadcn/tooltip.tsx
index 6846a81..39eaa8e 100644
--- a/tauri-app/src/components/shadcn/tooltip.tsx
+++ b/tauri-app/src/components/shadcn/tooltip.tsx
@@ -12,17 +12,25 @@ function TooltipContent({
...props
}: React.ComponentProps) {
return (
-
+ />
);
}
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
+
+/** Replaces browser title text with a keyboard-accessible, portaled tooltip. */
+export function TooltipHint({ text, children }: { text: string; children: React.ReactElement }) {
+ return
+ {children}
+ {text}
+
+ ;
+}
diff --git a/tauri-app/src/components/ui/Disclosure.tsx b/tauri-app/src/components/ui/Disclosure.tsx
new file mode 100644
index 0000000..e0da86f
--- /dev/null
+++ b/tauri-app/src/components/ui/Disclosure.tsx
@@ -0,0 +1,47 @@
+import * as React from "react";
+import { cn } from "@/lib/utils";
+
+/** Measured height releases to auto after opening, so nested content and focus rings aren't clipped. */
+export function Disclosure({ open, children, className, id, variant = "accordion" }: {
+ open: boolean; children: React.ReactNode; className?: string; id?: string; variant?: "accordion" | "panel";
+}) {
+ const [height, setHeight] = React.useState(open ? "auto" : 0);
+ const body = React.useRef(null);
+ const first = React.useRef(true);
+ React.useLayoutEffect(() => {
+ const el = body.current;
+ if (!el) return;
+ if (first.current) { first.current = false; return; }
+ // Layout measurement must precede paint; auto height is restored after motion.
+ if (matchMedia("(prefers-reduced-motion: reduce)").matches) {
+ setHeight(open ? "auto" : 0);
+ return;
+ }
+ const current = el.getBoundingClientRect().height;
+ setHeight(current);
+ const raf = requestAnimationFrame(() => {
+ void el.offsetHeight;
+ setHeight(open ? el.scrollHeight : 0);
+ });
+ const release = () => { if (open) setHeight("auto"); };
+ const onEnd = (event: TransitionEvent) => {
+ if (event.target === el && event.propertyName === "height") release();
+ };
+ el.addEventListener("transitionend", onEnd);
+ const timeout = setTimeout(release, variant === "panel" ? 450 : 300);
+ return () => {
+ cancelAnimationFrame(raf); clearTimeout(timeout);
+ el.removeEventListener("transitionend", onEnd);
+ };
+ }, [open, variant]);
+ return (
+
+ );
+}
diff --git a/tauri-app/src/components/ui/Toast.tsx b/tauri-app/src/components/ui/Toast.tsx
index 9ccbe0e..bfa709e 100644
--- a/tauri-app/src/components/ui/Toast.tsx
+++ b/tauri-app/src/components/ui/Toast.tsx
@@ -2,55 +2,11 @@ import { useEffect, useRef, useState } from "react";
import { useToastStore } from "@/stores/toast-store";
import { ErrorIcon } from "./shortcut-icons";
-/**
- * The settings window's transient error toast, Figma 2819:9753.
- *
- * Measured off the frame: HUG pill at radius 100 on Bg/Brand, padding 6 left
- * and 6/6 vertical against 20 on the right (the badge supplies the optical
- * inset on its side, so the text is the end that needs the room), gap 12. The
- * Bg/Brand fill inverts with the theme for free — #0C111D in light, #FAFAFA
- * in dark — with Text/Inverse tracking it the other way. The 40x40 badge is
- * Bg/Warning Bold holding the 20px `error` glyph in Icon/Warning Bold. Both
- * invert with the theme, so the chip reads as a tint of the pill in either one
- * (1.35:1 against it on light, 1.25:1 on dark). It was Yellow/950 with
- * Bg/Warning Active, whose light values these match exactly — but Yellow/950
- * is a primitive with no dark mode, so on dark the chip stayed a hard dark
- * disc (13.4:1) punched into the near-white pill.
- *
- * Position is the frame's too: x 175 in a 651-wide window is dead centre, at
- * y 76 down from the window's top edge.
- *
- * ## Motion
- *
- * Beats: fades up 16px above its mark -> settles onto it -> holds ->
- * fades out rising the same 16px
- * Trigger: a shortcut capture refused because the combo is already bound.
- * An event, not a state, which is what makes a toast the right
- * shape for it rather than a line of text under the field.
- * Timing: in 300ms (fade 260ms), hold 4000ms, out 220ms (fade 180ms)
- * Feel: in = critically-damped spring sampled to linear(), zero
- * overshoot: covers most of the drop early, then settles
- * onto its mark instead of stopping dead
- * out = cubic-bezier(0.32, 0.72, 0, 1), which builds speed so it
- * leaves rather than creeping
- *
- * The fade is the entrance here, not a coat on one. An earlier version parked
- * the pill 104px up behind the title bar and slid it out, treating the opaque
- * bar as a mask — but a mask cuts, it does not soften, and the pill arrived at
- * the bar's edge already 84% opaque with a hard flat top where the chrome had
- * clipped it. It now stays clear of the bar entirely. See .cm-toast in
- * globals.css for the geometry.
- *
- * Occasional-tier by frequency: you only see this when a binding is refused,
- * so it earns a standard entrance rather than the near-imperceptible
- * treatment a many-times-a-day control would get.
- *
- * CSS transitions, NOT keyframes — see .cm-toast in globals.css.
- */
+/** Uses the transitions.dev toast motion; repeat/exit lifecycle remains event-driven. */
/** Time the toast stays fully up, between the entrance and the exit. */
const HOLD_MS = 4000;
-/** Must be at or over the exit duration in .cm-toast[data-state="closed"]. */
-const EXIT_MS = 240;
+/** Must be at or over --toast-close (250ms) in disclosure-motion.css. */
+const EXIT_MS = 300;
export function Toast() {
const message = useToastStore((s) => s.message);
@@ -138,7 +94,7 @@ function ToastPill({ message, open }: { message: string; open: boolean }) {
// warrant that.
aria-hidden="true"
className={
- "cm-toast flex items-center gap-[var(--spacingS)] rounded-[var(--cornerRound)] " +
+ (open ? "t-toast is-open " : "t-toast ") + "flex items-center gap-[var(--spacingS)] rounded-[var(--cornerRound)] " +
"bg-[var(--bgBrand)] py-[var(--spacingXxs)] pl-[var(--spacingXxs)] pr-[var(--spacingL)] " +
// Not in the frame, which draws one message and hugs it. The window
// is 651 wide with 24 of padding, so a longer string than the
diff --git a/tauri-app/src/lib/audio-session.test.ts b/tauri-app/src/lib/audio-session.test.ts
new file mode 100644
index 0000000..eccd5af
--- /dev/null
+++ b/tauri-app/src/lib/audio-session.test.ts
@@ -0,0 +1,82 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { createAudioSession, installAudioReadiness } from "./audio-session";
+
+function output() {
+ const gain = { gain: { setValueAtTime: vi.fn(), linearRampToValueAtTime: vi.fn() }, connect: vi.fn(), disconnect: vi.fn() };
+ const source = { frequency: { value: 0 }, connect: vi.fn(() => gain), start: vi.fn(), stop: vi.fn(), disconnect: vi.fn() };
+ const context = { state: "running", currentTime: 0, destination: {}, createOscillator: () => source, createGain: () => gain,
+ resume: vi.fn().mockResolvedValue(undefined), close: vi.fn().mockResolvedValue(undefined) };
+ return { source, gain, context, create: vi.fn(() => context as unknown as AudioContext) };
+}
+
+afterEach(() => vi.unstubAllGlobals());
+
+describe("Windows audio session readiness", () => {
+ it("reuses one session and releases every node and context when stopped", () => {
+ const device = output();
+ const session = createAudioSession(device.create);
+ session.setActive(false);
+ expect(device.create).not.toHaveBeenCalled();
+ session.setActive(true);
+ session.setActive(true);
+ expect(device.create).toHaveBeenCalledTimes(1);
+ expect(device.source.frequency.value).toBe(20);
+ expect(device.gain.gain.linearRampToValueAtTime).toHaveBeenCalledWith(0.0005, 0.05);
+ session.setActive(false);
+ session.stop();
+ expect(device.source.stop).toHaveBeenCalledTimes(1);
+ expect(device.source.disconnect).toHaveBeenCalledTimes(1);
+ expect(device.gain.disconnect).toHaveBeenCalledTimes(1);
+ expect(device.context.close).toHaveBeenCalledTimes(1);
+ });
+
+ it("contains missing audio devices and failed resume without blocking the app", async () => {
+ const broken = createAudioSession(() => { throw new Error("No output"); });
+ expect(() => broken.setActive(true)).not.toThrow();
+ const device = output();
+ device.context.resume.mockRejectedValue(new Error("Autoplay denied"));
+ const session = createAudioSession(device.create);
+ session.setActive(true);
+ await Promise.resolve();
+ session.stop();
+ expect(device.context.close).toHaveBeenCalledTimes(1);
+ });
+
+ it("stops on mute, blur, hide and disposal, and resumes only when eligible", () => {
+ const device = output();
+ const win = Object.assign(new EventTarget(), { __TAURI_INTERNALS__: {}, location: { pathname: "/" } });
+ let focused = true;
+ const doc = Object.assign(new EventTarget(), { visibilityState: "visible", hasFocus: () => focused });
+ vi.stubGlobal("window", win);
+ vi.stubGlobal("document", doc);
+ vi.stubGlobal("navigator", { userAgent: "Windows" });
+ vi.stubGlobal("AudioContext", function () { return device.context; });
+ let enabled = false;
+ const readiness = installAudioReadiness(() => enabled);
+ expect(device.source.start).not.toHaveBeenCalled();
+ enabled = true;
+ readiness.sync();
+ expect(device.source.start).toHaveBeenCalledTimes(1);
+ enabled = false;
+ readiness.sync();
+ expect(device.context.close).toHaveBeenCalledTimes(1);
+ enabled = true;
+ focused = false;
+ readiness.sync();
+ expect(device.source.start).toHaveBeenCalledTimes(1);
+ focused = true;
+ win.dispatchEvent(new Event("focus"));
+ win.dispatchEvent(new Event("blur"));
+ expect(device.context.close).toHaveBeenCalledTimes(2);
+ win.dispatchEvent(new Event("focus"));
+ doc.visibilityState = "hidden";
+ doc.dispatchEvent(new Event("visibilitychange"));
+ expect(device.context.close).toHaveBeenCalledTimes(3);
+ doc.visibilityState = "visible";
+ doc.dispatchEvent(new Event("visibilitychange"));
+ readiness.dispose();
+ expect(device.context.close).toHaveBeenCalledTimes(4);
+ win.dispatchEvent(new Event("focus"));
+ expect(device.source.start).toHaveBeenCalledTimes(4);
+ });
+});
diff --git a/tauri-app/src/lib/audio-session.ts b/tauri-app/src/lib/audio-session.ts
new file mode 100644
index 0000000..3b5cab1
--- /dev/null
+++ b/tauri-app/src/lib/audio-session.ts
@@ -0,0 +1,75 @@
+// Short isolated cues can reach the Windows mixer yet disappear on an idle
+// HDMI output. Keep its audio session ready while the settings UI is in use.
+// This low-level 20Hz signal was listening-tested on the affected output; it
+// is not an ambient sound asset. Never run it while muted or in the background.
+export function createAudioSession(createContext: () => AudioContext) {
+ let active: { context: AudioContext; source: OscillatorNode; gain: GainNode } | undefined;
+
+ function stop() {
+ const previous = active;
+ active = undefined;
+ if (!previous) return;
+ previous.source.stop();
+ previous.source.disconnect();
+ previous.gain.disconnect();
+ void previous.context.close().catch(() => {});
+ }
+
+ return {
+ setActive(wanted: boolean) {
+ if (!wanted) { stop(); return; }
+ if (active) {
+ if (active.context.state === "suspended") void active.context.resume().catch(() => {});
+ return;
+ }
+ let context: AudioContext | undefined;
+ try {
+ context = createContext();
+ const source = context.createOscillator();
+ const gain = context.createGain();
+ source.frequency.value = 20;
+ gain.gain.setValueAtTime(0, context.currentTime);
+ gain.gain.linearRampToValueAtTime(0.0005, context.currentTime + 0.05);
+ source.connect(gain).connect(context.destination);
+ source.start();
+ active = { context, source, gain };
+ void context.resume().catch(() => {});
+ } catch {
+ // Output readiness must not prevent a setting change or cue playback.
+ if (context) void context.close().catch(() => {});
+ }
+ },
+ stop,
+ };
+}
+
+export function installAudioReadiness(isEnabled: () => boolean) {
+ // The workaround is scoped to the Windows desktop settings window.
+ if (typeof window === "undefined" || !("__TAURI_INTERNALS__" in window) ||
+ !navigator.userAgent.includes("Windows") || window.location.pathname.includes("overlay")) {
+ return { sync() {}, dispose() {} };
+ }
+ const session = createAudioSession(() => new AudioContext({ latencyHint: "interactive" }));
+ const sync = () => session.setActive(isEnabled() && document.visibilityState === "visible" && document.hasFocus());
+ const stop = () => session.stop();
+ window.addEventListener("focus", sync);
+ window.addEventListener("blur", stop);
+ window.addEventListener("pagehide", stop);
+ // Retry a context blocked by autoplay policy within the next user gesture.
+ window.addEventListener("pointerdown", sync, true);
+ window.addEventListener("keydown", sync, true);
+ document.addEventListener("visibilitychange", sync);
+ sync();
+ return {
+ sync,
+ dispose() {
+ window.removeEventListener("focus", sync);
+ window.removeEventListener("blur", stop);
+ window.removeEventListener("pagehide", stop);
+ window.removeEventListener("pointerdown", sync, true);
+ window.removeEventListener("keydown", sync, true);
+ document.removeEventListener("visibilitychange", sync);
+ stop();
+ },
+ };
+}
diff --git a/tauri-app/src/lib/settings-actions.ts b/tauri-app/src/lib/settings-actions.ts
new file mode 100644
index 0000000..041580b
--- /dev/null
+++ b/tauri-app/src/lib/settings-actions.ts
@@ -0,0 +1,45 @@
+import { useSettingsStore } from "@/stores/settings-store";
+import type { OverlaySettings, SensorKey } from "./types";
+import { playSound } from "./sound-effects";
+
+// Live UI entry points. Hydration, telemetry, hotkeys and overlay sync continue
+// using the silent store actions. Continuous inputs are deliberately excluded.
+const selectionKeys: (keyof OverlaySettings)[] = [
+ "positionIndex", "isHorizontal", "graphType", "progressType",
+ "fontSizeLabel", "fontSizeValue", "labelFontWeight", "fontWeight",
+ "temperatureUnit", "pollingRate", "themeMode", "selectedDisplayIndex",
+ "pixelShiftDistance", "pixelShiftInterval",
+];
+const toggleKeys: (keyof OverlaySettings)[] = ["pixelShift", "useCustomPosition"];
+
+export const settingsActions = {
+ updateSettings(patch: Partial) {
+ const before = useSettingsStore.getState().settings;
+ useSettingsStore.getState().updateSettings(patch);
+ const toggle = toggleKeys.find((key) => key in patch && patch[key] !== before[key]);
+ if (toggle) {
+ playSound("toggle", patch[toggle] ? "forward" : "back");
+ } else if (patch.progressType !== undefined &&
+ (patch.progressType === "none") !== (before.progressType === "none")) {
+ playSound("toggle", patch.progressType === "none" ? "back" : "forward");
+ } else if (selectionKeys.some((key) => key in patch && patch[key] !== before[key])) {
+ playSound("select");
+ }
+ },
+ updateSensor(key: K, patch: Partial) {
+ const before = useSettingsStore.getState().settings.sensors[key];
+ useSettingsStore.getState().updateSensor(key, patch);
+ if (patch.isEnabled !== undefined && patch.isEnabled !== before.isEnabled) {
+ playSound("press");
+ } else if (Object.entries(patch).some(([field, value]) =>
+ ["customReadingId", "targetAppName"].includes(field) &&
+ value !== (before as unknown as Record)[field])) {
+ playSound("select");
+ }
+ },
+ selectGpu(gpuId: string) {
+ const before = useSettingsStore.getState().settings.selectedGpuId;
+ useSettingsStore.getState().selectGpu(gpuId);
+ if (gpuId !== before) playSound("select");
+ },
+};
diff --git a/tauri-app/src/lib/sound-effects.test.ts b/tauri-app/src/lib/sound-effects.test.ts
new file mode 100644
index 0000000..fffcf36
--- /dev/null
+++ b/tauri-app/src/lib/sound-effects.test.ts
@@ -0,0 +1,121 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { DEFAULT_SETTINGS } from "./types";
+import { play, setEnabled } from "cuelume";
+import { play as playLegacy, setEnabled as enableLegacy } from "cuelume-legacy";
+import * as tauri from "./tauri";
+
+vi.mock("cuelume", () => ({ play: vi.fn(), setEnabled: vi.fn(), setVolume: vi.fn(), unlock: vi.fn() }));
+vi.mock("cuelume-legacy", () => ({ play: vi.fn(), setEnabled: vi.fn(), setVolume: vi.fn() }));
+vi.mock("./tauri", () => ({
+ saveSettings: vi.fn(), savePreferences: vi.fn(), getPreferences: vi.fn(),
+ setPollingRate: vi.fn(), setOverlayOpacity: vi.fn(), selectPresentMonApp: vi.fn(),
+}));
+const { useSettingsStore } = await import("@/stores/settings-store");
+const { playSound, beginSoundAction } = await import("./sound-effects");
+const { settingsActions } = await import("./settings-actions");
+
+beforeEach(() => {
+ useSettingsStore.setState({ preferencesLoaded: false });
+ useSettingsStore.setState({
+ preferencesLoaded: true,
+ preferences: { adminConsent: false, startMinimized: false, soundEffects: true },
+ settings: structuredClone(DEFAULT_SETTINGS),
+ });
+ vi.clearAllMocks();
+});
+
+describe("sound policy", () => {
+ it("is silent before preferences load and while muted, including active voice cancellation", () => {
+ useSettingsStore.setState({ preferencesLoaded: false });
+ playSound("toggle");
+ expect(playLegacy).not.toHaveBeenCalled();
+ useSettingsStore.setState({ preferencesLoaded: true });
+ playSound("toggle");
+ expect(playLegacy).toHaveBeenCalledTimes(1);
+ useSettingsStore.getState().updatePreferences({ soundEffects: false });
+ expect(setEnabled).toHaveBeenLastCalledWith(false);
+ playSound("success");
+ playSound("press");
+ expect(enableLegacy).toHaveBeenLastCalledWith(false);
+ expect(play).not.toHaveBeenCalled();
+ expect(playLegacy).toHaveBeenCalledTimes(1);
+ });
+
+ it("coalesces a section's multiple sensor updates into one cue", () => {
+ playSound("toggle"); // SectionCard emits once before updating its sensor group.
+ for (const key of ["cpuUsage", "cpuTemp", "cpuClock", "cpuConsumption"] as const) {
+ settingsActions.updateSensor(key, { isEnabled: !DEFAULT_SETTINGS.sensors[key].isEnabled });
+ }
+ expect(playLegacy).toHaveBeenCalledTimes(1);
+ expect(playLegacy).toHaveBeenCalledWith("toggle", expect.anything());
+ });
+
+ it("plays all ten rapid toggle events without a time-based cooldown", async () => {
+ const clock = vi.spyOn(performance, "now").mockReturnValue(100);
+ try {
+ for (let i = 0; i < 10; i++) {
+ settingsActions.updateSettings({ pixelShift: !useSettingsStore.getState().settings.pixelShift });
+ // Real input events are separated by the browser's microtask checkpoint.
+ await Promise.resolve();
+ }
+ expect(playLegacy).toHaveBeenCalledTimes(10);
+ expect(vi.mocked(playLegacy).mock.calls.every(([sound]) => sound === "toggle")).toBe(true);
+ } finally {
+ clock.mockRestore();
+ }
+ });
+
+ it("keeps unchanged choices, sliders, thresholds and silent store updates quiet", () => {
+ settingsActions.updateSettings({ positionIndex: DEFAULT_SETTINGS.positionIndex });
+ settingsActions.updateSettings({ opacity: 0.4 });
+ useSettingsStore.getState().updateBoundary("cpuTemp", { low: 40, medium: 60, high: 80 });
+ useSettingsStore.getState().updateSensor("cpuUsage", { isEnabled: false });
+ expect(play).not.toHaveBeenCalled();
+ });
+
+ it("plays current select and original Legacy toggle", () => {
+ settingsActions.updateSettings({ positionIndex: DEFAULT_SETTINGS.positionIndex === 0 ? 1 : 0 });
+ expect(play).toHaveBeenLastCalledWith("select", { direction: "forward" });
+ useSettingsStore.getState().updatePreferences({ soundEffects: false });
+ useSettingsStore.getState().updatePreferences({ soundEffects: true });
+ useSettingsStore.getState().updateSettings({ pixelShift: true });
+ settingsActions.updateSettings({ pixelShift: false });
+ expect(playLegacy).toHaveBeenLastCalledWith("toggle", { volume: undefined });
+ });
+
+ it("uses original press for a sensor checkbox without changing other cues", async () => {
+ settingsActions.updateSensor("cpuUsage", { isEnabled: !DEFAULT_SETTINGS.sensors.cpuUsage.isEnabled });
+ expect(playLegacy).toHaveBeenLastCalledWith("press", { volume: undefined });
+ expect(play).not.toHaveBeenCalled();
+ await Promise.resolve();
+ playSound("open", "forward", { volume: 0.5, emphasis: "subtle" });
+ expect(play).toHaveBeenLastCalledWith("open", { direction: "forward", volume: 0.5, emphasis: "subtle" });
+ });
+
+ it("does not replay an async result after muting then re-enabling", () => {
+ const finish = beginSoundAction();
+ useSettingsStore.getState().updatePreferences({ soundEffects: false });
+ useSettingsStore.getState().updatePreferences({ soundEffects: true });
+ finish("success");
+ expect(play).not.toHaveBeenCalled();
+ });
+
+ it("contains audio failures without blocking the setting change", () => {
+ vi.mocked(play).mockImplementationOnce(() => { throw new Error("No audio device"); });
+ expect(() => settingsActions.updateSettings({ positionIndex: 7 })).not.toThrow();
+ expect(useSettingsStore.getState().settings.positionIndex).toBe(7);
+ });
+
+ it("loads saved mute, migrates old preferences and fails silent on read errors", async () => {
+ vi.mocked(tauri.getPreferences).mockResolvedValueOnce({ adminConsent: true, startMinimized: true, soundEffects: false });
+ await useSettingsStore.getState().loadPreferences();
+ expect(useSettingsStore.getState().preferences.soundEffects).toBe(false);
+ expect(setEnabled).toHaveBeenLastCalledWith(false);
+ vi.mocked(tauri.getPreferences).mockResolvedValueOnce({ adminConsent: true, startMinimized: true } as Awaited>);
+ await useSettingsStore.getState().loadPreferences();
+ expect(useSettingsStore.getState().preferences).toEqual({ adminConsent: true, startMinimized: true, soundEffects: true });
+ vi.mocked(tauri.getPreferences).mockRejectedValueOnce(new Error("disk"));
+ await useSettingsStore.getState().loadPreferences();
+ expect(useSettingsStore.getState().preferences.soundEffects).toBe(false);
+ });
+});
diff --git a/tauri-app/src/lib/sound-effects.ts b/tauri-app/src/lib/sound-effects.ts
new file mode 100644
index 0000000..9d35763
--- /dev/null
+++ b/tauri-app/src/lib/sound-effects.ts
@@ -0,0 +1,63 @@
+import { play, setEnabled, setVolume, unlock, type SoundName, type PlayOptions } from "cuelume";
+import { play as playLegacy, setEnabled as enableLegacy, setVolume as volumeLegacy } from "cuelume-legacy";
+import { useSettingsStore } from "@/stores/settings-store";
+import { installAudioReadiness } from "./audio-session";
+
+// Explicit calls from UI actions only: never bind all clicks or store updates.
+// Coalesce synchronous multi-sensor changes from one section switch, but let
+// each subsequent input event play, even when it arrives less than 90ms later.
+let playedThisTurn = false;
+let muteGeneration = 0;
+const enabled = () => {
+ const state = useSettingsStore.getState();
+ return state.preferencesLoaded && state.preferences.soundEffects;
+};
+
+setVolume(0.35);
+volumeLegacy(0.35);
+setEnabled(enabled());
+enableLegacy(enabled());
+const readiness = installAudioReadiness(enabled);
+const unsubscribe = useSettingsStore.subscribe((state, previous) => {
+ if (state.preferences.soundEffects !== previous.preferences.soundEffects ||
+ state.preferencesLoaded !== previous.preferencesLoaded) {
+ setEnabled(enabled()); // Also silences voices already ringing.
+ enableLegacy(enabled());
+ readiness.sync();
+ if (!enabled()) muteGeneration++;
+ playedThisTurn = false;
+ }
+});
+if (import.meta.hot) import.meta.hot.dispose(() => { unsubscribe(); readiness.dispose(); });
+
+export function prepareSound() {
+ if (enabled()) void unlock();
+}
+
+// Capture at the gesture: muting during an async request cancels its cue,
+// including when sound is enabled again before that request completes.
+export function beginSoundAction() {
+ const audible = enabled();
+ const generation = muteGeneration;
+ prepareSound();
+ return (sound: SoundName | "press", direction: "forward" | "back" = "forward") => {
+ if (audible && generation === muteGeneration) playSound(sound, direction);
+ };
+}
+
+export function playSound(sound: SoundName | "press", direction: "forward" | "back" = "forward", options: Pick = {}) {
+ if (!enabled()) return;
+ if (playedThisTurn) return;
+ try {
+ if (sound === "toggle" || sound === "press") {
+ // Original Legacy recipes; 0.2.2 uses the same cue in both directions.
+ playLegacy(sound, { volume: options.volume });
+ } else {
+ play(sound, { ...options, direction });
+ }
+ playedThisTurn = true;
+ queueMicrotask(() => { playedThisTurn = false; });
+ } catch {
+ // Audio failure must never interrupt changing a setting.
+ }
+}
diff --git a/tauri-app/src/lib/types.ts b/tauri-app/src/lib/types.ts
index c64c473..568943c 100644
--- a/tauri-app/src/lib/types.ts
+++ b/tauri-app/src/lib/types.ts
@@ -215,6 +215,7 @@ export interface MonitorInfo {
export interface AppPreferences {
adminConsent: boolean;
startMinimized: boolean;
+ soundEffects: boolean;
}
export type SensorKey = keyof SensorsConfig;
diff --git a/tauri-app/src/stores/settings-store.reset.test.ts b/tauri-app/src/stores/settings-store.reset.test.ts
index c8c3a75..fdea43f 100644
--- a/tauri-app/src/stores/settings-store.reset.test.ts
+++ b/tauri-app/src/stores/settings-store.reset.test.ts
@@ -18,7 +18,7 @@ beforeEach(() => {
vi.clearAllMocks();
useSettingsStore.setState({
settings: structuredClone(DEFAULT_SETTINGS),
- preferences: { adminConsent: true, startMinimized: true },
+ preferences: { adminConsent: true, startMinimized: true, soundEffects: false },
sensorData: null,
});
});
@@ -41,9 +41,9 @@ describe("reset all settings", () => {
expect(useSettingsStore.getState().settings).toEqual(DEFAULT_SETTINGS);
expect(useSettingsStore.getState().settings.sensors).not.toBe(DEFAULT_SETTINGS.sensors);
- expect(useSettingsStore.getState().preferences).toEqual({ adminConsent: false, startMinimized: false });
+ expect(useSettingsStore.getState().preferences).toEqual({ adminConsent: false, startMinimized: false, soundEffects: true });
expect(tauri.saveSettings).toHaveBeenCalledExactlyOnceWith(DEFAULT_SETTINGS);
- expect(tauri.savePreferences).toHaveBeenCalledExactlyOnceWith({ adminConsent: false, startMinimized: false });
+ expect(tauri.savePreferences).toHaveBeenCalledExactlyOnceWith({ adminConsent: false, startMinimized: false, soundEffects: true });
expect(tauri.setAutoStart).toHaveBeenCalledExactlyOnceWith(false);
expect(tauri.setPollingRate).toHaveBeenCalledExactlyOnceWith(DEFAULT_SETTINGS.pollingRate);
expect(tauri.setOverlayOpacity).toHaveBeenCalledExactlyOnceWith(DEFAULT_SETTINGS.opacity);
diff --git a/tauri-app/src/stores/settings-store.sound.test.ts b/tauri-app/src/stores/settings-store.sound.test.ts
new file mode 100644
index 0000000..e5fd9cd
--- /dev/null
+++ b/tauri-app/src/stores/settings-store.sound.test.ts
@@ -0,0 +1,47 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import * as tauri from "@/lib/tauri";
+import { useToastStore } from "./toast-store";
+
+vi.mock("@/lib/tauri", () => ({ savePreferences: vi.fn().mockResolvedValue(undefined), getPreferences: vi.fn() }));
+const { useSettingsStore } = await import("./settings-store");
+
+describe("sound preference persistence", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ useSettingsStore.setState({ preferencesLoaded: true });
+ });
+ it("blocks preference writes after a failed read and recovers on retry", async () => {
+ vi.mocked(tauri.getPreferences).mockRejectedValueOnce(new Error("read failed"));
+ await useSettingsStore.getState().loadPreferences();
+ expect(useSettingsStore.getState().preferencesLoaded).toBe(false);
+ expect(useSettingsStore.getState().preferences.soundEffects).toBe(false);
+ useSettingsStore.getState().updatePreferences({ startMinimized: true });
+ await Promise.resolve();
+ expect(tauri.savePreferences).not.toHaveBeenCalled();
+ vi.mocked(tauri.getPreferences).mockResolvedValueOnce({ adminConsent: true, startMinimized: true, soundEffects: true });
+ await useSettingsStore.getState().loadPreferences();
+ useSettingsStore.getState().updatePreferences({ startMinimized: false });
+ await vi.waitFor(() => expect(tauri.savePreferences).toHaveBeenCalledWith({ adminConsent: true, startMinimized: false, soundEffects: true }));
+ });
+ it("serializes rapid edits so the last mute value is the last saved value", async () => {
+ let completeFirst!: () => void;
+ vi.mocked(tauri.savePreferences).mockImplementationOnce(() => new Promise((resolve) => { completeFirst = resolve; }));
+ const update = useSettingsStore.getState().updatePreferences;
+ update({ soundEffects: true });
+ update({ soundEffects: false });
+ expect(useSettingsStore.getState().preferences.soundEffects).toBe(false);
+ await vi.waitFor(() => expect(tauri.savePreferences).toHaveBeenCalledTimes(1));
+ completeFirst();
+ await vi.waitFor(() => expect(tauri.savePreferences).toHaveBeenCalledTimes(2));
+ expect(tauri.savePreferences).toHaveBeenLastCalledWith(expect.objectContaining({ soundEffects: false }));
+ });
+
+ it("reports a save rejection, keeps current mute and lets later edits save", async () => {
+ vi.mocked(tauri.savePreferences).mockRejectedValueOnce(new Error("native invoke failed"));
+ useSettingsStore.getState().updatePreferences({ soundEffects: false });
+ await vi.waitFor(() => expect(useToastStore.getState().message).toContain("Couldn't save preferences"));
+ expect(useSettingsStore.getState().preferences.soundEffects).toBe(false);
+ useSettingsStore.getState().updatePreferences({ startMinimized: true });
+ await vi.waitFor(() => expect(tauri.savePreferences).toHaveBeenLastCalledWith(expect.objectContaining({ soundEffects: false, startMinimized: true })));
+ });
+});
diff --git a/tauri-app/src/stores/settings-store.ts b/tauri-app/src/stores/settings-store.ts
index 822e07b..23c6323 100644
--- a/tauri-app/src/stores/settings-store.ts
+++ b/tauri-app/src/stores/settings-store.ts
@@ -25,6 +25,7 @@ import {
} from "@/lib/gpu";
import * as tauri from "@/lib/tauri";
import { cpuClockOptions } from "@/lib/utils";
+import { useToastStore } from "./toast-store";
/**
* Best sensor of a given type out of an already-narrowed list, by keyword
@@ -238,6 +239,14 @@ function autoSelectSensors(
let sawSidecarEvent = false;
let saveTimer: ReturnType | null = null;
+// Preserve the order of rapid mute/unmute and other preference edits. Native
+// invocations may otherwise finish out of order and persist an older value.
+let preferencesSaveQueue: Promise = Promise.resolve();
+function persistPreferences(preferences: AppPreferences) {
+ const save = preferencesSaveQueue.then(async () => { await tauri.savePreferences(preferences); });
+ preferencesSaveQueue = save.catch(() => {});
+ return save;
+}
function debouncedSave(settings: OverlaySettings) {
if (saveTimer) clearTimeout(saveTimer);
saveTimer = setTimeout(() => tauri.saveSettings(settings), 300);
@@ -247,6 +256,7 @@ interface SettingsStore {
// State
settings: OverlaySettings;
preferences: AppPreferences;
+ preferencesLoaded: boolean;
sensorData: HardwareMonitorData | null;
presentMonApps: string[];
pipeStatus: PipeStatus;
@@ -322,7 +332,8 @@ const prehydratedDark =
export const useSettingsStore = create((set, get) => ({
settings: { ...DEFAULT_SETTINGS, isDarkTheme: prehydratedDark },
- preferences: { adminConsent: false, startMinimized: false },
+ preferences: { adminConsent: false, startMinimized: false, soundEffects: true },
+ preferencesLoaded: false,
sensorData: null,
presentMonApps: [],
pipeStatus: { connected: false },
@@ -524,13 +535,13 @@ export const useSettingsStore = create((set, get) => ({
saveTimer = null;
const settings = structuredClone(DEFAULT_SETTINGS);
settings.isDarkTheme = systemPrefersDark();
- const preferences = { adminConsent: false, startMinimized: false };
+ const preferences = { adminConsent: false, startMinimized: false, soundEffects: true };
set({ settings, preferences, gpuSilence: NO_GPU_SILENCE });
// Use the normal save path to persist and broadcast the same defaults,
// including re-registering the default global shortcuts.
await Promise.all([
tauri.saveSettings(settings),
- tauri.savePreferences(preferences),
+ persistPreferences(preferences),
tauri.setAutoStart(false),
tauri.setPollingRate(settings.pollingRate),
tauri.setOverlayOpacity(settings.opacity),
@@ -539,18 +550,25 @@ export const useSettingsStore = create((set, get) => ({
},
loadPreferences: async () => {
+ set({ preferencesLoaded: false });
try {
const preferences = await tauri.getPreferences();
- if (preferences) set({ preferences });
+ if (preferences) set({ preferences: { ...preferences, soundEffects: preferences.soundEffects ?? true } });
+ set({ preferencesLoaded: true });
} catch {
- // Use defaults
+ // If loading fails, do not risk playing over a saved mute preference.
+ set((state) => ({ preferences: { ...state.preferences, soundEffects: false } }));
}
},
updatePreferences: (patch) => {
+ // A failed read leaves unknown saved values; do not overwrite them with defaults.
+ if (!get().preferencesLoaded) return;
const newPrefs = { ...get().preferences, ...patch };
set({ preferences: newPrefs });
- tauri.savePreferences(newPrefs);
+ void persistPreferences(newPrefs).catch(() => {
+ useToastStore.getState().showToast("Couldn't save preferences. Your changes may not survive a restart.");
+ });
},
setSensorData: (data) => {