Add browser storage persistence for GramFrame annotations#164
Merged
Conversation
Add automatic save/restore of annotations (analysis markers, harmonic sets, doppler curves) using the Web Storage API. Trainer pages (identified by an "ANALYSIS" link) use localStorage for permanent persistence; student pages use sessionStorage for session-scoped persistence. - New storage adapter module (src/core/storage.js) with context detection, key generation, save/load/clear, schema versioning, and graceful degradation - JSDoc types for StoredAnnotations and related entities - GramFrame constructor integration: restore on init, save on state change - "Clear gram" button on trainer pages to reset all annotations - Comprehensive Playwright tests covering all 3 user stories plus edge cases - All 101 tests pass, typecheck clean, build clean https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty
✅ Deploy Preview for gramframe ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ser-storage-5OnwT
Contributor
PR PreviewPreview deployment is ready! View Preview Last updated: 2026-03-27T11:37:22.951Z |
- New debug-trainer.html with "ANALYSIS" link (triggers localStorage persistence) - Updated debug.html with badge and link to trainer page for easy navigation - Added trainer page to Vite build inputs https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty
Root index.html now serves as a demo hub linking to the student (sessionStorage) and trainer (localStorage) pages, so the preview URL works without specifying a page name. https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty
The PR preview now serves a landing page with links to: - Student page (sessionStorage, no ANALYSIS link) - Trainer page (localStorage, with ANALYSIS link + Clear gram) Also adds debug-trainer.html to the main site deploy. https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty
The main site now builds the standalone bundle and serves student/trainer demo pages at /demo/ alongside the existing dev-oriented pages. https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements automatic persistence of user annotations (analysis markers, harmonic sets, doppler curves) in browser storage, with context-aware storage selection (localStorage for trainers, sessionStorage for students) and a "Clear gram" button for trainer pages.
Key Changes
Storage Module (
src/core/storage.js): New adapter module providing context detection, key generation, save/load/clear operations, schema versioning (v1), and graceful degradation with try/catch wrapping all Web Storage callsdetectUserContext(): Identifies trainer pages by presence of anchor with exact text "ANALYSIS"getStorage(): Returns appropriate Storage object (localStorage/sessionStorage) with availability probingsaveAnnotations(): Persists annotation state only when data exists; removes empty entriesloadAnnotations(): Validates schema version and discards incompatible dataclearAnnotations(): Removes stored data for current pageGramFrame Integration (
src/main.js):_clearGram(): Resets all annotation state and storage, re-renders UIType Definitions (
src/types.js): Added JSDoc typedefs forStoredAnnotations,StoredAnalysisData,StoredMarker,StoredHarmonicsData,StoredHarmonicSet, andStoredDopplerDataStyling (
src/gramframe.css): Added.gram-frame-clear-btnwith gradient background, hover/active states, and responsive stylingTest Fixtures: Created
trainer-page.htmlandstudent-page.htmlfor integration testingTest Suite (
tests/storage.spec.js): Comprehensive Playwright tests covering:Test Helpers (
tests/helpers/gram-frame-page.js): Added storage utility methods (clearStorage(),getStorageEntry(),setStorageEntry(),getStorageKeys())Notable Implementation Details
https://claude.ai/code/session_01Gb6npXwykVzbvHBZUgmYty