smoosic 2.0.3 → 2.0.4

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.
Files changed (245) hide show
  1. package/build/smoosic.js +395 -67
  2. package/changes.md +85 -0
  3. package/package.json +98 -82
  4. package/release/smoosic.js +395 -67
  5. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  6. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  7. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  8. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  9. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  10. package/specs/032-split-multimeasure-rests/research.md +63 -0
  11. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  12. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  13. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  14. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  15. package/specs/033-key-distance-transposition/data-model.md +49 -0
  16. package/specs/033-key-distance-transposition/plan.md +87 -0
  17. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  18. package/specs/033-key-distance-transposition/research.md +82 -0
  19. package/specs/033-key-distance-transposition/spec.md +132 -0
  20. package/specs/033-key-distance-transposition/tasks.md +139 -0
  21. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  22. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  23. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  24. package/specs/034-smz-compressed-scores/plan.md +89 -0
  25. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  26. package/specs/034-smz-compressed-scores/research.md +86 -0
  27. package/specs/034-smz-compressed-scores/spec.md +137 -0
  28. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  29. package/specs/035-paste-special/checklists/requirements.md +35 -0
  30. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  31. package/specs/035-paste-special/data-model.md +47 -0
  32. package/specs/035-paste-special/plan.md +83 -0
  33. package/specs/035-paste-special/quickstart.md +51 -0
  34. package/specs/035-paste-special/research.md +97 -0
  35. package/specs/035-paste-special/spec.md +170 -0
  36. package/specs/035-paste-special/tasks.md +149 -0
  37. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  38. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  39. package/specs/036-autosave-recovery/data-model.md +70 -0
  40. package/specs/036-autosave-recovery/plan.md +87 -0
  41. package/specs/036-autosave-recovery/quickstart.md +65 -0
  42. package/specs/036-autosave-recovery/research.md +105 -0
  43. package/specs/036-autosave-recovery/spec.md +143 -0
  44. package/specs/036-autosave-recovery/tasks.md +165 -0
  45. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  46. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  47. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  48. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  49. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  50. package/specs/037-fix-new-part-dialog/research.md +86 -0
  51. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  52. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  53. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  54. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  55. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  56. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  57. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  58. package/specs/038-per-measure-beam-groups/research.md +72 -0
  59. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  60. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  61. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  62. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  63. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  64. package/specs/039-measure-fill-submenu/plan.md +81 -0
  65. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  66. package/specs/039-measure-fill-submenu/research.md +68 -0
  67. package/specs/039-measure-fill-submenu/spec.md +153 -0
  68. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  69. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  70. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  71. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  72. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  73. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  74. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  75. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  76. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  77. package/specs/041-delete-special/checklists/requirements.md +35 -0
  78. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  79. package/specs/041-delete-special/data-model.md +40 -0
  80. package/specs/041-delete-special/plan.md +93 -0
  81. package/specs/041-delete-special/quickstart.md +41 -0
  82. package/specs/041-delete-special/research.md +75 -0
  83. package/specs/041-delete-special/spec.md +136 -0
  84. package/specs/041-delete-special/tasks.md +106 -0
  85. package/src/application/application.ts +13 -2
  86. package/src/application/exports.ts +401 -395
  87. package/src/application/generateVexTests.ts +2 -2
  88. package/src/render/sui/NoteEntryCaret.ts +117 -16
  89. package/src/render/sui/autosave.ts +265 -0
  90. package/src/render/sui/formatter.ts +12 -2
  91. package/src/render/sui/scoreChangeState.ts +8 -3
  92. package/src/render/sui/scoreView.ts +47 -2
  93. package/src/render/sui/scoreViewOperations.ts +2706 -2555
  94. package/src/render/sui/staffLineGeometry.ts +82 -0
  95. package/src/render/vex/vxMeasure.ts +22 -8
  96. package/src/render/vex/vxNote.ts +2 -4
  97. package/src/smo/data/measure.ts +58 -1
  98. package/src/smo/data/measureModifiers.ts +81 -1
  99. package/src/smo/data/music.ts +169 -359
  100. package/src/smo/data/note.ts +1 -1
  101. package/src/smo/data/noteModifiers.ts +12 -0
  102. package/src/smo/data/score.ts +167 -2
  103. package/src/smo/data/scoreModifiers.ts +46 -1
  104. package/src/smo/data/systemStaff.ts +43 -0
  105. package/src/smo/xform/beamers.ts +80 -6
  106. package/src/smo/xform/copypaste.ts +207 -47
  107. package/src/smo/xform/measureFill.ts +89 -0
  108. package/src/smo/xform/operations.ts +403 -61
  109. package/src/smo/xform/selections.ts +7 -0
  110. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  111. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  112. package/src/ui/components/dialogs/dynamics.vue +16 -3
  113. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  114. package/src/ui/components/dialogs/hairpin.vue +3 -3
  115. package/src/ui/components/dialogs/newPart.vue +148 -184
  116. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  117. package/src/ui/components/dialogs/recovery.vue +66 -0
  118. package/src/ui/components/dialogs/save.vue +11 -4
  119. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  120. package/src/ui/components/dialogs/slur.vue +6 -6
  121. package/src/ui/components/dialogs/tempo.vue +11 -3
  122. package/src/ui/components/dialogs/timeSignature.vue +5 -0
  123. package/src/ui/components/dialogs/volta.vue +3 -3
  124. package/src/ui/dialogs/annotationVue.ts +1 -1
  125. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  126. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  127. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  128. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  129. package/src/ui/dialogs/factory.ts +0 -2
  130. package/src/ui/dialogs/fileDialogs.ts +63 -22
  131. package/src/ui/dialogs/instrument.ts +37 -30
  132. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  133. package/src/ui/dialogs/preferences.ts +41 -40
  134. package/src/ui/dialogs/recovery.ts +49 -0
  135. package/src/ui/fileio/fileInput.ts +12 -3
  136. package/src/ui/fileio/scoreArchive.ts +151 -0
  137. package/src/ui/fileio/xhrLoader.ts +26 -0
  138. package/src/ui/i18n/language.ts +1 -1
  139. package/src/ui/menus/beams.ts +181 -112
  140. package/src/ui/menus/edit.ts +44 -6
  141. package/src/ui/menus/file.ts +21 -1
  142. package/src/ui/menus/measure.ts +40 -1
  143. package/tests/autosave.ts +332 -0
  144. package/tests/beamDotted.ts +56 -0
  145. package/tests/beamGroups.ts +338 -0
  146. package/tests/createPart.ts +292 -0
  147. package/tests/deleteSpecial.ts +350 -0
  148. package/tests/dynamicsFontSize.ts +132 -0
  149. package/tests/keyDistanceTransposition.ts +351 -0
  150. package/tests/measureFill.ts +295 -0
  151. package/tests/movePart.ts +94 -0
  152. package/tests/multimeasureRest.ts +338 -0
  153. package/tests/pasteIntoMeasure.ts +103 -0
  154. package/tests/pasteSpecial.ts +541 -0
  155. package/tests/quickBeam.ts +126 -0
  156. package/tests/scoreArchive.ts +218 -0
  157. package/tests/scoreChangeState.ts +2 -0
  158. package/tests/staffLineGeometry.ts +179 -0
  159. package/tests/timeSignatureDisplay.ts +58 -0
  160. package/tools/smoosic-schema.json +37 -0
  161. package/typedoc.ts +1 -1
  162. package/types/src/application/exports.d.ts +453 -447
  163. package/types/src/common/promiseHelpers.d.ts +30 -30
  164. package/types/src/common/vex.d.ts +224 -224
  165. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  166. package/types/src/render/sui/autosave.d.ts +99 -0
  167. package/types/src/render/sui/scoreView.d.ts +23 -0
  168. package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
  169. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  170. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  171. package/types/src/render/sui/textEdit.d.ts +96 -96
  172. package/types/src/render/sui/textRender.d.ts +199 -199
  173. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  174. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  175. package/types/src/render/vex/vxNote.d.ts +56 -56
  176. package/types/src/render/vex/vxSystem.d.ts +71 -71
  177. package/types/src/smo/data/measure.d.ts +30 -0
  178. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  179. package/types/src/smo/data/music.d.ts +74 -32
  180. package/types/src/smo/data/note.d.ts +498 -498
  181. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  182. package/types/src/smo/data/score.d.ts +476 -421
  183. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  184. package/types/src/smo/data/scoreText.d.ts +334 -334
  185. package/types/src/smo/data/systemStaff.d.ts +14 -0
  186. package/types/src/smo/xform/beamers.d.ts +23 -1
  187. package/types/src/smo/xform/copypaste.d.ts +138 -2
  188. package/types/src/smo/xform/measureFill.d.ts +21 -0
  189. package/types/src/smo/xform/operations.d.ts +245 -129
  190. package/types/src/smo/xform/selections.d.ts +154 -154
  191. package/types/src/smo/xform/undo.d.ts +142 -142
  192. package/types/src/ui/buttons/button.d.ts +100 -100
  193. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  194. package/types/src/ui/common.d.ts +76 -76
  195. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  196. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  197. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  198. package/types/src/ui/composable/draggable.d.ts +15 -15
  199. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  200. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  201. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  202. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  203. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  204. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  205. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  206. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  207. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  208. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  209. package/types/src/ui/dialogs/factory.d.ts +15 -15
  210. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  211. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  212. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  213. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  214. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  215. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  216. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  217. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  218. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  219. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  220. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  221. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  222. package/types/src/ui/dialogs/slur.d.ts +57 -57
  223. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  224. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  225. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  226. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  227. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  228. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  229. package/types/src/ui/dialogs/tie.d.ts +41 -41
  230. package/types/src/ui/dialogs/volta.d.ts +40 -40
  231. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  232. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  233. package/types/src/ui/fileio/library.d.ts +40 -40
  234. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  235. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  236. package/types/src/ui/menus/file.d.ts +8 -8
  237. package/types/src/ui/menus/language.d.ts +7 -7
  238. package/types/src/ui/menus/manager.d.ts +58 -58
  239. package/types/src/ui/menus/menu.d.ts +159 -159
  240. package/types/src/ui/menus/partSelection.d.ts +14 -14
  241. package/types/src/ui/menus/score.d.ts +8 -8
  242. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  243. package/types/typedoc.d.ts +147 -147
  244. package/src/ui/dialogs/dynamics.ts +0 -141
  245. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -0,0 +1,81 @@
1
+ # Implementation Plan: Measure Fill Submenu
2
+
3
+ **Branch**: `039-measure-fill-submenu` (work is on `main`; no feature branch was created) | **Date**: 2026-11-09 | **Spec**: [spec.md](spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/039-measure-fill-submenu/spec.md`
6
+
7
+ ## Summary
8
+
9
+ Add a "Fill Measures" submenu to the Measure menu with three choices (Whole Rest, Beats, Eighth Rests) that replace the selected measures' content with rests.
10
+
11
+ The rule for which rests to use goes in one small, pure module in `src/smo/xform` that turns a time signature, a fill choice and a measure length into a list of rest durations (in ticks). One model operation applies a list to every selected measure: it removes the notes of every voice, builds the rests in a single voice, clears the tuplets and beam groups, and removes the markings that pointed at the removed notes (staff modifiers such as slurs, hairpins and ties that start or end in the measure, and text attached to its notes). One view method wraps the operation in a single whole-score undo step and redraws the changed measures. The menu entries call the view method.
12
+
13
+ ## Technical Context
14
+
15
+ **Language/Version**: TypeScript. Tests run with `ts-node`.
16
+
17
+ **Primary Dependencies**: None new. Reuses `SmoMusic.validDurations` (the rest values the application can show), `SmoMeasure`, `SmoNote`, `SmoSelection`, and the configured-menu submenu mechanism used by Copy Voices and Arpeggio.
18
+
19
+ **Storage**: N/A. A filled measure is an ordinary measure of rest notes and serializes like any other. No new persisted fields.
20
+
21
+ **Testing**: Headless `ts-node` script `tests/measureFill.ts` (npm script `test:measure-fill`), following `tests/beamGroups.ts` and `tests/quickBeam.ts`. The duration rule, the operation and the cleanup are tested; the menu and view method are checked by compilation and the manual steps in [quickstart.md](quickstart.md).
22
+
23
+ **Target Platform**: Browser application and library.
24
+
25
+ **Project Type**: Single project.
26
+
27
+ **Performance Goals**: Work is proportional to the number of selected measures. One whole-score undo snapshot and one redraw of the changed measures per command.
28
+
29
+ **Constraints**: A filled measure must be exactly as long as the measure (never short, never long). The smo layer must not import UI code. The undo must restore voices, staff modifiers and text, so it is a single step.
30
+
31
+ **Scale/Scope**: One pure module, one measure method, one model operation, one view method, one menu submenu, one test file.
32
+
33
+ ## Constitution Check
34
+
35
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
36
+
37
+ | Principle | Assessment |
38
+ |-----------|------------|
39
+ | #1 Serialization | Pass. No new persisted data. A test serializes and reloads a score with filled measures (including a pickup measure) and checks the rests, their durations and the preserved measure settings survive. Scores written before the feature are untouched because nothing is added to the format. |
40
+ | #2 Editing and transformation logic regression tested | Pass. The duration rule is tested against every row of the spec's examples table plus the extra meters in the Assumptions; the operation is tested for voices, tuplets, beams, preserved settings, cleanup, scope, and idempotence. |
41
+ | #3 Rendering performance | Pass. No new rendering code. The view redraws only the changed measures through the existing path. |
42
+ | #4 Logical dependencies | Pass. The rule, the measure method and the operation are in `src/smo` with no UI imports. The menu only calls the view. |
43
+
44
+ Re-check after Phase 1 design: still passes. No complexity violations.
45
+
46
+ ## Project Structure
47
+
48
+ ### Documentation (this feature)
49
+
50
+ ```text
51
+ specs/039-measure-fill-submenu/
52
+ ├── plan.md # This file
53
+ ├── research.md # Phase 0 output
54
+ ├── data-model.md # Phase 1 output
55
+ ├── quickstart.md # Phase 1 output
56
+ ├── contracts/
57
+ │ └── measure-fill-api.md # Phase 1 output
58
+ ├── checklists/
59
+ │ └── requirements.md
60
+ └── tasks.md # Phase 2 output (/speckit-tasks - NOT created by /speckit-plan)
61
+ ```
62
+
63
+ ### Source Code (repository root)
64
+
65
+ ```text
66
+ src/smo/xform/measureFill.ts # NEW pure rule: MeasureFillType, fillRestDurations(), restDurationsFor()
67
+ src/smo/data/measure.ts # NEW SmoMeasure.fillWithRests(durations, defaultBeamBeats): rests in one voice, tuplets/beams cleared
68
+ src/smo/xform/operations.ts # NEW SmoOperation.fillMeasures(): rule + measure + cleanup of modifiers and attached text
69
+ src/render/sui/scoreViewOperations.ts # NEW fillMeasures(fill): one undo step, redraw
70
+ src/ui/menus/measure.ts # NEW "Fill Measures" submenu: Whole Rest, Beats, Eighth Rests
71
+ types/src/... # hand-updated declarations for the files above only
72
+ tests/measureFill.ts # NEW
73
+ package.json # test:measure-fill script
74
+ changes.md # changelog entry
75
+ ```
76
+
77
+ **Structure Decision**: Single-project layout as it exists. The rule is separate from `operations.ts` so it can be tested without a score and read in one place; the operation sits with the other score operations; the menu follows the submenu pattern of `edit.ts` and `note.ts`.
78
+
79
+ ## Complexity Tracking
80
+
81
+ No constitution violations to justify.
@@ -0,0 +1,62 @@
1
+ # Quickstart: Validating the Measure Fill Submenu
2
+
3
+ ## 1. Headless checks
4
+
5
+ ```text
6
+ npm run test:measure-fill
7
+ ```
8
+
9
+ Expected: every case in [contracts/measure-fill-api.md](contracts/measure-fill-api.md) prints `PASS` and the script exits 0.
10
+
11
+ Also run the suites that touch measures and serialization, to check nothing regressed:
12
+
13
+ ```text
14
+ npm run test:beam-groups
15
+ npm run test:quick-beam
16
+ npm run test:score-archive
17
+ npm run test:paste-special
18
+ npm run test:multimeasure-rest
19
+ ```
20
+
21
+ ## 2. Compile
22
+
23
+ ```text
24
+ npx tsc --noEmit -p tsconfig.json
25
+ ```
26
+
27
+ Expected: no errors.
28
+
29
+ ## 3. Manual: Whole Rest (spec user story 1)
30
+
31
+ 1. Open a score in 4/4 with notes in measure 1. Select measure 1, open the Measure menu, choose **Fill Measures**, then **Whole Rest**.
32
+ 2. Expected: measure 1 holds one whole rest and no notes. The key, clef and barlines are unchanged.
33
+ 3. Change measure 2 to 5/8, enter notes, and choose **Whole Rest**. Expected: a half rest and an eighth rest.
34
+ 4. Use Undo. Expected: the notes in measure 2 come back in one step.
35
+
36
+ ## 4. Manual: Beats (user story 2)
37
+
38
+ Choose **Beats** on measures in 4/4, 3/4, 6/8 and 12/8.
39
+
40
+ Expected: four quarter rests, three quarter rests, two dotted quarter rests, and four dotted quarter rests. In 5/8, two quarter rests and an eighth rest.
41
+
42
+ ## 5. Manual: Eighth Rests (user story 3)
43
+
44
+ Choose **Eighth Rests** on measures in 4/4, 6/8 and 5/8.
45
+
46
+ Expected: eight, six and five eighth rests. In 5/16, two eighth rests and a sixteenth rest (a full measure).
47
+
48
+ ## 6. Manual: several measures, voices, markings (user story 4)
49
+
50
+ 1. In a two-staff score, select measures 2 to 5 of the lower staff only and choose **Beats**. Expected: only those four measures change; the upper staff is untouched.
51
+ 2. Put two voices in a measure (the Voice commands), add a slur from that measure to the next, and add a lyric. Choose **Whole Rest**. Expected: one voice of rests; the slur and lyric are gone.
52
+ 3. Draw a hairpin from measure 1 to measure 4, and fill measure 2. Expected: the hairpin is still there.
53
+ 4. Select measures in 4/4 and 6/8 together and choose **Beats**. Expected: each measure uses its own meter.
54
+ 5. Undo once after each. Expected: everything comes back, including the second voice, the slur and the lyric.
55
+
56
+ ## 7. Manual: saving
57
+
58
+ Fill some measures, save the score as JSON, reload it. Expected: the rests are the same. Open a score saved before this feature. Expected: no change.
59
+
60
+ ## 8. Manual: nothing selected
61
+
62
+ Clear the selection if the editor allows it. Expected: **Fill Measures** is not offered.
@@ -0,0 +1,68 @@
1
+ # Research: Measure Fill Submenu
2
+
3
+ All unknowns from the Technical Context are resolved below. No `NEEDS CLARIFICATION` items remain.
4
+
5
+ ## R1: Which rests can the application show?
6
+
7
+ **Finding**: `SmoMusic.validDurations` lists every duration a note or rest can have, with up to three dots. For example 32768 (breve), 24576 (dotted whole), 16384 (whole), 14336 (double-dotted half), 12288 (dotted half), 8192, 6144, 4096, 3072, 2048, and so on. Some lengths are not available as one rest: 10240 (5/8) and 18432 (9/8) are not in the list.
8
+
9
+ **Decision**: The "largest rest that fits" is the largest value in `validDurations` that is not longer than what is left. Repeating that until nothing is left gives the spec's results: 5/8 is 8192 + 2048 (half and eighth), 9/8 is 16384 + 2048 (whole and eighth), 7/8 is 14336 (one double-dotted half), 12/8 is 24576 (one dotted whole), 5/16 is 4096 + 1024.
10
+
11
+ **Rationale**: Uses the application's own table, so a fill can never produce a rest that cannot be drawn or saved.
12
+
13
+ **Alternatives considered**: Preferring a dotted half plus dotted quarter for 9/8 (a better musical grouping in compound meters). The request says "the largest rest possible", so the plain rule is used; the spec's Assumptions record this and the rule is isolated in one function if it is ever changed.
14
+
15
+ ## R2: How is a measure's length decided?
16
+
17
+ **Finding**: `SmoMusic.timeSignatureToTicks(actualBeats, beatDuration)` gives the length of a full measure. `SmoMeasure.isPickup()` is true when voice 0 holds fewer ticks than that, and `getTicksFromVoice(0)` gives what it holds.
18
+
19
+ **Decision**: The target length is the full-measure length, except for a pickup measure, where it is the ticks voice 0 holds now. The beat rules still use the measure's time signature.
20
+
21
+ **Rationale**: Matches the spec (a pickup keeps its length) and means the fill never changes how long a measure is.
22
+
23
+ ## R3: The three rules
24
+
25
+ **Decision** (all work on a target length `T` in ticks):
26
+
27
+ - **Whole Rest**: greedy fill of `T` with the largest valid durations (R1).
28
+ - **Beats**: the beat length `B` comes from the time signature. `floor(T / B)` beats, then the remainder filled greedily (R1). `B` is:
29
+ - lower number 1, 2 or 4: the note value of the lower number (16384, 8192, 4096);
30
+ - lower number 8 or more, with `unit = 16384 / lower` (2048 for 8, 1024 for 16, 512 for 32): compound when the top number is a multiple of 3, `B = 3 * unit` (dotted quarter in x/8, dotted eighth in x/16); otherwise `B = 2 * unit` (quarter in x/8, eighth in x/16).
31
+ This gives 4 quarters for 4/4, 3 quarters for 3/4, 2 dotted quarters for 6/8, 4 for 12/8, 2 quarters and an eighth for 5/8, 3 quarters and an eighth for 7/8, 1 dotted quarter for 3/8, and 2 eighths and a sixteenth for 5/16.
32
+ - **Eighth Rests**: `floor(T / 2048)` eighth rests, then the remainder filled greedily (R1). 5/16 gives two eighths and a sixteenth, so the measure is never short.
33
+
34
+ **Rationale**: These are the spec's rules; the lower-number-8-or-more formula is one rule instead of one per meter.
35
+
36
+ ## R4: Replacing the content of a measure
37
+
38
+ **Finding**: A measure holds `voices` (each `{ notes }`), `tupletTrees`, `beamGroups`, `activeVoice` and its own `modifiers` (barlines, rehearsal marks, tempo, beam groups, and so on). `SmoMeasure.timeSignatureNotes` already shows how to build a rest note for a clef: a default note with `noteType 'r'`, the clef's default pitch (`SmoMeasure.defaultPitchForClef`), `ticks.numerator` and `stemTicks` set to the duration.
39
+
40
+ **Decision**: A new `SmoMeasure.fillWithRests(durations, beamBeats)` builds the rests that way, sets `voices` to one voice of them, empties `tupletTrees` and `beamGroups`, sets `activeVoice` to 0, and copies the measure's key signature onto the new notes. Rests are given the beam length for the meter so later notes entered over them beam as they would in a new measure. Measure modifiers, time signature, clef, key and format are not touched.
41
+
42
+ **Alternatives considered**: Deleting notes one at a time with the existing editing operations (slow, leaves tuplets and voices to clean up); recreating the measure with `getDefaultMeasureWithNotes` (would lose the measure's settings).
43
+
44
+ ## R5: What else points at the removed notes?
45
+
46
+ **Finding**: Staff modifiers (slurs, ties, hairpins, pedal markings, text brackets) hold `startSelector` and `endSelector` with staff, measure, voice and tick. `SmoSystemStaff.deleteMeasure` already removes modifiers whose start or end is in the deleted measure. Text attached to notes is a `SmoTextGroup` with `attachToSelector` and a `selector`, stored on the score (`score.textGroups`) and, for parts that keep their own text, in the staff's part information.
47
+
48
+ **Decision**: For each filled measure of a staff, remove every staff modifier of that staff whose start or end selector is in that measure (the same test `deleteMeasure` uses), and remove every text group attached to a note (`attachToSelector`) whose selector is in that staff and measure, from the score and from the staff's part information. Modifiers that only pass over the measure, with both ends elsewhere, are kept.
49
+
50
+ **Rationale**: Matches FR-010 and the spec's edge case, and cannot leave a marking pointing at a note that no longer exists. Notes' own attachments (lyrics, chords, dynamics, articulations, ornaments, grace notes) go with the notes.
51
+
52
+ ## R6: Undo
53
+
54
+ **Finding**: Undo has buffers for measures, staff modifiers, text groups, and the whole score; `groupUndo` can combine buffers. `clearAllBeams` uses the whole-score buffer.
55
+
56
+ **Decision**: Use the whole-score buffer (`_undoScore`) for one undo step.
57
+
58
+ **Rationale**: The operation changes measures, staff modifiers and text groups, and one buffer that restores all three is simpler and cannot miss one. The cost is serializing the score once per command, which is the same cost `clearAllBeams` has.
59
+
60
+ **Alternatives considered**: A measure buffer per measure plus a buffer per removed modifier and text group (more code, more places to get wrong).
61
+
62
+ ## R7: Selections and parts
63
+
64
+ **Decision**: Apply to the measures of the selections in each selected staff, on both the displayed score and the stored score (`_getEquivalentSelections`), as the other note and measure commands do. Distinct measures are found by staff and measure index. The operation is idempotent, so applying it twice to the same measure (in case the two scores are the same object) is harmless.
65
+
66
+ ## R8: Menu
67
+
68
+ **Decision**: A "Fill Measures" entry in `SuiMeasureMenuOptions` with `subMenu` of three choices ("Whole Rest", "Beats", "Eighth Rests"), following `copyVoicesMenuOption` in `src/ui/menus/edit.ts`. The parent and the choices are displayed when the tracker has selected measures (`menu.tracker.getSelectedMeasures().length > 0`). Handlers call `menu.view.fillMeasures(fill)`.
@@ -0,0 +1,153 @@
1
+ # Feature Specification: Measure Fill Submenu
2
+
3
+ **Feature Branch**: `039-measure-fill-submenu`
4
+
5
+ **Created**: 2026-11-09
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "create a measure fill submenu. It has 3 options: whole rest, which fills the measure with the largest rest possible for that measure (which generally appears as a whole rest). For some odd-times like 5/8 it will not be possible with a single rest, we just get as close as we can. Second option is 'beats'. This will fill either 1/4 notes (even meter time, 3/4) or dotted 1/4 rests for triple time. Third option is eighth rests. This puts eighth rests until the measure won't fit any more. These are all destructive and clear out any notes/voices in the measures."
10
+
11
+ ## User Scenarios & Testing *(mandatory)*
12
+
13
+ ### User Story 1 - Clear a measure to a whole rest (Priority: P1)
14
+
15
+ A user has a measure full of notes that they want to throw away and start again, or a measure that should simply be silent. They select the measure, open the Measure menu, choose the fill submenu, and choose **Whole Rest**. The measure is emptied and holds the largest rest that fits. In 4/4 that is a whole rest. In a meter such as 3/4 or 6/8 it is the single rest that fills the measure (a dotted half rest). In a meter such as 5/8, where no single rest is long enough, the largest rest that fits is used first and the rest of the measure is filled with the next largest, as close to one rest as can be had. Dotted and double-dotted rests count, so 7/8 is a single double-dotted half rest.
16
+
17
+ **Why this priority**: Resting a whole measure is the most common reason to clear it, and it has no equivalent today that works for every meter.
18
+
19
+ **Independent Test**: Select a measure of notes in 4/4 and choose Whole Rest. Confirm it now holds one whole rest and no notes. Repeat in 3/4, 6/8 and 5/8 and compare with the table below.
20
+
21
+ **Acceptance Scenarios**:
22
+
23
+ 1. **Given** a 4/4 measure with notes, **When** the user chooses Whole Rest, **Then** the measure holds exactly one whole rest.
24
+ 2. **Given** a 3/4 measure with notes, **When** the user chooses Whole Rest, **Then** the measure holds exactly one dotted half rest.
25
+ 3. **Given** a 5/8 measure with notes, **When** the user chooses Whole Rest, **Then** the measure holds a half rest followed by an eighth rest, and is full.
26
+ 4. **Given** a measure that already holds only a whole rest, **When** the user chooses Whole Rest, **Then** the measure is unchanged.
27
+
28
+ ---
29
+
30
+ ### User Story 2 - Fill a measure with beat rests (Priority: P1)
31
+
32
+ A user wants a measure of rests, one for each beat, so they can see where to write. They choose **Beats**. In an even meter such as 4/4 or 2/4, and in 3/4, the measure is filled with quarter rests. In a compound ("triple") meter such as 6/8, 9/8 or 12/8, it is filled with dotted quarter rests, one for each beat.
33
+
34
+ **Why this priority**: A measure of beat rests is the usual starting point for entering music, and the right beat is different for 4/4 and for 6/8.
35
+
36
+ **Independent Test**: Choose Beats on a measure in 4/4, 3/4, 6/8 and 12/8 and confirm four quarter rests, three quarter rests, two dotted quarter rests and four dotted quarter rests.
37
+
38
+ **Acceptance Scenarios**:
39
+
40
+ 1. **Given** a 4/4 measure, **When** the user chooses Beats, **Then** the measure holds four quarter rests.
41
+ 2. **Given** a 3/4 measure, **When** the user chooses Beats, **Then** the measure holds three quarter rests.
42
+ 3. **Given** a 6/8 measure, **When** the user chooses Beats, **Then** the measure holds two dotted quarter rests.
43
+ 4. **Given** a 12/8 measure, **When** the user chooses Beats, **Then** the measure holds four dotted quarter rests.
44
+ 5. **Given** a 5/8 measure, **When** the user chooses Beats, **Then** the measure holds two quarter rests and an eighth rest, and is full.
45
+
46
+ ---
47
+
48
+ ### User Story 3 - Fill a measure with eighth rests (Priority: P2)
49
+
50
+ A user who is about to enter a measure of eighth notes chooses **Eighth Rests**. The measure is filled with eighth rests, one after the other, for as long as another eighth rest fits. A 4/4 measure holds eight eighth rests, and a 6/8 measure holds six.
51
+
52
+ **Why this priority**: It is useful for eighth-note passages, but it is a smaller group of users than the first two choices.
53
+
54
+ **Independent Test**: Choose Eighth Rests on measures in 4/4, 3/4, 6/8, 5/8 and 5/16 and confirm eight, six, six, five and two (plus one sixteenth rest) rests.
55
+
56
+ **Acceptance Scenarios**:
57
+
58
+ 1. **Given** a 4/4 measure, **When** the user chooses Eighth Rests, **Then** the measure holds eight eighth rests.
59
+ 2. **Given** a 5/8 measure, **When** the user chooses Eighth Rests, **Then** the measure holds five eighth rests.
60
+ 3. **Given** a 5/16 measure, **When** the user chooses Eighth Rests, **Then** the measure holds two eighth rests followed by a sixteenth rest, so the measure is full.
61
+
62
+ ---
63
+
64
+ ### User Story 4 - Fill several measures at once, and undo it (Priority: P2)
65
+
66
+ A user selects a run of measures, in one or more staves, and chooses one of the fill options. Every selected measure is emptied and filled. Notes in every voice are removed, so each measure ends up with a single voice of rests. If the user did not mean to lose the music, one Undo restores every measure.
67
+
68
+ **Why this priority**: The choices are destructive, so being able to apply them to many measures at once is useful, and being able to undo them is necessary for safety.
69
+
70
+ **Independent Test**: Select measures 2 to 5 of a two-staff score and choose Beats. Confirm measures 2 to 5 of the selected staves are rests and nothing else changed. Choose Undo once and confirm the notes are back.
71
+
72
+ **Acceptance Scenarios**:
73
+
74
+ 1. **Given** measures 2 to 5 of one staff are selected, **When** the user chooses any fill option, **Then** those measures are filled and no other measure or staff changes.
75
+ 2. **Given** a measure with two voices of notes, **When** the user chooses any fill option, **Then** the measure holds one voice, containing only rests.
76
+ 3. **Given** a fill has just been applied, **When** the user chooses Undo once, **Then** all the filled measures return to what they were, including every voice.
77
+ 4. **Given** measures in 4/4 and 6/8 are selected together, **When** the user chooses Beats, **Then** each measure is filled according to its own meter.
78
+
79
+ ---
80
+
81
+ ### Edge Cases
82
+
83
+ - A measure with a time signature that changes partway through the selection is filled by its own time signature, not the first measure's.
84
+ - A pickup (partial) measure is filled to its own length where the time signature allows, otherwise by the same rules as a full measure. [see Assumptions]
85
+ - Notes with lyrics, chords, dynamics, articulations, ornaments, tuplets or other attachments are all removed with the notes.
86
+ - Slurs, ties, hairpins and other markings that run between notes are removed if either end is in a filled measure and that end is removed.
87
+ - The measure's own settings are kept: time signature, key signature, clef, tempo, barlines, endings, repeat symbols, rehearsal marks, measure text and formatting, and any beam grouping.
88
+ - Choosing a fill on a measure that is part of a multimeasure rest, or on a measure that is already all rests, still works and gives the same result as any other measure.
89
+ - A selection that contains no measures (nothing selected) leaves the choices unavailable, with no change to the score.
90
+ - Meters with an odd top number over 8 or 16 (5/8, 7/8, 5/16) cannot be filled with whole beats alone, so the last rest is the largest one that fits; the measure is always completely filled and never left short.
91
+
92
+ ## Requirements *(mandatory)*
93
+
94
+ ### Functional Requirements
95
+
96
+ - **FR-001**: The Measure menu MUST have a submenu for filling measures with rests, with three choices: **Whole Rest**, **Beats** and **Eighth Rests**.
97
+ - **FR-002**: The choices MUST apply to every measure covered by the current selection, in each selected staff.
98
+ - **FR-003**: Each choice MUST remove all notes from the measure, in every voice, and leave one voice that holds only rests and fills the measure.
99
+ - **FR-004**: **Whole Rest** MUST fill the measure with the largest rest that fits. If that does not fill the measure, it MUST add the largest rest that fits in what is left, and so on until the measure is full. Every rest value the application can show is available for this, including dotted and double-dotted rests.
100
+ - **FR-005**: **Whole Rest** MUST give a single rest in 4/4 (whole), 2/4 (half), 3/4 (dotted half), 6/8 (dotted half), 7/8 (double-dotted half) and 12/8 (dotted whole), a half rest and an eighth rest in 5/8, and a whole rest and an eighth rest in 9/8.
101
+ - **FR-006**: **Beats** MUST fill the measure with quarter rests in meters whose lower number is 4 (including 3/4), and with dotted quarter rests in compound meters whose lower number is 8 and whose top number is a multiple of 3 (3/8, 6/8, 9/8, 12/8). For other meters the beat is described in the Assumptions.
102
+ - **FR-007**: **Beats** in a meter that cannot be divided into whole beats (for example 5/8 or 7/8) MUST fill the measure with as many beat rests as fit, followed by the largest rest that fits in the remainder, so the measure is full.
103
+ - **FR-008**: **Eighth Rests** MUST fill the measure with eighth rests for as long as another eighth rest fits. If less than an eighth of the measure is left (for example 5/16), the largest rest that fits in the remainder MUST be added so that the measure is full.
104
+ - **FR-009**: Each measure MUST be filled according to its own time signature, including when several meters are selected together.
105
+ - **FR-010**: Attachments on the removed notes MUST be removed with them, and markings that run between notes MUST NOT be left pointing at removed notes.
106
+ - **FR-011**: The measure's own settings (time signature, key signature, clef, tempo, barlines, endings, repeat symbols, rehearsal marks, text, formatting and beam grouping) MUST be kept.
107
+ - **FR-012**: The filled measures MUST be redrawn without the user taking any other action.
108
+ - **FR-013**: A fill MUST be undoable as a single step that restores every filled measure, including all its voices.
109
+ - **FR-014**: The fill choices MUST NOT be offered when nothing is selected.
110
+ - **FR-015**: Scores saved with filled measures MUST save and reopen normally, and scores saved before this feature MUST be unaffected.
111
+
112
+ ### Examples
113
+
114
+ | Time signature | Whole Rest | Beats | Eighth Rests |
115
+ |----------------|------------|-------|--------------|
116
+ | 4/4 | whole rest | 4 quarter rests | 8 eighth rests |
117
+ | 2/4 | half rest | 2 quarter rests | 4 eighth rests |
118
+ | 3/4 | dotted half rest | 3 quarter rests | 6 eighth rests |
119
+ | 6/8 | dotted half rest | 2 dotted quarter rests | 6 eighth rests |
120
+ | 9/8 | whole rest and eighth rest | 3 dotted quarter rests | 9 eighth rests |
121
+ | 12/8 | dotted whole rest | 4 dotted quarter rests | 12 eighth rests |
122
+ | 5/8 | half rest and eighth rest | 2 quarter rests and an eighth rest | 5 eighth rests |
123
+ | 7/8 | double-dotted half rest | 3 quarter rests and an eighth rest | 7 eighth rests |
124
+ | 5/16 | quarter rest and sixteenth rest | 2 eighth rests and a sixteenth rest | 2 eighth rests and a sixteenth rest |
125
+
126
+ ### Key Entities *(include if feature involves data)*
127
+
128
+ - **Measure**: Is emptied and refilled with rests. Keeps its own settings (time signature, key, tempo, barlines, and so on).
129
+ - **Rest**: A silent note of a given duration. A filled measure holds only rests, in one voice, adding up to the full length of the measure.
130
+ - **Fill choice**: One of Whole Rest, Beats or Eighth Rests. It decides which rests are used and does not persist anywhere after it is applied.
131
+
132
+ ## Success Criteria *(mandatory)*
133
+
134
+ ### Measurable Outcomes
135
+
136
+ - **SC-001**: A user can clear a measure to rests with three actions or fewer: select it, open the fill submenu, choose an option.
137
+ - **SC-002**: For the meters in the examples table, 100% of fills give exactly the rests listed, and the rests add up to the full length of the measure.
138
+ - **SC-003**: A fill applied to any number of selected measures can be reversed with a single Undo, restoring 100% of the notes in every voice.
139
+ - **SC-004**: After any fill, 0 notes remain in the filled measures, and 0 markings are left attached to removed notes.
140
+ - **SC-005**: Scores saved before this feature open with identical content, and a score containing filled measures reopens with the same rests.
141
+
142
+ ## Assumptions
143
+
144
+ - The submenu lives in the Measure menu, alongside the other commands that change whole measures. It is named for filling a measure with rests (for example "Fill Measures").
145
+ - "Triple time" for the Beats choice means a compound meter whose lower number is 8 and whose top number is a multiple of 3 (6/8, 9/8, 12/8, and also 3/8). 3/4 is treated as an even meter for this purpose, as the request says, so it gets quarter rests.
146
+ - Other meters with a lower number of 8 (such as 2/8, 4/8, 5/8, 7/8) get quarter rests, with a final eighth rest when the number of eighths is odd. The same idea applies one level down for a lower number of 16: compound meters whose top number is a multiple of 3 (6/16, 9/16) get dotted eighth rests, and other meters get eighth rests with a final sixteenth rest when needed. For a lower number of 2 (such as 2/2 or 3/2) the beat is a half rest.
147
+ - "Largest rest" means the longest single rest the application can show, so a measure such as 9/8 gets a whole rest and an eighth rest, not a dotted half and a dotted quarter. This is the rule in the request applied as written; a different rule for compound meters can be added later if wanted.
148
+ - When a fill cannot be made of whole beats, the remainder is always filled with the largest rest that fits, so the measure is never left short. This differs slightly from "until the measure won't fit any more" in the request, which would leave a gap in a measure such as 5/16; a short measure would be treated as a pickup, which was not intended.
149
+ - The fill applies to the staves and measures in the current selection only, as other measure commands do.
150
+ - Pickup measures keep their own length: they are filled to the length they have now, using the same rules.
151
+ - "Whole Rest" is the name of the choice even where the result is not literally a whole rest (3/4 gives a dotted half rest), because the request describes it as the largest rest for the measure.
152
+ - Multimeasure rest settings, "force rest" measure formatting and other display options are not changed by this feature.
153
+ - Localization of the new menu text follows the existing practice for menus.
@@ -0,0 +1,121 @@
1
+ ---
2
+
3
+ description: "Task list for Measure Fill Submenu"
4
+ ---
5
+
6
+ # Tasks: Measure Fill Submenu
7
+
8
+ **Input**: Design documents from `/specs/039-measure-fill-submenu/`
9
+
10
+ **Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md), [data-model.md](data-model.md), [contracts/measure-fill-api.md](contracts/measure-fill-api.md), [quickstart.md](quickstart.md)
11
+
12
+ **Tests**: Included. The constitution asks for regression tests on editing logic and serialization. The duration rule, the measure method, the operation and the cleanup are tested headless in `tests/measureFill.ts`; the menu and view method are checked by compilation and [quickstart.md](quickstart.md).
13
+
14
+ **Organization**: Tasks are grouped by user story. The duration rule for all three fills, the measure method, the operation and the view method serve every story, so they are in the Foundational phase. Each story then adds its menu choice and its tests.
15
+
16
+ ## Format: `[ID] [P?] [Story] Description`
17
+
18
+ - **[P]**: Can run in parallel (different files, no dependencies on unfinished tasks)
19
+ - **[Story]**: Which user story the task belongs to (US1 to US4)
20
+
21
+ ## Phase 1: Setup
22
+
23
+ - [X] T001 Create `tests/measureFill.ts` with the `check()`/failure-count harness and the dynamic-ctor registration used in `tests/quickBeam.ts` (`noteModifierDynamicCtorInit`, `measureModifierDynamicCtorInit`, `staffModifierDynamicCtorInit`, `scoreModifierDynamicCtorInit`). Add helpers: `ts(actualBeats, beatDuration)` returning `new SmoTimeSignature({ ...SmoTimeSignature.defaults, times: [{ actualBeats, beatDuration }] })`; `buildScore(meters: [number, number][], staves = 1)` that makes a default score, adds measures until it has `meters.length` measures, sets each measure's time signature from `meters`, fills each measure's voice 0 with notes of the measure's beat length (`noteType = 'n'`, built with `SmoNote.cloneWithDuration`) and adds the requested number of staves as `tests/beamGroups.ts` does; and `pick(score, staff, measure)` returning `SmoSelection.measureSelection(score, staff, measure)!`. Register `"test:measure-fill": "ts-node -P tests/tsconfig.json tests/measureFill.ts"` in `package.json`
24
+
25
+ ---
26
+
27
+ ## Phase 2: Foundational (Blocking Prerequisites)
28
+
29
+ **Purpose**: The rule, the measure method, the operation and the view method. See [data-model.md](data-model.md) and [research.md](research.md) R1 to R7.
30
+
31
+ - [X] T002 Create `src/smo/xform/measureFill.ts` (no UI imports) exporting `type MeasureFillType = 'wholeRest' | 'beats' | 'eighthRests'` and `fillRestDurations(timeSignature: SmoTimeSignature, fill: MeasureFillType, totalTicks?: number): number[]` as specified in [data-model.md](data-model.md). Private helpers: `greedy(left)` that repeatedly takes the largest key of `SmoMusic.validDurations` that is not larger than what is left (sort the keys numerically, descending, once) and stops if nothing fits; `beatTicks(timeSignature)` implementing the beat length rule (lower number 1, 2 or 4 gives the note value; 8 or more gives 3 or 2 times `16384 / lower` depending on whether the top number is a multiple of 3). `totalTicks` defaults to `SmoMusic.timeSignatureToTicks(actualBeats, beatDuration)`. Use the time signature's current `actualBeats` and `beatDuration`
32
+ - [X] T003 In `src/smo/data/measure.ts` add `fillWithRests(durations: number[], beamBeats: number)`: build each rest as `SmoNote.defaults` with `noteType = 'r'`, `clef = this.clef`, the pitch `SmoMeasure.defaultPitchForClef[this.clef]`, `ticks.numerator = duration`, `stemTicks = duration` and `beamBeats`; set `this.voices = [{ notes }]`, `this.tupletTrees = []`, `this.beamGroups = []`, `this.activeVoice = 0`; then call `this.setKeySignature(this.keySignature)` so the new notes carry the key. Do not touch `modifiers`, `timeSignature`, `tempo` or `format`
33
+ - [X] T004 Add `SmoOperation.fillMeasures(score: SmoScore, selections: SmoSelection[], fill: MeasureFillType)` to `src/smo/xform/operations.ts` as specified in [data-model.md](data-model.md): for each distinct (staff, measure) in the selections work out the target length (the full measure, or `getTicksFromVoice(0)` if `isPickup()`), get the durations from `fillRestDurations`, remove from the staff every modifier whose `startSelector.measure` or `endSelector.measure` is this measure (build a new array like `SmoSystemStaff.deleteMeasure` does and also remove matching entries from the staff's text brackets/tab stave handling by going through `staff.removeStaffModifier` for each match), remove every `SmoTextGroup` with `attachToSelector` whose selector is in this staff and measure from `score.textGroups` (use `score.removeTextGroup`) and from the staff's `partInfo.textGroups`, then call `measure.fillWithRests(durations, beamBeats)` with the score's triple default when the top number is a multiple of 3, otherwise the duple default (the test used by `clearAllBeamGroups`)
34
+ - [X] T005 Add `fillMeasures(fill: MeasureFillType): Promise<void>` to `SuiScoreViewOperations` in `src/render/sui/scoreViewOperations.ts`: do nothing if there are no selections; `this._undoScore('fill measures')`; get `const selections = this.tracker.selections` and `const measureSelections = SmoSelection.getMeasureList(selections)`; run `SmoOperation.fillMeasures(this.score, selections, fill)` and `SmoOperation.fillMeasures(this.storeScore, this._getEquivalentSelections(selections), fill)`; `this._renderChangedMeasures(measureSelections)`; `await this.renderer.updatePromise()`
35
+ - [X] T006 Run `npx tsc --noEmit -p tsconfig.json` to confirm the foundation compiles
36
+
37
+ **Checkpoint**: The rule and the operation exist and can be called. Nothing in the menu uses them yet.
38
+
39
+ ---
40
+
41
+ ## Phase 3: User Story 1 - Clear a measure to a whole rest (Priority: P1)
42
+
43
+ **Goal**: A user selects measures, opens Measure, Fill Measures, Whole Rest, and each measure holds the largest rests that fit.
44
+
45
+ **Independent Test**: Run the Whole Rest cases in `tests/measureFill.ts`, then [quickstart.md](quickstart.md) section 3.
46
+
47
+ - [X] T007 [US1] In `src/ui/menus/measure.ts` add the "Fill Measures" submenu: a helper `fillChoice(fill: MeasureFillType, text: string, value: string)` returning a `SuiConfiguredMenuOption` whose handler is `await menu.view.fillMeasures(fill)` and whose `display` is `menu.tracker.getSelectedMeasures().length > 0`; a `fillMeasuresMenuOption` with `subMenu` set to the choices, `handler: async () => { }` (unreachable, as in `edit.ts`), the same `display`, and `menuChoice: { icon: '', text: 'Fill Measures', value: 'fillMeasuresMenuOption' }`; add it to the Measure menu list. Add only the Whole Rest choice (`'Whole Rest'`, value `'fillWholeRest'`) here
48
+ - [X] T008 [US1] In `tests/measureFill.ts` add the Whole Rest duration cases from [data-model.md](data-model.md) (D1, D4, D7, D10, D13, D16, D19, D22, D25, D28, D31, D34, D37: the Whole Rest column for 4/4, 2/4, 3/4, 6/8, 9/8, 12/8, 5/8, 7/8, 3/8, 4/8, 2/2, 6/16 and 5/16) and the pickup cases D42 and D46. Add the `SmoMeasure.fillWithRests` cases F1 to F5 and the operation cases O3, O11, O12 and O13. Run `npm run test:measure-fill`
49
+
50
+ **Checkpoint**: User story 1 works end to end.
51
+
52
+ ---
53
+
54
+ ## Phase 4: User Story 2 - Fill a measure with beat rests (Priority: P1)
55
+
56
+ **Goal**: Beats gives quarter rests, dotted quarter rests in compound meters, and a remainder rest in odd meters.
57
+
58
+ **Independent Test**: Run the Beats cases in `tests/measureFill.ts`, then [quickstart.md](quickstart.md) section 4.
59
+
60
+ - [X] T009 [US2] Add the **Beats** choice (`'Beats'`, value `'fillBeats'`) to the submenu in `src/ui/menus/measure.ts`, after Whole Rest
61
+ - [X] T010 [US2] In `tests/measureFill.ts` add the Beats duration cases from [data-model.md](data-model.md) (D2, D5, D8, D11, D14, D17, D20, D23, D26, D29, D32, D35, D38) and the pickup cases D43 and D45. Fix `src/smo/xform/measureFill.ts` if any fails (likely places: the compound test for lower number 8 or more, and the remainder). Add O2 (4/4 and 6/8 measures selected together)
62
+
63
+ **Checkpoint**: Whole Rest and Beats both work.
64
+
65
+ ---
66
+
67
+ ## Phase 5: User Story 3 - Fill a measure with eighth rests (Priority: P2)
68
+
69
+ **Goal**: Eighth Rests fills with eighth rests, and a smaller rest if less than an eighth is left.
70
+
71
+ **Independent Test**: Run the Eighth Rests cases in `tests/measureFill.ts`, then [quickstart.md](quickstart.md) section 5.
72
+
73
+ - [X] T011 [US3] Add the **Eighth Rests** choice (`'Eighth Rests'`, value `'fillEighthRests'`) to the submenu in `src/ui/menus/measure.ts`, after Beats
74
+ - [X] T012 [US3] In `tests/measureFill.ts` add the Eighth Rests duration cases from [data-model.md](data-model.md) (D3, D6, D9, D12, D15, D18, D21, D24, D27, D30, D33, D36, D39) and the pickup case D44, and the D40 and D41 checks that every result adds up to the target and uses only valid durations, over all meters and all three fills
75
+
76
+ **Checkpoint**: All three choices work.
77
+
78
+ ---
79
+
80
+ ## Phase 6: User Story 4 - Several measures at once, and undo (Priority: P2)
81
+
82
+ **Goal**: The fill applies to the selected measures and staves only, removes everything attached to the removed notes, keeps the measure's settings, and is one undo step.
83
+
84
+ **Independent Test**: Run the operation and serialization cases in `tests/measureFill.ts`, then [quickstart.md](quickstart.md) section 6.
85
+
86
+ - [X] T013 [US4] In `tests/measureFill.ts` add the operation cases O1 (scope: only the selected measures of the selected staff change), O4 (lyrics, dynamics and articulations gone), O5, O6, O7, O8 (staff modifier cleanup: build slurs and hairpins with `SmoSlur`/`SmoStaffHairpin` and `staff.addStaffModifier`, with selectors from `SmoSelector.default` set to the staff, measure, voice and tick), O9 and O10 (text groups: create a `SmoTextGroup` with `attachToSelector` and a selector, add it with `score.addTextGroup`), O14 (beam grouping kept) and O15 (beam length on the rests)
87
+ - [X] T014 [US4] In `tests/measureFill.ts` add the serialization cases S1 and S2: fill one measure with each fill type and a pickup measure, serialize with `JSON.stringify(score.serialize())`, deserialize with `SmoScore.deserialize`, and compare the rest durations and the preserved settings; and check a score with no filled measures serializes to the same text before and after loading
88
+ - [X] T015 [US4] Add a test in `tests/measureFill.ts` that a measure with two voices ends with one voice (also covered by F1), and one that a 4/4 measure, a 6/8 measure and a 5/8 measure in one selection each get their own meter's rests with Beats (O2 extended to three meters)
89
+
90
+ **Checkpoint**: Every story and every contract case is covered.
91
+
92
+ ---
93
+
94
+ ## Phase 7: Polish and Cross-Cutting Concerns
95
+
96
+ - [X] T016 [P] Update the declarations by hand or with `npm run types`: add `types/src/smo/xform/measureFill.d.ts`, and the new members in `types/src/smo/data/measure.d.ts`, `types/src/smo/xform/operations.d.ts` and `types/src/render/sui/scoreViewOperations.d.ts`. If `npm run types` is used, keep only the changes for these files and restore unrelated declaration churn (`git checkout -- <file>`; delete other newly generated untracked declarations)
97
+ - [X] T017 [P] Add a `changes.md` entry (follow the entries at the top of the file) describing the Fill Measures submenu in the Measure menu, the three choices, that a fill removes all notes, voices and the markings attached to them, and that it is one undo step
98
+ - [X] T018 Run `npx tsc --noEmit -p tsconfig.json`, then `npm run test:measure-fill`, `npm run test:beam-groups`, `npm run test:quick-beam`, `npm run test:beam-dotted`, `npm run test:score-archive`, `npm run test:paste-special`, `npm run test:multimeasure-rest`, `npm run test:create-part`. All must pass
99
+ - [ ] T019 Walk through [quickstart.md](quickstart.md) sections 3 to 8 by hand in the running application and note any difference from the expected results
100
+
101
+ ---
102
+
103
+ ## Dependencies and Execution Order
104
+
105
+ - Phase 1 (T001) first. Phase 2 (T002 to T006) blocks every story. T002 and T003 are independent files; T004 needs both; T005 needs T004.
106
+ - US1 (T007, T008) depends on Phase 2. US2 (T009, T010) and US3 (T011, T012) edit the same menu file as US1, so their menu tasks (T009, T011) follow T007 in order; their test tasks do not depend on the menu.
107
+ - US4 (T013 to T015) depends only on Phase 2 and can run alongside US1 to US3.
108
+ - Polish (T016 to T019) after the stories.
109
+
110
+ ### Parallel opportunities
111
+
112
+ - T002 and T003 (different files).
113
+ - T008, T010, T012 (test cases for different fills) once Phase 2 is done, although they share one file.
114
+ - T013 to T015 alongside the menu tasks.
115
+ - T016 and T017.
116
+
117
+ ## Implementation Strategy
118
+
119
+ **MVP**: Phase 1, Phase 2, then US1 (T001 to T008): a user can clear selected measures to the largest rests that fit. US2 and US3 add one menu choice each; the rule for them is already in place from Phase 2, so each is a small step. US4 locks in the cleanup, scope and persistence. Polish adds declarations, changelog and the manual walkthrough.
120
+
121
+ Run `npm run test:measure-fill` after each phase.
@@ -0,0 +1,36 @@
1
+ # Specification Quality Checklist: Dynamics Dialog Cleanup and Font Size
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+ **Created**: 2026-11-15
5
+ **Feature**: [spec.md](../spec.md)
6
+
7
+ ## Content Quality
8
+
9
+ - [x] No implementation details (languages, frameworks, APIs)
10
+ - [x] Focused on user value and business needs
11
+ - [x] Written for non-technical stakeholders
12
+ - [x] All mandatory sections completed
13
+
14
+ ## Requirement Completeness
15
+
16
+ - [x] No [NEEDS CLARIFICATION] markers remain
17
+ - [x] Requirements are testable and unambiguous
18
+ - [x] Success criteria are measurable
19
+ - [x] Success criteria are technology-agnostic (no implementation details)
20
+ - [x] All acceptance scenarios are defined
21
+ - [x] Edge cases are identified
22
+ - [x] Scope is clearly bounded
23
+ - [x] Dependencies and assumptions identified
24
+
25
+ ## Feature Readiness
26
+
27
+ - [x] All functional requirements have clear acceptance criteria
28
+ - [x] User scenarios cover primary flows
29
+ - [x] Feature meets measurable outcomes defined in Success Criteria
30
+ - [x] No implementation details leak into specification
31
+
32
+ ## Notes
33
+
34
+ - Half of this request is a code cleanup (remove a legacy dialog and its adapter object), so User Story 3, FR-008, FR-009 and SC-006 are necessarily about the code. They say what must be true (one dialog, no adapter, nothing referring to the old one) and not how to write it; the behaviour that users see is in User Stories 1 and 2.
35
+ - The existing behaviours listed in User Story 2 were taken from the current dialog and adapter (live redraw, all selected notes, one undo step, Cancel, Remove, placement next to the marking, adding a default marking from the menu) so the rewrite can be checked against them.
36
+ - The size range (1 to 99) is an assumption, recorded in the spec, because the request does not give one.
@@ -0,0 +1,52 @@
1
+ # Contract: Dynamics Dialog
2
+
3
+ This lists the behaviour that `tests/dynamicsFontSize.ts` checks, the interfaces the dialog depends on, and the checks for the cleanup. Case ids are used in the test names.
4
+
5
+ ## Model: `SmoDynamicText` font size (tests)
6
+
7
+ | Id | Case | Expected |
8
+ |----|------|----------|
9
+ | M1 | a new marking from `SmoDynamicText.defaults` | `fontSize === 30` |
10
+ | M2 | `isValidFontSize` with 1, 30, 99 | true |
11
+ | M3 | `isValidFontSize` with 0, -5, 100, 1000 | false |
12
+ | M4 | `isValidFontSize` with 12.5, `NaN`, `Infinity`, `-Infinity` | false |
13
+ | M5 | `isValidFontSize` with a string or `undefined` (cast) | false |
14
+ | M6 | `minFontSize` and `maxFontSize` | 1 and 99 |
15
+
16
+ ## Serialization (tests)
17
+
18
+ | Id | Case | Expected |
19
+ |----|------|----------|
20
+ | S1 | a marking with the default size, serialized | the output has no `fontSize` |
21
+ | S2 | a marking with size 48, serialized | `fontSize` is 48 |
22
+ | S3 | a score with a size-48 marking on one note and a default marking on another, saved and loaded | the first loads with 48, the second with 30 |
23
+ | S4 | a marking written without `fontSize` (as an older version wrote it) loaded through `SmoDynamicText.deserialize` or the note | `fontSize === 30` |
24
+ | S5 | a size set to 48, then back to 30, then saved | the saved marking has no `fontSize` |
25
+
26
+ ## Applying to selected notes (tests)
27
+
28
+ | Id | Case | Expected |
29
+ |----|------|----------|
30
+ | A1 | three notes; the same marking is added to each with `SmoOperation.addDynamic`; its size is changed to 40 and added to each again | all three notes carry a marking of size 40 and there is exactly one marking on each note |
31
+ | A2 | `SmoOperation.removeDynamic` on each selected note | no note has a marking |
32
+ | A3 | a marking on one note of a measure of two | the other note is unchanged |
33
+
34
+ ## Dialog (checked by compilation, a search, and the manual steps)
35
+
36
+ - The dialog is created by `SuiDynamicModifierDialogVue(parameters)`, exported from `src/ui/dialogs/dynamicsVue.ts`, with the same parameters as now.
37
+ - It passes the component: `domId`, `label` ('Dynamics Properties'), `initialPosition`, `yOffsetLine`, `yOffsetPixels`, `xOffset`, `fontSize`, `text`, `updateNumberCb`, `updateTextCb`, and the commit, cancel and remove callbacks.
38
+ - `updateNumberCb(param, value)` accepts `'yOffsetLine' | 'yOffsetPixels' | 'xOffset' | 'fontSize'`, sets the field on the marking, and applies it to every selected note. A `fontSize` that fails `isValidFontSize` is ignored.
39
+ - The Font Size field shows the marking's current size, steps by 1, and is limited to 1 to 99.
40
+
41
+ ## Cleanup (checked by search and build)
42
+
43
+ | Id | Check | Expected |
44
+ |----|-------|----------|
45
+ | C1 | `src/ui/dialogs/dynamics.ts` | does not exist |
46
+ | C2 | search `src` and `tests` for `SuiDynamicDialogAdapter` | no results |
47
+ | C3 | search `src` and `tests` for `dialogs/dynamics'` | no results |
48
+ | C4 | search `src` and `tests` for `SuiDynamicModifierDialog\b` | only the `ctor` strings in `menus/text.ts` and `dialogs/dynamicsVue.ts`'s function name `SuiDynamicModifierDialogVue` (not matched by `\b` after `Dialog`); no class reference |
49
+ | C5 | `npx tsc --noEmit -p tsconfig.json` | no errors |
50
+ | C6 | compile `dynamics.vue` with `@vue/compiler-sfc` | no errors |
51
+ | C7 | the dialog factory with a `SmoDynamicText` modifier | still calls `SuiDynamicModifierDialogVue` |
52
+ | C8 | the declarations in `types/` | no file or export refers to `dialogs/dynamics` |