fix: FM-901 Option click sfx does not play in offline mode in Assessment embedded mode.#1962
Conversation
📝 WalkthroughWalkthroughThe PR improves service worker assessment audio caching by refactoring ChangesAssessment Audio Offline Caching
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/sw-src.js (1)
71-74: ⚡ Quick winUse one cache strategy for the shared assessment SFX.
These four
.wavs are now cached in three places: install-timedynamic-cache, everyassessment-${dataKey}cache, and the Workbox precache after theglobIgnoreschange. That adds duplicate fetch/storage work and increases eviction risk on low-storage devices. I'd keep the shared sounds in one shared cache path only—preferably the Workbox precache—and reserveassessment-${dataKey}for the dataKey-specific mp3s.Also applies to: 302-315
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sw-src.js` around lines 71 - 74, The shared SFX .wav files returned by getAssessmentAssetPath("audio/...") are being cached in three places; remove them from the runtime caching and assessment-specific caches and rely solely on the Workbox precache: update the code that populates "dynamic-cache" and the assessment-${dataKey} cache to skip any paths that match the shared SFX filenames (or check against a small sharedSfx set), ensuring these four entries remain only in the precache registration, and apply the same exclusion logic to the other similar block (the later loop around the 302-315 area) so assessment-${dataKey} only stores dataKey-specific mp3s.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/sw-src.js`:
- Around line 71-74: The shared SFX .wav files returned by
getAssessmentAssetPath("audio/...") are being cached in three places; remove
them from the runtime caching and assessment-specific caches and rely solely on
the Workbox precache: update the code that populates "dynamic-cache" and the
assessment-${dataKey} cache to skip any paths that match the shared SFX
filenames (or check against a small sharedSfx set), ensuring these four entries
remain only in the precache registration, and apply the same exclusion logic to
the other similar block (the later loop around the 302-315 area) so
assessment-${dataKey} only stores dataKey-specific mp3s.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1c13ab5f-ac79-4acf-b654-8f6e244f4541
📒 Files selected for processing (2)
src/sw-src.jsworkbox-config.js
Changes
How to test
Ref: FM-901
Summary by CodeRabbit