smoosic 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/smoosic.js +171 -78
- package/package.json +82 -77
- package/release/smoosic.js +171 -78
- package/release/styles/fonts/MaterialIconsOutlined-Regular.otf +0 -0
- package/release/styles/menus.css +26 -0
- package/specs/022-text-reposition-on-resize/spec.md +1 -0
- package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
- package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
- package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
- package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
- package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
- package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
- package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
- package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
- package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
- package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
- package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
- package/specs/028-unsaved-changes-indicator/plan.md +96 -0
- package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
- package/specs/028-unsaved-changes-indicator/research.md +68 -0
- package/specs/028-unsaved-changes-indicator/spec.md +135 -0
- package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
- package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
- package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
- package/specs/029-remove-promise-helpers/data-model.md +45 -0
- package/specs/029-remove-promise-helpers/plan.md +86 -0
- package/specs/029-remove-promise-helpers/quickstart.md +53 -0
- package/specs/029-remove-promise-helpers/research.md +71 -0
- package/specs/029-remove-promise-helpers/spec.md +107 -0
- package/specs/029-remove-promise-helpers/tasks.md +164 -0
- package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
- package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
- package/specs/030-copy-paste-voices/data-model.md +63 -0
- package/specs/030-copy-paste-voices/plan.md +80 -0
- package/specs/030-copy-paste-voices/quickstart.md +50 -0
- package/specs/030-copy-paste-voices/research.md +80 -0
- package/specs/030-copy-paste-voices/spec.md +124 -0
- package/specs/030-copy-paste-voices/tasks.md +183 -0
- package/specs/031-select-voice/checklists/requirements.md +39 -0
- package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
- package/specs/031-select-voice/data-model.md +47 -0
- package/specs/031-select-voice/plan.md +79 -0
- package/specs/031-select-voice/quickstart.md +43 -0
- package/specs/031-select-voice/research.md +55 -0
- package/specs/031-select-voice/spec.md +113 -0
- package/specs/031-select-voice/tasks.md +171 -0
- package/src/application/application.ts +464 -459
- package/src/common/promiseHelpers.ts +2 -2
- package/src/render/audio/samples.ts +117 -118
- package/src/render/sui/pageDivisions.ts +58 -0
- package/src/render/sui/renderState.ts +469 -464
- package/src/render/sui/scoreChangeState.ts +62 -0
- package/src/render/sui/scoreView.ts +30 -0
- package/src/render/sui/scoreViewOperations.ts +2555 -2380
- package/src/render/sui/svgPageMap.ts +16 -17
- package/src/render/sui/textEdit.ts +310 -311
- package/src/render/sui/tracker.ts +40 -0
- package/src/render/vex/vxNote.ts +3 -1
- package/src/smo/xform/copypaste.ts +304 -4
- package/src/smo/xform/selections.ts +68 -0
- package/src/smo/xform/undo.ts +9 -0
- package/src/styles/menus.css +26 -0
- package/src/ui/buttons/ribbon.ts +3 -1
- package/src/ui/components/buttons/sidebar.vue +15 -6
- package/src/ui/components/dialogs/library.vue +3 -1
- package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
- package/src/ui/dialogs/adapter.ts +181 -183
- package/src/ui/dialogs/addMeasure.ts +97 -97
- package/src/ui/dialogs/annotationVue.ts +56 -56
- package/src/ui/dialogs/audioSettings.ts +121 -123
- package/src/ui/dialogs/chordChangeVue.ts +46 -46
- package/src/ui/dialogs/clefChange.ts +53 -53
- package/src/ui/dialogs/customTuplets.ts +95 -96
- package/src/ui/dialogs/customTupletsVue.ts +47 -47
- package/src/ui/dialogs/dialog.ts +627 -620
- package/src/ui/dialogs/durations.ts +34 -34
- package/src/ui/dialogs/dynamics.ts +140 -142
- package/src/ui/dialogs/factory.ts +198 -198
- package/src/ui/dialogs/fileDialogs.ts +245 -179
- package/src/ui/dialogs/fonts.ts +93 -93
- package/src/ui/dialogs/globalLayout.ts +40 -40
- package/src/ui/dialogs/gracenote.ts +31 -31
- package/src/ui/dialogs/hairpin.ts +108 -110
- package/src/ui/dialogs/hairpinVue.ts +51 -51
- package/src/ui/dialogs/instrument.ts +111 -111
- package/src/ui/dialogs/keySignature.ts +175 -176
- package/src/ui/dialogs/keySignatureVue.ts +47 -47
- package/src/ui/dialogs/library.ts +207 -207
- package/src/ui/dialogs/libraryVue.ts +62 -48
- package/src/ui/dialogs/lyricVue.ts +46 -46
- package/src/ui/dialogs/measureFormat.ts +78 -78
- package/src/ui/dialogs/microtones.ts +147 -147
- package/src/ui/dialogs/noteHead.ts +319 -319
- package/src/ui/dialogs/pageLayout.ts +61 -61
- package/src/ui/dialogs/partInfo.ts +60 -60
- package/src/ui/dialogs/pedalMarking.ts +117 -117
- package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
- package/src/ui/dialogs/pitch.ts +352 -352
- package/src/ui/dialogs/preferences.ts +40 -40
- package/src/ui/dialogs/rehearsalMark.ts +64 -64
- package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
- package/src/ui/dialogs/scoreId.ts +35 -36
- package/src/ui/dialogs/scoreView.ts +42 -42
- package/src/ui/dialogs/slur.ts +308 -310
- package/src/ui/dialogs/slurVue.ts +91 -91
- package/src/ui/dialogs/staffGroup.ts +112 -112
- package/src/ui/dialogs/tabNote.ts +84 -84
- package/src/ui/dialogs/tabStave.ts +182 -182
- package/src/ui/dialogs/tempo.ts +261 -263
- package/src/ui/dialogs/tempoVue.ts +73 -73
- package/src/ui/dialogs/textBlockVue.ts +127 -127
- package/src/ui/dialogs/textBracket.ts +114 -116
- package/src/ui/dialogs/textBracketVue.ts +56 -56
- package/src/ui/dialogs/tie.ts +140 -142
- package/src/ui/dialogs/timeSignature.ts +65 -66
- package/src/ui/dialogs/transposeScore.ts +39 -39
- package/src/ui/dialogs/unsavedChanges.ts +43 -0
- package/src/ui/dialogs/volta.ts +120 -122
- package/src/ui/dialogs/voltaVue.ts +51 -51
- package/src/ui/fileio/library.ts +110 -111
- package/src/ui/menus/edit.ts +100 -1
- package/src/ui/menus/file.ts +19 -3
- package/tests/pageDivisions.ts +156 -0
- package/tests/promiseHelpersUsage.ts +142 -0
- package/tests/scoreChangeState.ts +102 -0
- package/tests/selectVoice.ts +189 -0
- package/tests/voiceCopyPaste.ts +417 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Specification Quality Checklist: Unsaved Changes Indicator and Save Prompt
|
|
2
|
+
|
|
3
|
+
**Purpose**: Validate specification completeness and quality before proceeding to planning
|
|
4
|
+
|
|
5
|
+
**Created**: 2026-10-13
|
|
6
|
+
|
|
7
|
+
**Feature**: [spec.md](../spec.md)
|
|
8
|
+
|
|
9
|
+
## Content Quality
|
|
10
|
+
|
|
11
|
+
- [x] No implementation details (languages, frameworks, APIs)
|
|
12
|
+
- [x] Focused on user value and business needs
|
|
13
|
+
- [x] Written for non-technical stakeholders
|
|
14
|
+
- [x] All mandatory sections completed
|
|
15
|
+
|
|
16
|
+
## Requirement Completeness
|
|
17
|
+
|
|
18
|
+
- [x] No [NEEDS CLARIFICATION] markers remain
|
|
19
|
+
- [x] Requirements are testable and unambiguous
|
|
20
|
+
- [x] Success criteria are measurable
|
|
21
|
+
- [x] Success criteria are technology-agnostic (no implementation details)
|
|
22
|
+
- [x] All acceptance scenarios are defined
|
|
23
|
+
- [x] Edge cases are identified
|
|
24
|
+
- [x] Scope is clearly bounded
|
|
25
|
+
- [x] Dependencies and assumptions identified
|
|
26
|
+
|
|
27
|
+
## Feature Readiness
|
|
28
|
+
|
|
29
|
+
- [x] All functional requirements have clear acceptance criteria
|
|
30
|
+
- [x] User scenarios cover primary flows
|
|
31
|
+
- [x] Feature meets measurable outcomes defined in Success Criteria
|
|
32
|
+
- [x] No implementation details leak into specification
|
|
33
|
+
|
|
34
|
+
## Notes
|
|
35
|
+
|
|
36
|
+
- The Input line quotes the request verbatim, so it names the sidebar component and scoreView. The rest of the spec uses behavioral terms only.
|
|
37
|
+
- The request suggested hooking the change flag into the undo methods; FR-002 captures that as "whenever an editing operation records an undo step", and the plan phase should confirm which code paths that covers.
|
|
38
|
+
- Defaults chosen instead of clarification markers: Quick Save counts as saved; undo and redo never clear the asterisk; the Save choice reuses the existing Save dialog; an empty name shows a placeholder; closing the browser tab is out of scope.
|
|
39
|
+
- Ready for `/speckit-clarify` or `/speckit-plan`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contract: Score Change Tracking and Save Prompt
|
|
2
|
+
|
|
3
|
+
Implemented across `src/smo/xform/undo.ts`, `src/render/sui/scoreChangeState.ts`, `scoreView.ts`, `scoreViewOperations.ts` and the dialogs in `src/ui`. Headless cases (S1 to S14) are verified by `tests/scoreChangeState.ts` (`npm run test:score-change-state`); UI cases (U1 to U12) are verified manually per [quickstart.md](../quickstart.md). Spec references: [spec.md](../spec.md).
|
|
4
|
+
|
|
5
|
+
## Headless test cases
|
|
6
|
+
|
|
7
|
+
| ID | Case | Expected | Spec |
|
|
8
|
+
|----|------|----------|------|
|
|
9
|
+
| S1 | `UndoBuffer` with no `onAddBuffer` set: `addBuffer` as before | no error, buffer grows | compatibility |
|
|
10
|
+
| S2 | `onAddBuffer` set, one `addBuffer` | callback called once | FR-002 |
|
|
11
|
+
| S3 | `onAddBuffer` set, several `addBuffer` calls (including while `grouping` is true) | callback called for every call | FR-002 |
|
|
12
|
+
| S4 | `reset()` after setting `onAddBuffer`, then `addBuffer` | callback still called (reset does not drop the hook) | FR-002 |
|
|
13
|
+
| S5 | `isFullSaveFormat('.json')` | true | FR-004 |
|
|
14
|
+
| S6 | `isFullSaveFormat` for `.xml`, `.mid`, `.midi`, `.js` | false | FR-004 |
|
|
15
|
+
| S7 | `isFullSaveFormat` for unknown, empty and upper-case (`'.JSON'`) input | false for unknown and empty; true for `.JSON` (case-insensitive) | FR-004 |
|
|
16
|
+
| S8 | `formatScoreTitle('My Song', false)` | `'My Song'` | FR-005, FR-006 |
|
|
17
|
+
| S9 | `formatScoreTitle('My Song', true)` | `'My Song*'` | FR-006 |
|
|
18
|
+
| S10 | `formatScoreTitle('', false)` and `formatScoreTitle(' ', false)` | `'Untitled'` | FR-008 |
|
|
19
|
+
| S11 | `formatScoreTitle('', true)` | `'Untitled*'` (no bare asterisk) | FR-008 |
|
|
20
|
+
| S12 | `nextStepAfterSave('saved')` | `'load'` | FR-011 |
|
|
21
|
+
| S13 | `nextStepAfterSave('exported')` | `'prompt'` | FR-011, scenario 5a |
|
|
22
|
+
| S14 | `nextStepAfterSave('cancelled')` | `'abort'` | FR-011, scenario 5 |
|
|
23
|
+
|
|
24
|
+
## Manual UI cases
|
|
25
|
+
|
|
26
|
+
| ID | Case | Expected | Spec |
|
|
27
|
+
|----|------|----------|------|
|
|
28
|
+
| U1 | App starts, header | `Smoosic <name>`, no asterisk | US1.1, US3.2 |
|
|
29
|
+
| U2 | Add a note | asterisk appears | US1.2, SC-001 |
|
|
30
|
+
| U3 | Edit text (add, modify, remove a text group) | asterisk appears (these bypass the usual undo helpers) | FR-002 |
|
|
31
|
+
| U4 | Select, scroll, zoom | no asterisk | FR-003 |
|
|
32
|
+
| U5 | Press undo | asterisk appears or stays | edge case |
|
|
33
|
+
| U6 | Save dialog, Smoosic format, Save | asterisk clears | US1.3, FR-004 |
|
|
34
|
+
| U7 | Save dialog, MusicXML or MIDI, Save | asterisk stays | US1.4a, FR-004 |
|
|
35
|
+
| U8 | Quick Save | asterisk clears | FR-004 |
|
|
36
|
+
| U9 | Rename in the score-information dialog | header shows the new name | US1.5 |
|
|
37
|
+
| U10 | Changed score, File > New / Open / Import / Library, then Don't save | prompt appears first; new score loads, no asterisk | US2.1/2.3, US3.1 |
|
|
38
|
+
| U11 | Same, then Cancel | nothing loads; asterisk and content unchanged | US2.4 |
|
|
39
|
+
| U12 | Same, then Save and complete a Smoosic-format save | new score loads | US2.2 |
|
|
40
|
+
| U13 | Same, then Save and export MusicXML | prompt appears again; new score not loaded | US2.5a |
|
|
41
|
+
| U14 | Same, then Save and cancel the Save dialog | new score not loaded; asterisk stays | US2.5 |
|
|
42
|
+
| U15 | Unchanged score, then Open | no prompt; loads immediately | US2.6, FR-014 |
|
|
43
|
+
| U16 | Open dialog cancelled before choosing a file | no prompt | US2.7 |
|
|
44
|
+
| U17 | Open an unreadable file | error handling as before; current score and asterisk unchanged | FR-015 |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Data Model: Unsaved Changes Indicator and Save Prompt
|
|
2
|
+
|
|
3
|
+
All state below is in memory for the running session. Nothing is serialized into a score, so file formats and legacy scores are unchanged (constitution Principle #1).
|
|
4
|
+
|
|
5
|
+
## ScoreChangeState (on `SuiScoreView`)
|
|
6
|
+
|
|
7
|
+
| Field | Type | Meaning |
|
|
8
|
+
|-------|------|---------|
|
|
9
|
+
| `scoreChanged` | `Ref<boolean>` | True when the open score has been edited since it was last saved in the full Smoosic format or loaded |
|
|
10
|
+
| `scoreName` | `Ref<string>` | The open score's name (from `score.scoreInfo.name`), as stored; the display placeholder is applied at format time |
|
|
11
|
+
|
|
12
|
+
**Initial value**: `scoreChanged = false`; `scoreName` = initial score's name.
|
|
13
|
+
|
|
14
|
+
**Transitions**
|
|
15
|
+
|
|
16
|
+
| Event | Effect |
|
|
17
|
+
|-------|--------|
|
|
18
|
+
| `UndoBuffer.addBuffer` called (any edit) | `scoreChanged = true` via `onAddBuffer` |
|
|
19
|
+
| `SuiScoreView.undo()` completes | `scoreChanged = true`; `scoreName` refreshed |
|
|
20
|
+
| `updateScoreInfo(...)` | `scoreName` refreshed (flag set by the undo record it makes) |
|
|
21
|
+
| `changeScore(score)` completes | `scoreChanged = false`; `scoreName` refreshed |
|
|
22
|
+
| `recordSave(ext)` with a full-fidelity extension | `scoreChanged = false` |
|
|
23
|
+
| `recordSave(ext)` with a lossy extension | no change |
|
|
24
|
+
| `quickSave()` | `scoreChanged = false` |
|
|
25
|
+
| Selection, scrolling, zoom, playback | no change |
|
|
26
|
+
|
|
27
|
+
## UndoBuffer (changed)
|
|
28
|
+
|
|
29
|
+
| Member | Type | Meaning |
|
|
30
|
+
|--------|------|---------|
|
|
31
|
+
| `onAddBuffer` | `(() => void) \| undefined` | Optional listener called at the end of every `addBuffer`; unset by default so existing users of `UndoBuffer` behave as before |
|
|
32
|
+
|
|
33
|
+
## Pure policy module `scoreChangeState.ts`
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
type SaveOutcome = 'saved' | 'exported' | 'cancelled';
|
|
37
|
+
type AfterSaveStep = 'load' | 'prompt' | 'abort';
|
|
38
|
+
|
|
39
|
+
isFullSaveFormat(extension: string): boolean // '.json', compared case-insensitively
|
|
40
|
+
formatScoreTitle(name: string, changed: boolean): string // 'Untitled' placeholder; trailing '*' when changed
|
|
41
|
+
nextStepAfterSave(outcome: SaveOutcome): AfterSaveStep // saved -> load, exported -> prompt, cancelled -> abort
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`formatScoreTitle` returns only the score portion (for example `My Song*`); the sidebar shows the application name separately, before it.
|
|
45
|
+
|
|
46
|
+
## Save prompt (UI)
|
|
47
|
+
|
|
48
|
+
| Choice | Result of `confirmReplaceScore` |
|
|
49
|
+
|--------|--------------------------------|
|
|
50
|
+
| No unsaved changes | resolves `true` immediately, no prompt shown |
|
|
51
|
+
| Don't save | resolves `true` |
|
|
52
|
+
| Cancel | resolves `false` |
|
|
53
|
+
| Save, then outcome `saved` | resolves `true` |
|
|
54
|
+
| Save, then outcome `exported` | prompt shown again |
|
|
55
|
+
| Save, then outcome `cancelled` | resolves `false` |
|
|
56
|
+
|
|
57
|
+
## Dialog interface additions
|
|
58
|
+
|
|
59
|
+
| Interface | Addition |
|
|
60
|
+
|-----------|----------|
|
|
61
|
+
| `DialogInstallParams` (`dialog.ts`) | `afterCloseCb?: DialogCallback`, awaited after a commit has closed and unmounted the dialog (not run on cancel) |
|
|
62
|
+
| `SuiFileSaveDialog` | second, optional argument `onClosed?: (outcome: SaveOutcome) => void` |
|
|
63
|
+
| `library.vue` props | a callback that reports the selected URL on commit, replacing the direct `loadRemoteScore` call |
|
|
64
|
+
| `sidebar.vue` props | `scoreName: Ref<string>`, `scoreChanged: Ref<boolean>` |
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Implementation Plan: Unsaved Changes Indicator and Save Prompt
|
|
2
|
+
|
|
3
|
+
**Branch**: `028-unsaved-changes-indicator` | **Date**: 2026-10-13 | **Spec**: [spec.md](./spec.md)
|
|
4
|
+
|
|
5
|
+
**Input**: Feature specification from `/specs/028-unsaved-changes-indicator/spec.md`
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
The score view gains two pieces of session state, `scoreChanged` and `scoreName` (both Vue refs, like the existing `selectedPart`), that the sidebar header renders as `Smoosic <name>*`. The changed flag is set from a single choke point: `UndoBuffer.addBuffer` gets an optional `onAddBuffer` callback that `SuiScoreView` wires to `markScoreChanged()`. This catches all ten places that record undo (seven in `scoreView.ts`, three in `scoreViewOperations.ts` that bypass the `_undo*` helpers). `SuiScoreView.undo()` also marks the score changed. The flag is cleared at the end of `changeScore` (every new, opened, imported or library load) and by a new `SuiScoreViewOperations.recordSave(extension)` that clears it only for the full Smoosic format (`.json`), plus `quickSave()`. The Save dialog calls `recordSave` on commit and reports its outcome (`saved`, `exported`, `cancelled`) to a new "unsaved changes" prompt. That prompt gates New, Open, Import and Music Library loads: Save (looping back to the prompt after a lossy export), Don't save, or Cancel. Because the Open and Library dialogs are themselves modal, the prompt runs from a new `afterCloseCb` that `InstallDialog` calls once the host dialog has closed.
|
|
10
|
+
|
|
11
|
+
## Technical Context
|
|
12
|
+
|
|
13
|
+
**Language/Version**: TypeScript (built by `build/build.js`); Vue 3 `<script setup>` for components.
|
|
14
|
+
|
|
15
|
+
**Primary Dependencies**: Existing only: Vue 3 (`ref`), `UndoBuffer` (`src/smo/xform/undo.ts`), `SuiScoreView` / `SuiScoreViewOperations`, `InstallDialog` (`src/ui/dialogs/dialog.ts`), `SuiFileSaveDialog` / `SuiFileUploadDialog` (`fileDialogs.ts`), `libraryVue.ts` / `library.vue`, `sidebar.vue`, `file.ts` menu.
|
|
16
|
+
|
|
17
|
+
**Storage**: None added. The change state is memory-only and is not serialized into the score; `quickSave` still writes the same local-storage JSON.
|
|
18
|
+
|
|
19
|
+
**Testing**: Headless `ts-node` script `tests/scoreChangeState.ts` (`npm run test:score-change-state`) for the pure logic: the `UndoBuffer` callback, the lossless-format policy, the title formatter, and the prompt-loop decision function. UI behavior (header, prompt, dialog sequencing) is verified manually per `quickstart.md`; rendering UI regression is lower priority per the constitution.
|
|
20
|
+
|
|
21
|
+
**Target Platform**: Browser application; headless tests under Node.
|
|
22
|
+
|
|
23
|
+
**Project Type**: Single project (library + application); existing `src/` and `tests/` layout.
|
|
24
|
+
|
|
25
|
+
**Performance Goals**: No regression. The `addBuffer` callback sets one boolean ref; the header re-renders one text node. No DOM measurement or per-render work is added.
|
|
26
|
+
|
|
27
|
+
**Constraints**: `src/smo` stays UI-free (the `onAddBuffer` callback is a plain function field). Not persisted in score JSON. Must work in part view (the flag follows the one `storeScore`). The prompt must not appear while another modal's DOM is still mounted.
|
|
28
|
+
|
|
29
|
+
**Scale/Scope**: About 8 touched files and 2 new files (a Vue prompt component and a small pure helper module), plus one test.
|
|
30
|
+
|
|
31
|
+
## Constitution Check
|
|
32
|
+
|
|
33
|
+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
|
34
|
+
|
|
35
|
+
- **Principle #1 (Serialization)**: PASS. Nothing is added to `SmoScore` or any serialized shape; the changed flag and name display are runtime state. Existing and legacy scores load unchanged.
|
|
36
|
+
- **Principle #2 (Non-UI logic regression testing)**: PASS. The decision logic (which formats count as a full save, when to prompt, what happens after a lossy export) and the undo-recording hook are pure and covered by a headless script with a contract case list, matching specs 019, 022, 023 and 027.
|
|
37
|
+
- **Principle #3 (Rendering performance)**: PASS. The only per-edit cost is one boolean assignment inside `addBuffer`; no render path, DOM measurement or repaint logic changes.
|
|
38
|
+
- **Principle #4 (Logical dependencies)**: PASS. `UndoBuffer` (smo layer) gains only a plain callback and knows nothing about views or Vue. State lives in the view (the render layer already holds Vue refs, e.g. `selectedPart`). Prompt and dialog code live in `src/ui`. The render layer does not import UI code.
|
|
39
|
+
|
|
40
|
+
No violations; Complexity Tracking is not needed. Re-check after Phase 1: unchanged, still PASS.
|
|
41
|
+
|
|
42
|
+
## Project Structure
|
|
43
|
+
|
|
44
|
+
### Documentation (this feature)
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
specs/028-unsaved-changes-indicator/
|
|
48
|
+
├── plan.md
|
|
49
|
+
├── research.md
|
|
50
|
+
├── data-model.md
|
|
51
|
+
├── quickstart.md
|
|
52
|
+
├── contracts/
|
|
53
|
+
│ └── score-change-contract.md
|
|
54
|
+
├── checklists/
|
|
55
|
+
│ └── requirements.md
|
|
56
|
+
└── tasks.md # created later by /speckit-tasks
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Source Code (repository root)
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
src/
|
|
63
|
+
├── smo/xform/
|
|
64
|
+
│ └── undo.ts # UndoBuffer: optional onAddBuffer callback, fired by addBuffer
|
|
65
|
+
├── render/sui/
|
|
66
|
+
│ ├── scoreChangeState.ts # NEW, no imports: isFullSaveFormat(ext), formatScoreTitle(name, changed),
|
|
67
|
+
│ │ # nextStepAfterSave(outcome, fullySaved)
|
|
68
|
+
│ ├── scoreView.ts # scoreName/scoreChanged refs; markScoreChanged/markScoreSaved/refreshScoreName;
|
|
69
|
+
│ │ # wire storeUndo.onAddBuffer; undo() marks changed; changeScore() clears + refreshes
|
|
70
|
+
│ └── scoreViewOperations.ts # recordSave(extension); quickSave() clears; updateScoreInfo() refreshes name
|
|
71
|
+
├── ui/
|
|
72
|
+
│ ├── dialogs/
|
|
73
|
+
│ │ ├── dialog.ts # DialogInstallParams.afterCloseCb, run after a commit has closed the dialog
|
|
74
|
+
│ │ ├── fileDialogs.ts # Upload: convert in commit, replace in afterCloseCb after prompt;
|
|
75
|
+
│ │ │ # Save: recordSave on commit, report outcome via onClosed
|
|
76
|
+
│ │ ├── libraryVue.ts # afterCloseCb: prompt then loadRemoteScore
|
|
77
|
+
│ │ └── unsavedChanges.ts # NEW: confirmReplaceScore(parameters): Promise<boolean>
|
|
78
|
+
│ ├── components/
|
|
79
|
+
│ │ ├── buttons/sidebar.vue # shows "Smoosic <name>*"
|
|
80
|
+
│ │ └── dialogs/
|
|
81
|
+
│ │ ├── library.vue # report selected url instead of loading directly
|
|
82
|
+
│ │ └── unsavedChanges.vue # NEW: Save / Don't save / Cancel
|
|
83
|
+
│ ├── buttons/ribbon.ts # pass scoreName/scoreChanged refs to the sidebar app
|
|
84
|
+
│ └── menus/file.ts # New: prompt before changeScore
|
|
85
|
+
|
|
86
|
+
tests/
|
|
87
|
+
└── scoreChangeState.ts # NEW headless regression script
|
|
88
|
+
|
|
89
|
+
package.json # add "test:score-change-state" script
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Structure Decision**: Keep to the existing layering (smo / render / ui). A single pure module, `scoreChangeState.ts`, holds the policy so tests do not need DOM, Vue or VexFlow imports.
|
|
93
|
+
|
|
94
|
+
## Complexity Tracking
|
|
95
|
+
|
|
96
|
+
*No Constitution Check violations; table not needed.*
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Quickstart: Validating the Unsaved Changes Indicator
|
|
2
|
+
|
|
3
|
+
Contract cases are in [contracts/score-change-contract.md](./contracts/score-change-contract.md); state and transitions are in [data-model.md](./data-model.md).
|
|
4
|
+
|
|
5
|
+
## 1. Headless regression test
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run test:score-change-state
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Expected: every case S1 to S14 prints `PASS`, the run ends with `all checks passed`, and the exit code is 0.
|
|
12
|
+
|
|
13
|
+
## 2. Type check and build
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx tsc --noEmit -p tsconfig.json
|
|
17
|
+
npm run build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Expected: no errors; the webpack build completes.
|
|
21
|
+
|
|
22
|
+
## 3. Existing tests still pass
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run test:page-divisions
|
|
26
|
+
npm run test:global-layout-reposition
|
|
27
|
+
npm run test:text-drag-placement
|
|
28
|
+
npm run test:attached-text
|
|
29
|
+
npm run test:rehearsal-measure-number
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 4. Manual check in the app
|
|
33
|
+
|
|
34
|
+
Prerequisite: build and open the app.
|
|
35
|
+
|
|
36
|
+
**Header**
|
|
37
|
+
1. Open the app. The sidebar header reads `Smoosic <score name>` with no asterisk.
|
|
38
|
+
2. Add a note. An asterisk appears after the name.
|
|
39
|
+
3. Add or edit a text block (title, annotation). The asterisk appears (text edits record undo through a different code path than note edits, so check them separately).
|
|
40
|
+
4. Select notes, scroll and zoom. No asterisk appears on an unchanged score.
|
|
41
|
+
5. Open the score information dialog and change the name. The header shows the new name.
|
|
42
|
+
|
|
43
|
+
**Saving**
|
|
44
|
+
6. With an asterisk showing, File > Save, choose Smoosic format, Save. The asterisk clears.
|
|
45
|
+
7. Make an edit, then File > Save, choose MusicXML, Save. The asterisk stays.
|
|
46
|
+
8. Make an edit, then Quick Save. The asterisk clears.
|
|
47
|
+
|
|
48
|
+
**Prompt**
|
|
49
|
+
9. Make an edit. File > New. The prompt appears. Choose Cancel: nothing changes. Repeat and choose Don't save: a new default score loads with no asterisk.
|
|
50
|
+
10. Make an edit. File > Open, pick a file. After the Open dialog closes the prompt appears. Choose Save, save in Smoosic format: the file then loads.
|
|
51
|
+
11. Make an edit. File > Open, pick a file, prompt, Save, export MusicXML: the prompt appears again and the file is not loaded. Then choose Cancel to stay.
|
|
52
|
+
12. Make an edit. Open the Music Library and load a score: the same prompt appears after the library closes.
|
|
53
|
+
13. Open the Open dialog and cancel it. No prompt appears.
|
|
54
|
+
14. With no edits since loading, File > Open and load a file. No prompt appears.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Research: Unsaved Changes Indicator and Save Prompt
|
|
2
|
+
|
|
3
|
+
No NEEDS CLARIFICATION items remained after `/speckit-clarify`. The findings below come from reading the code; each ends in a decision.
|
|
4
|
+
|
|
5
|
+
## 1. Where to detect "the score changed"
|
|
6
|
+
|
|
7
|
+
**Finding**: Every undo record goes through `UndoBuffer.addBuffer`. There are 10 call sites outside `undo.ts`: seven in `scoreView.ts` (`undoStaffModifier`, `_undoColumn`, `_undoScorePreferences`, `undoMeasureRange`, `_undoFirstMeasureSelection`, `_undoSelection`, `_undoScore`) and three direct calls in `scoreViewOperations.ts` (`remove text group` twice, `modify text`). The three direct calls do not use the `_undo*` helpers.
|
|
8
|
+
|
|
9
|
+
**Decision**: Add an optional `onAddBuffer?: () => void` field to `UndoBuffer`, invoked at the end of `addBuffer`. `SuiScoreView`'s constructor sets `this.storeUndo.onAddBuffer = () => this.markScoreChanged()`. Because `changeScore` calls `storeUndo.reset()` rather than replacing the buffer, the hook survives score loads.
|
|
10
|
+
|
|
11
|
+
**Alternatives considered**: Hooking only the `_undo*` helpers in `scoreView.ts` (the original suggestion). Rejected: it would miss text-group edits in `scoreViewOperations.ts` and any future direct `addBuffer` call. Hooking the helpers plus the three direct sites is possible but needs ten edits and stays fragile. The single callback covers all of them and keeps `UndoBuffer` free of any view or Vue knowledge (Principle #4).
|
|
12
|
+
|
|
13
|
+
## 2. Undo itself
|
|
14
|
+
|
|
15
|
+
**Finding**: `SuiScoreView.undo()` pops the undo stack and restores content. It does not call `addBuffer`. There is no redo path in the view.
|
|
16
|
+
|
|
17
|
+
**Decision**: `undo()` calls `markScoreChanged()` after restoring. The spec says undo is an edit and never clears the flag.
|
|
18
|
+
|
|
19
|
+
## 3. When to clear
|
|
20
|
+
|
|
21
|
+
**Finding**: All user-initiated loads funnel through `SuiScoreView.changeScore` (File menu New, Open, Import via `SuiFileUploadDialog`; `loadRemoteXml` / `loadRemoteJson` for the library). `generateVexTests.ts` and application startup also call it or construct the view with a score.
|
|
22
|
+
|
|
23
|
+
**Decision**: `changeScore` sets `scoreChanged = false` and refreshes the name as its last step, after `awaitRender`, so anything that records undo while the new score is being set up cannot leave a stray asterisk. The view constructor starts with the flag false and the name read from the initial score.
|
|
24
|
+
|
|
25
|
+
## 4. What counts as a save
|
|
26
|
+
|
|
27
|
+
**Finding**: `SuiFileSaveDialog` builds the file contents itself and offers `.json` (Smoosic), `.xml`, `.mid`/`.midi`, `.js` (Vex) and a "Validation (large)" option. The validation option sets the dialog extension back to `.json` after generating the content with different serialization options. `quickSave()` writes the same full JSON as the first option to local storage. The file is only produced when the download link is clicked, which happens in the dialog's commit callback.
|
|
28
|
+
|
|
29
|
+
**Decision**: Add `SuiScoreViewOperations.recordSave(extension: string): boolean`, called by the dialog on commit with its current extension. It clears the flag and returns true only when the extension is a full-fidelity format; for `.xml`, `.mid`, `.midi`, `.js` it leaves the flag alone and returns false. The policy itself is the pure function `isFullSaveFormat` in `scoreChangeState.ts`. `quickSave()` calls `markScoreSaved()` directly. This follows the clarification: the dialog does not know which formats are lossy; the view operation does.
|
|
30
|
+
|
|
31
|
+
**Alternatives considered**: Moving all content builders (`getSmoContent`, `getMusicXmlContent`, and so on) out of the dialog into `scoreViewOperations.ts` so one method both produces and records the save. Rejected for now as a larger refactor with no behavior benefit; `recordSave` keeps the knowledge in the view operation, as asked, with a small change.
|
|
32
|
+
|
|
33
|
+
**Known limit**: The dialog commits when the link is clicked; the application cannot see whether the browser's download actually finished. The flag is cleared on click.
|
|
34
|
+
|
|
35
|
+
## 5. Reactivity for the sidebar
|
|
36
|
+
|
|
37
|
+
**Finding**: The sidebar is mounted by `createSidebarMenuHtml` in `ribbon.ts` with `createApp(ribbonSidebarApp, { buttonProps, domId })`. The ribbon already watches `this.view.PartName`, a `Ref<string>` getter backed by `selectedPart` in `SuiScoreView`.
|
|
38
|
+
|
|
39
|
+
**Decision**: Follow the same pattern: `SuiScoreView` owns `scoreName: Ref<string>` and `scoreChanged: Ref<boolean>`; `ribbon.ts` passes both as props to the sidebar app; `sidebar.vue` renders `Smoosic {{ scoreName }}{{ scoreChanged ? '*' : '' }}`. Formatting goes through `formatScoreTitle(name, changed)` so the placeholder rule (empty name becomes "Untitled") is testable. The name is refreshed in `changeScore`, `updateScoreInfo`, and `undo()` (a score-info undo can change it).
|
|
40
|
+
|
|
41
|
+
## 6. Showing the prompt from inside a modal dialog
|
|
42
|
+
|
|
43
|
+
**Finding**: `InstallDialog` runs the dialog's commit callback and then, in the same function, calls `hideDialogModal()` and unmounts the Vue app. Opening a second dialog from inside the first commit callback would mount at the shared modal root (`replaceVueRoot` empties and recreates it) and then be hidden by the first dialog's own cleanup. Existing nested dialogs avoid this by passing `startPromise` so the new one waits for the old one to close.
|
|
44
|
+
|
|
45
|
+
**Decision**: Add an optional `afterCloseCb?: DialogCallback` to `DialogInstallParams`, awaited at the very end of the install's `commitCb` (after unmount) and not on cancel. The Open/Import dialog and the Library dialog do their score replacement from `afterCloseCb`. Everything the first dialog needs to do before closing (read and convert the file) stays in its commit callback, and the prompt appears only after the first dialog has fully gone. The File menu's New handler runs after the menu has closed, so it calls the prompt directly (passing `menu.closePromise` as `startPromise`, as the menu's other dialogs do).
|
|
46
|
+
|
|
47
|
+
**Alternatives considered**: (a) Prompt before opening the Open/Library dialog. Rejected: it would ask users who only wanted to look at the library, and contradicts spec scenario 7 (cancelling the selection should not leave a prompt). (b) `setTimeout(0)` inside the commit callback to run after cleanup. Rejected as timing-dependent. (c) A guard hook inside `changeScore`. Rejected: the render layer must not call UI, and it would still run inside the modal.
|
|
48
|
+
|
|
49
|
+
## 7. The save-then-load loop
|
|
50
|
+
|
|
51
|
+
**Decision**: `confirmReplaceScore(parameters)` loops:
|
|
52
|
+
|
|
53
|
+
1. If `!view.scoreChanged.value`, return true.
|
|
54
|
+
2. Show the prompt. Cancel returns false. Don't save returns true.
|
|
55
|
+
3. Save opens `SuiFileSaveDialog` with an `onClosed(outcome)` callback: `'saved'` (committed with a full format, so `recordSave` cleared the flag), `'exported'` (committed with a lossy format), `'cancelled'`.
|
|
56
|
+
4. After the save dialog closes, the pure function `nextStepAfterSave(outcome)` returns `'load'` for saved, `'prompt'` for exported (back to step 2), and `'abort'` for cancelled (return false).
|
|
57
|
+
|
|
58
|
+
This matches spec scenarios 2, 5 and 5a and FR-011.
|
|
59
|
+
|
|
60
|
+
## 8. Library dialog
|
|
61
|
+
|
|
62
|
+
**Finding**: `library.vue` currently calls `view.loadRemoteScore(url)` inside its commit handler, before `commitCb`. The legacy `SuiLibraryDialog` (`library.ts`) calls the same view method, but the ribbon creates `SuiLibraryDialogVue`.
|
|
63
|
+
|
|
64
|
+
**Decision**: Change `library.vue` to report the chosen URL through a prop callback and let `libraryVue.ts` load it from `afterCloseCb` after the prompt. The legacy `library.ts` path is not reachable from the ribbon; it is left unchanged and noted as out of scope.
|
|
65
|
+
|
|
66
|
+
## 9. Nothing here is persisted
|
|
67
|
+
|
|
68
|
+
The flag and name are not part of `SmoScore.serialize`; no schema or legacy-score handling is needed (Principle #1).
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Feature Specification: Unsaved Changes Indicator and Save Prompt
|
|
2
|
+
|
|
3
|
+
**Feature Branch**: `028-unsaved-changes-indicator`
|
|
4
|
+
|
|
5
|
+
**Created**: 2026-10-13
|
|
6
|
+
|
|
7
|
+
**Status**: Draft
|
|
8
|
+
|
|
9
|
+
**Input**: User description: "Indicate whether the user has saved the score, and check before loading a score from the library or file menu whether the user wants to save or not. In the sidebar.vue component, show the name of the current score after 'Smoosic'. Indicate with an asterisk if the file has been changed since it was last saved. There probably isn't a way to tell right now if the score has been changed. It makes the most sense to do this in scoreView.ts, whenever one of the 'undo....' methods is called: if we are pushing something onto the undo buffer, we are inevitably going to be modifying the score, so we can indicate the change. The flag should be cleared when a new score is created or loaded."
|
|
10
|
+
|
|
11
|
+
## Clarifications
|
|
12
|
+
|
|
13
|
+
### Session 2026-10-13
|
|
14
|
+
|
|
15
|
+
- Q: Do exports to MusicXML or MIDI clear the unsaved-changes indicator? → A: No. Those formats are lossy, so only a save in the full Smoosic (JSON) format clears it. The Save dialog does not know the difference, so the save operation itself decides whether the change state is cleared.
|
|
16
|
+
- Q: When the user chooses Save on the prompt but exports only to a lossy format, does the new score still load? → A: No. The score is still unsaved, so the new score is not loaded and the save prompt is shown again.
|
|
17
|
+
|
|
18
|
+
## User Scenarios & Testing *(mandatory)*
|
|
19
|
+
|
|
20
|
+
### User Story 1 - See which score is open and whether it has unsaved changes (Priority: P1)
|
|
21
|
+
|
|
22
|
+
A user working on a score looks at the sidebar header, which reads "Smoosic" followed by the name of the score they have open. As soon as they make an edit, an asterisk appears after the name. When they save the score, the asterisk disappears. At a glance, they know whether closing the page or switching scores would lose work.
|
|
23
|
+
|
|
24
|
+
**Why this priority**: This is the core of the request. It gives the user the information, and it is the basis for the save prompt in Story 2. It is useful on its own even if the prompt were never added.
|
|
25
|
+
|
|
26
|
+
**Independent Test**: Open a score, confirm the sidebar shows its name with no asterisk. Make any edit (for example, add a note) and confirm an asterisk appears. Save the score and confirm the asterisk disappears.
|
|
27
|
+
|
|
28
|
+
**Acceptance Scenarios**:
|
|
29
|
+
|
|
30
|
+
1. **Given** a score has just been created or loaded, **When** the user looks at the sidebar header, **Then** it shows "Smoosic" followed by the score's name, with no asterisk.
|
|
31
|
+
2. **Given** a score with no unsaved changes, **When** the user makes an edit that can be undone (adding or changing notes, measures, text, layout or other score content), **Then** an asterisk appears after the score name.
|
|
32
|
+
3. **Given** a score with unsaved changes, **When** the user saves it, **Then** the asterisk is removed.
|
|
33
|
+
4. **Given** a score with unsaved changes, **When** the user saves it and then makes another edit, **Then** the asterisk appears again.
|
|
34
|
+
4a. **Given** a score with unsaved changes, **When** the user exports it to a lossy format such as MusicXML or MIDI, **Then** the asterisk remains, because the exported file does not preserve the whole score.
|
|
35
|
+
5. **Given** the user changes the score's name in the score information dialog, **When** the change is applied, **Then** the sidebar header shows the new name.
|
|
36
|
+
6. **Given** a score whose name is empty, **When** the sidebar header is shown, **Then** it displays a readable placeholder name rather than blank text or a stray asterisk next to "Smoosic".
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### User Story 2 - Be asked to save before replacing the open score (Priority: P1)
|
|
41
|
+
|
|
42
|
+
A user with unsaved changes chooses to open a different score: New, Open, or Import from the File menu, or a score from the Music Library. Before the current score is replaced, the user is asked whether to save it. They can save and continue, continue without saving, or cancel and stay on the current score. If there are no unsaved changes, the new score loads straight away without a prompt.
|
|
43
|
+
|
|
44
|
+
**Why this priority**: This prevents the real harm, silently losing work. It depends on Story 1's change tracking, and is the reason for that tracking.
|
|
45
|
+
|
|
46
|
+
**Independent Test**: Make an edit, then choose Open (or pick a library score). Confirm a prompt appears and that each of its three choices behaves as described. Then save, choose Open again, and confirm no prompt appears.
|
|
47
|
+
|
|
48
|
+
**Acceptance Scenarios**:
|
|
49
|
+
|
|
50
|
+
1. **Given** a score with unsaved changes, **When** the user starts loading another score from the File menu (New, Open, or Import) or from the Music Library, **Then** a prompt asks whether to save the current score first, with options to save, not save, or cancel.
|
|
51
|
+
2. **Given** the prompt is showing, **When** the user chooses to save, **Then** the user is taken through saving the current score, and once the score has been saved in the full Smoosic format the new score loads.
|
|
52
|
+
3. **Given** the prompt is showing, **When** the user chooses not to save, **Then** the current score is discarded and the new score loads.
|
|
53
|
+
4. **Given** the prompt is showing, **When** the user cancels, **Then** nothing is loaded and the current score and its unsaved-changes state are unchanged.
|
|
54
|
+
5. **Given** the user chose to save but then abandons the save step without saving, **When** the save step closes, **Then** the new score is not loaded and the current score remains open with its asterisk.
|
|
55
|
+
5a. **Given** the user chose to save but exported to a lossy format (MusicXML or MIDI), **When** the save step closes, **Then** the new score is not loaded, the current score remains open with its asterisk, and the save prompt is shown again so the user can save in the full format, choose not to save, or cancel.
|
|
56
|
+
6. **Given** a score with no unsaved changes, **When** the user starts loading another score, **Then** no prompt appears and the new score loads immediately.
|
|
57
|
+
7. **Given** the user starts loading a score from a file or the library and then cancels the file or library selection itself, **When** the selection closes without choosing a score, **Then** no save prompt is left behind and the current score is unaffected.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### User Story 3 - Fresh start for each new or loaded score (Priority: P2)
|
|
62
|
+
|
|
63
|
+
Whenever a score is created, opened, imported, or loaded from the library (including loads done programmatically at startup), the new score begins as "saved". The asterisk from the previous score never carries over, and the header shows the new score's name.
|
|
64
|
+
|
|
65
|
+
**Why this priority**: It makes Stories 1 and 2 accurate across consecutive scores. It is lower priority only because it mostly falls out of loading correctly.
|
|
66
|
+
|
|
67
|
+
**Independent Test**: Make an edit (asterisk appears), choose "don't save" on the prompt while loading another score, and confirm the new score shows its own name with no asterisk. Repeat for New, Open, Import and Library.
|
|
68
|
+
|
|
69
|
+
**Acceptance Scenarios**:
|
|
70
|
+
|
|
71
|
+
1. **Given** a score with unsaved changes, **When** the user discards it and a new or loaded score replaces it, **Then** the header shows the new score's name with no asterisk.
|
|
72
|
+
2. **Given** the application starts and loads an initial score, **When** the header is first shown, **Then** it shows that score's name with no asterisk.
|
|
73
|
+
3. **Given** a score is loaded and the user makes no edits, **When** the user starts loading yet another score, **Then** no prompt appears.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### Edge Cases
|
|
78
|
+
|
|
79
|
+
- What happens when the user undoes edits back to the original state? The score is still treated as changed (the asterisk stays) because the application cannot reliably tell the content is identical to what was saved. It clears only on save or load.
|
|
80
|
+
- What happens when the user presses undo or redo? These count as edits to the score and keep or set the asterisk; they never clear it.
|
|
81
|
+
- What happens when the user makes only changes that cannot be undone and so are not tracked (view-only actions such as scrolling, zooming, selecting, or switching between score and a part view)? They do not set the asterisk.
|
|
82
|
+
- What happens when a save is started but the user closes the save dialog without saving? The score remains marked as changed.
|
|
83
|
+
- What happens when the user uses Quick Save? That saves in the full Smoosic format, so it counts as saving and clears the asterisk.
|
|
84
|
+
- What happens when the user exports to MusicXML, MIDI, or another lossy format? The file is written, but the score still counts as unsaved and keeps its asterisk.
|
|
85
|
+
- What happens when a load fails (an unreadable file)? The current score stays open and keeps its unsaved-changes state.
|
|
86
|
+
- What happens when a very long score name is shown? The header stays readable without breaking the sidebar layout; the name may be truncated visually.
|
|
87
|
+
- What happens when the user closes or reloads the browser tab with unsaved changes? Out of scope for this feature (see Assumptions).
|
|
88
|
+
|
|
89
|
+
## Requirements *(mandatory)*
|
|
90
|
+
|
|
91
|
+
### Functional Requirements
|
|
92
|
+
|
|
93
|
+
- **FR-001**: The system MUST track, for the currently open score, whether it has been changed since it was last saved or loaded.
|
|
94
|
+
- **FR-002**: The system MUST mark the score as changed whenever an editing operation records an undo step, since recording an undo step means the score is about to be modified.
|
|
95
|
+
- **FR-003**: The system MUST NOT mark the score as changed because of view-only actions that record no undo step (selection, scrolling, zooming, playback).
|
|
96
|
+
- **FR-004**: The system MUST clear the changed state when the score is saved in the full Smoosic (JSON) format (through the Save dialog or Quick Save), and MUST NOT clear it when the score is exported to a lossy format such as MusicXML or MIDI. The decision is made by the save operation, which knows the format, not by the dialog. The system MUST also clear the changed state when a new score is created or a score is loaded or imported from a file, the Music Library, a remote address, or at application startup.
|
|
97
|
+
- **FR-005**: The sidebar header MUST show the application name followed by the current score's name.
|
|
98
|
+
- **FR-006**: The sidebar header MUST show an asterisk immediately after the score name when the score is marked as changed, and no asterisk otherwise.
|
|
99
|
+
- **FR-007**: The sidebar header MUST update when the score is edited, saved, replaced, or renamed, without the user needing to reload or reopen anything.
|
|
100
|
+
- **FR-008**: When the score's name is empty, the header MUST show a readable placeholder name.
|
|
101
|
+
- **FR-009**: Before a New, Open, or Import action from the File menu, or loading a score from the Music Library, replaces the current score, the system MUST check whether the score is marked as changed.
|
|
102
|
+
- **FR-010**: If the score is marked as changed, the system MUST ask the user whether to save, not save, or cancel, and MUST NOT replace the score until the user decides.
|
|
103
|
+
- **FR-011**: If the user chooses to save, the system MUST run the normal save flow for the current score and load the new score only once the score has been saved in the full Smoosic format; if the save is abandoned, or the score is exported only to a lossy format, the system MUST NOT load the new score, MUST keep the current score and its changed state, and, in the lossy-export case, MUST show the save prompt again.
|
|
104
|
+
- **FR-012**: If the user chooses not to save, the system MUST load the new score without saving the current one.
|
|
105
|
+
- **FR-013**: If the user cancels the prompt, the system MUST leave the current score and its changed state untouched and MUST NOT load anything.
|
|
106
|
+
- **FR-014**: If the score is not marked as changed, the system MUST load the new score without any prompt.
|
|
107
|
+
- **FR-015**: A failed or cancelled load MUST NOT change the current score's changed state.
|
|
108
|
+
|
|
109
|
+
### Key Entities
|
|
110
|
+
|
|
111
|
+
- **Score change state**: A yes/no indication, kept for the currently open score, of whether it has been modified since it was last saved or loaded. It is session state only and is not stored in the saved score file.
|
|
112
|
+
- **Score display name**: The name of the open score, taken from the score's own information; shown in the sidebar header and used as the suggested file name when saving.
|
|
113
|
+
- **Save prompt**: A question shown when the user is about to replace a changed score, offering save, don't save, and cancel.
|
|
114
|
+
|
|
115
|
+
## Success Criteria *(mandatory)*
|
|
116
|
+
|
|
117
|
+
### Measurable Outcomes
|
|
118
|
+
|
|
119
|
+
- **SC-001**: After any single editing action that can be undone, the asterisk is visible in the header within one second, without the user doing anything else.
|
|
120
|
+
- **SC-002**: After a save, the asterisk disappears within one second; and after loading or creating any score, the header shows the new score's name with no asterisk in 100% of cases.
|
|
121
|
+
- **SC-003**: In 100% of attempts to replace a changed score through New, Open, Import, or the Music Library, the user is shown the save prompt before any content is lost; in 0% of attempts with an unchanged score is a prompt shown.
|
|
122
|
+
- **SC-004**: Choosing Cancel on the prompt results in zero change to the open score, its contents, and its asterisk.
|
|
123
|
+
- **SC-005**: A user can tell whether their score has unsaved changes at a glance, without opening any menu.
|
|
124
|
+
|
|
125
|
+
## Assumptions
|
|
126
|
+
|
|
127
|
+
- "Saved" means the score was written in the full Smoosic (JSON) format: either through the Save dialog or by Quick Save to the browser's local storage. Either one clears the asterisk. Exports to other formats (MusicXML, MIDI, and the like) lose information and so do not count as saving. The Save dialog's large "validation" variant of the Smoosic format holds the whole score, so it counts as a full save.
|
|
128
|
+
- Undo and redo are themselves edits and never clear the asterisk. Returning the score to its original content by undoing does not clear it either.
|
|
129
|
+
- The asterisk shows after any step recorded in the undo history, even if the step turns out not to alter the score. Slightly over-reporting a change is acceptable; under-reporting is not.
|
|
130
|
+
- Changes that are not recorded in the undo history (for example, zoom or other view settings) are not tracked as changes.
|
|
131
|
+
- The Save choice in the prompt reuses the existing Save dialog instead of introducing a new save mechanism, and the new score loads after the user completes that dialog.
|
|
132
|
+
- The prompt covers every way of replacing the current score from the user interface: File menu New, Open, and Import, and the Music Library. Loads made by the host application's own code (for example at startup) are not prompted for but do reset the state.
|
|
133
|
+
- The score name is the one in the score's information (the name also used as the suggested file name); an unnamed score is displayed with a placeholder such as "Untitled".
|
|
134
|
+
- Warning on closing or reloading the browser tab (a browser "leave site?" confirmation) is out of scope for this feature.
|
|
135
|
+
- The change state is not saved in the score file, so existing files and serialization are unchanged.
|