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,144 @@
1
+ # Feature Specification: Fix the Create Part Dialog
2
+
3
+ **Feature Branch**: `037-fix-new-part-dialog`
4
+
5
+ **Created**: 2026-11-06
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "Fix some issues when creating new parts or editing part properties. 1) It should be possible to add a part after/before any system in the score. There is a 'staff location' parameter in the create part dialog, but it doesn't let you do that. location 1 should be first, you should be able to set the value to score.staves.length + 1. The largest value would put it after the last staff. 2) You should be able to set a name and abbreviation in the create part dialog, and the name should be 'create part'. The default (placeholder) name is name of the selected instrument. 3) The default value for 'Preserve Text Groups' should be true. Don't change the default in SmoPartInfo.defaults, but set it to that value in the Create Part dialog. 4) Don't insert the new part in an existing 2-stave part, put the new staff either before or after the 2-stave part (even if the staff index indicates otherwise)."
10
+
11
+ ## User Scenarios & Testing *(mandatory)*
12
+
13
+ ### User Story 1 - Put the new part anywhere in the score (Priority: P1)
14
+
15
+ A composer has a score with several staves and wants to add a new part in a particular place: at the very top, between two existing staves, or at the very bottom. In the Create Part dialog, **Staff Location** is the position the new part will have in the score. Location 1 puts it first. Each higher number puts it one place lower, and the largest allowed value, one more than the number of staves now in the score, puts it after the last staff. Today the largest value cannot be reached, the starting value is not a sensible position, and it is not possible to put the new part first or last as expected.
16
+
17
+ **Why this priority**: Without this the dialog cannot do the most basic thing it offers: choose where the part goes. A part added in the wrong place has to be moved by hand, one step at a time.
18
+
19
+ **Independent Test**: In a score with 3 staves, create a part at location 1, and confirm it is the first staff. Undo, create one at location 2 and confirm it sits between the old first and second staves. Undo, create one at location 4 (the largest allowed) and confirm it is the last staff.
20
+
21
+ **Acceptance Scenarios**:
22
+
23
+ 1. **Given** a score with N staves, **When** the user opens the Create Part dialog, **Then** Staff Location accepts whole numbers from 1 to N + 1, and no others.
24
+ 2. **Given** the dialog is open, **When** the user opens it without changing Staff Location, **Then** the starting value is N + 1, so the new part goes after the last staff, which is what most users expect.
25
+ 3. **Given** Staff Location is set to a number K from 1 to N + 1, **When** the user confirms, **Then** the new part is staff number K in the score, and the staves that were at K or beyond move down by one.
26
+ 4. **Given** a score with 1 staff, **When** the user opens the dialog, **Then** Staff Location accepts 1 (before the staff) or 2 (after it).
27
+ 5. **Given** the user types a number outside 1 to N + 1, **Then** it is held to the nearest allowed value.
28
+ 6. **Given** the new part is added, **Then** its music, text and part settings do not disturb those of the staves around it, and the score can still be undone to its earlier state in one step.
29
+
30
+ ---
31
+
32
+ ### User Story 2 - Never split an existing two-stave part (Priority: P1)
33
+
34
+ Some parts take two staves (for example a piano part with treble and bass). If the user chooses a Staff Location that falls between the two staves of such a part, putting the new part there would break the part in two. Instead, the new part is placed just before the whole two-stave part or just after it, so the existing part stays intact.
35
+
36
+ **Why this priority**: Splitting a two-stave part corrupts it (the two staves are meant to be shown and printed together), and the user has no easy way to see or repair it afterward. This is a data-safety rule for story 1.
37
+
38
+ **Independent Test**: In a score where staves 2 and 3 are a two-stave piano part, create a part with Staff Location 3 (which points between those two staves). Confirm the piano part is still two adjacent staves and the new part is either directly before or directly after them, never between them.
39
+
40
+ **Acceptance Scenarios**:
41
+
42
+ 1. **Given** a two-stave part on staves 2 and 3, **When** the user sets Staff Location to 3 (between its staves) and confirms, **Then** the new part is placed after the two-stave part (as staff 4), and the part's two staves stay together.
43
+ 2. **Given** a two-stave part, **When** the location chosen is at its first staff or at the staff right after its second, **Then** the new part is placed exactly there, since that does not split it.
44
+ 3. **Given** the new part is itself a two-stave part, **When** it is placed, **Then** both of its staves are adjacent and it too is not placed inside another two-stave part.
45
+ 4. **Given** the new part has been placed to avoid a split, **Then** nothing else about the dialog changes, and the user is not shown an error.
46
+ 5. **Given** several two-stave parts in the score, **Then** the rule applies to whichever one the chosen location falls inside.
47
+
48
+ ---
49
+
50
+ ### User Story 3 - Name the part when creating it (Priority: P2)
51
+
52
+ A composer creating a part wants to name it right away rather than finding the Part Properties dialog afterward. The Create Part dialog has a **Name** field and an **Abbreviation** field. The dialog's title is "Create Part" (today it is "Instrument Properties", which is confusing, since that is a different dialog). The Name field shows the name of the instrument currently chosen in the dialog as placeholder text; if the user leaves it empty, the part gets that instrument name. If the user changes the instrument, the placeholder follows.
53
+
54
+ **Why this priority**: It saves a step on every new part and gives parts sensible names by default, but the part can still be named later, so it is not as important as placing it correctly.
55
+
56
+ **Independent Test**: Open Create Part, choose Cello without typing a name, and confirm the Name field shows "Cello" as placeholder and the new part is named "Cello". Repeat typing "Cello I" as name and "Vc. I" as abbreviation, and confirm the part has exactly those.
57
+
58
+ **Acceptance Scenarios**:
59
+
60
+ 1. **Given** the dialog is open, **Then** its title is "Create Part" and it has a Name and an Abbreviation field.
61
+ 2. **Given** the Name field is empty, **Then** it shows the chosen instrument's name as placeholder text, and changes it when the instrument changes.
62
+ 3. **Given** the user leaves Name empty and confirms, **Then** the new part's name is the chosen instrument's name.
63
+ 4. **Given** the user types a Name and an Abbreviation and confirms, **Then** the new part has those values.
64
+ 5. **Given** the user leaves Abbreviation empty, **Then** the new part has no abbreviation.
65
+ 6. **Given** a 2-stave part is created, **Then** the name and abbreviation apply to the part as a whole, and the second staff does not get a separate name.
66
+ 7. **Given** the user cancels, **Then** the score is unchanged.
67
+
68
+ ---
69
+
70
+ ### User Story 4 - Keep the text of new parts by default (Priority: P3)
71
+
72
+ When a part is created through the dialog, the option that decides whether text groups (titles, composer, other text boxes) of the part are kept is switched on, so a new part starts with the text that belongs to it. The user can still switch the option off later in the Part Properties dialog. The default used everywhere else is not changed.
73
+
74
+ **Why this priority**: A small default that avoids a later fix in the Part Properties dialog. It does not affect how the part is placed or named.
75
+
76
+ **Independent Test**: Create a part through the dialog, open Part Properties for it, and confirm Preserve Text Groups is on. Create a part some other way (for example by adding a staff through any other path, or by loading an old score) and confirm its setting is unchanged from before.
77
+
78
+ **Acceptance Scenarios**:
79
+
80
+ 1. **Given** a part is created with the Create Part dialog, **Then** its Preserve Text Groups setting is on.
81
+ 2. **Given** a score is loaded from a file, or a part is created by any means other than the Create Part dialog, **Then** the setting has the value it has always had (off by default, or whatever the file says).
82
+ 3. **Given** a part was created with the setting on, **When** the user opens Part Properties, **Then** they can switch it off and the change is kept.
83
+
84
+ ---
85
+
86
+ ### Edge Cases
87
+
88
+ - A score with no staves cannot open this dialog; the existing behavior for that case is unchanged.
89
+ - The score is shown as a single part, not as a full score: the new part is still placed according to its position among all staves in the score, not only the displayed ones, and the view switches to the full score as it does today so the user can see it.
90
+ - The chosen location is the same as that of an existing part's first staff: the new part goes before that part.
91
+ - A two-stave part sits at the end of the score and the user picks N + 1: the new part goes after it (this does not split anything).
92
+ - The user picks a location inside a two-stave part, and the new part is also a two-stave part: it is placed before or after the existing part, as in story 2.
93
+ - The name or abbreviation contains only spaces: it is treated as empty.
94
+ - The instrument is changed after the user has typed a Name: the typed name is kept; only the placeholder changes.
95
+ - Very long names: no limit is added by this change.
96
+ - Undo after creating a part: the whole creation (the new staff or staves, name, and setting) is removed in one step.
97
+
98
+ ## Requirements *(mandatory)*
99
+
100
+ ### Functional Requirements
101
+
102
+ - **FR-001**: The Create Part dialog MUST accept a Staff Location that is a whole number from 1 to the number of staves in the score plus one, and hold other values to the nearest allowed value.
103
+ - **FR-002**: Staff Location 1 MUST put the new part first, each higher number one place lower, and the largest value after the last staff.
104
+ - **FR-003**: The dialog MUST open with Staff Location set to the largest allowed value (after the last staff).
105
+ - **FR-004**: When confirmed, the new part MUST become the staff at the chosen position, and the staves at or after that position MUST move down, keeping their order and content.
106
+ - **FR-005**: If the chosen position falls between the two staves of an existing two-stave part, the new part MUST be placed after that part (directly following its second staff) instead, and the existing part MUST stay together.
107
+ - **FR-006**: A new two-stave part MUST have its two staves adjacent.
108
+ - **FR-007**: The dialog title MUST be "Create Part".
109
+ - **FR-008**: The dialog MUST have a Name field and an Abbreviation field.
110
+ - **FR-009**: The Name field MUST show the chosen instrument's name as placeholder text, updated when the instrument changes.
111
+ - **FR-010**: If Name is empty (or only spaces) when confirmed, the part's name MUST be the chosen instrument's name; otherwise it MUST be the typed name.
112
+ - **FR-011**: The part's abbreviation MUST be the typed abbreviation, or empty if none was typed.
113
+ - **FR-012**: A part created with the dialog MUST have Preserve Text Groups on.
114
+ - **FR-013**: The default setting for Preserve Text Groups for parts created any other way, and for loaded scores, MUST NOT change.
115
+ - **FR-014**: Creating a part MUST be one undoable step that restores the previous score.
116
+ - **FR-015**: Canceling the dialog MUST leave the score unchanged.
117
+
118
+ ### Key Entities
119
+
120
+ - **Part**: A named group of one or two staves in the score, with a name, an abbreviation and settings such as whether its text groups are kept. A two-stave part must stay together.
121
+ - **Staff Location**: The position, counted from 1, that the new part will have among the staves of the score, from first to after the last. It is a request that may be adjusted so as not to split a two-stave part.
122
+ - **Create Part Request**: What the dialog collects: the instrument and clef, staff lines, transposition, whether to use two staves, the location, the name and the abbreviation.
123
+
124
+ ## Success Criteria *(mandatory)*
125
+
126
+ ### Measurable Outcomes
127
+
128
+ - **SC-001**: In a score with N staves, a user can place a new part at every one of the N + 1 possible positions using only the dialog, with no later move needed, and the result is at the chosen position every time.
129
+ - **SC-002**: Across all positions chosen in scores containing two-stave parts, no two-stave part is ever split by a new part (0 splits).
130
+ - **SC-003**: A user can create a named, abbreviated part in one dialog without opening Part Properties afterward.
131
+ - **SC-004**: A part created with an empty Name field always has a non-empty name.
132
+ - **SC-005**: 100% of parts created with the dialog have Preserve Text Groups on, and parts created any other way keep their previous setting.
133
+ - **SC-006**: Undoing a part creation restores the score to exactly its state before, in one step.
134
+
135
+ ## Assumptions
136
+
137
+ - "Staff Location" counts staves of the whole score (including any staves not currently displayed), from 1, and the new part takes that place, so the staff that was there moves down. This matches the request ("location 1 should be first", the largest value "after the last staff").
138
+ - The "selected instrument" in the request is the instrument chosen in the Create Part dialog, and the placeholder follows the choice. The name of an instrument is the label shown for it in the dialog's instrument list (for example "Cello", "Bb Trumpet").
139
+ - When the chosen position is inside a two-stave part, "before or after" is resolved by placing the new part after the part. The request did not say which, and either keeps the part together.
140
+ - A two-stave part is recognized from the part information already kept with its staves.
141
+ - The Abbreviation has no placeholder, and an empty abbreviation is allowed.
142
+ - The Create Part dialog does not get a new Preserve Text Groups toggle; the new part is simply created with it on, and the existing Part Properties dialog is where it can be changed.
143
+ - The title of the dialog is the only existing text changed. The Part Properties dialog and the menu text ("Create New Part/Stave") are unchanged.
144
+ - Parts are created at the full length of the score, as today.
@@ -0,0 +1,174 @@
1
+ ---
2
+
3
+ description: "Task list for Fix the Create Part Dialog"
4
+ ---
5
+
6
+ # Tasks: Fix the Create Part Dialog
7
+
8
+ **Input**: Design documents from `/specs/037-fix-new-part-dialog/`
9
+
10
+ **Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md), [data-model.md](data-model.md), [contracts/create-part-api.md](contracts/create-part-api.md), [quickstart.md](quickstart.md)
11
+
12
+ **Tests**: Included. The constitution asks for regression tests on editing logic and serialization. The model operation and the small helpers are tested headless in `tests/createPart.ts`; the dialog and view method are checked by compilation and [quickstart.md](quickstart.md).
13
+
14
+ **Organization**: Tasks are grouped by user story. Shifting references when a staff is inserted above others is needed by every story, so it is in the Foundational phase.
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/createPart.ts` with the `check()`/failure-count harness and the dynamic-ctor registration used in `tests/voiceCopyPaste.ts` (`noteModifierDynamicCtorInit`, `measureModifierDynamicCtorInit`, `staffModifierDynamicCtorInit`, `scoreModifierDynamicCtorInit`), plus a `buildScore(names: string[])` helper that makes a score with one measure per staff using `SmoScore.getDefaultScore(SmoScore.defaults, null)` and `score.addStaff(...)` with `SmoSystemStaff.defaults` (set `staffId` to the next index), giving each staff a `partInfo.partName` from `names`; and an `order(score)` helper returning the part names in staff order. Register `"test:create-part": "ts-node -P tests/tsconfig.json tests/createPart.ts"` in `package.json`
24
+
25
+ ---
26
+
27
+ ## Phase 2: Foundational (Blocking Prerequisites)
28
+
29
+ **Purpose**: Inserting a staff above others must keep everything that refers to a staff by number correct. See [research.md](research.md) R4.
30
+
31
+ **CRITICAL**: No user story work can begin until this phase is complete.
32
+
33
+ - [X] T002 In `src/smo/data/systemStaff.ts` add `shiftStaffReferences(fromIndex: number, delta: number)` to `SmoSystemStaff`: for every staff modifier in `this.modifiers` and every text bracket in `this.textBrackets`, add `delta` to `startSelector.staff`, `endSelector.staff` and `associatedStaff` when each is `>= fromIndex`; and do the same for the `startSelector.staff` and `endSelector.staff` of every instrument in `this.measureInstrumentMap`. Follow the style of `mapStaffFromTo` in the same file
34
+ - [X] T003 In `src/smo/data/score.ts` add `shiftStaffReferences(fromIndex: number, delta: number)` to `SmoScore`: call each staff's `shiftStaffReferences`, add `delta` to the `startSelector.staff` and `endSelector.staff` of every system group when each is `>= fromIndex`, and add `delta` to `selector.staff` of every score text group that has a selector when it is `>= fromIndex`. Then in `SmoScore.addStaff`, call `this.shiftStaffReferences(parameters.staffId, 1)` just before the new staff is pushed onto `this.staves` (so only the existing staves are shifted and the new staff's own selectors are untouched), and only when `parameters.staffId < this.staves.length` (an append shifts nothing)
35
+ - [X] T004 Write the shifting tests R1-R5 and S2 in `tests/createPart.ts` as listed in [contracts/create-part-api.md](contracts/create-part-api.md): a slur on the third staff (use `SmoSlur` with start and end selectors on that staff, added through `staff.addStaffModifier`), a system group over staves 1-2 and one over 0-2 (`SmoSystemGroup`), an instrument map entry, an append that shifts nothing, and `staves[i].staffId === i` after each insertion, inserting with `score.addStaff` at a staff id of 0, 1 and N. Run `npm run test:create-part` and confirm they pass
36
+
37
+ **Checkpoint**: Staves can be inserted anywhere without corrupting references. User stories can begin.
38
+
39
+ ---
40
+
41
+ ## Phase 3: User Story 1 - Put the new part anywhere in the score (Priority: P1) 🎯 MVP
42
+
43
+ **Goal**: Staff Location accepts 1 to N+1, starts at N+1, and the new part lands there.
44
+
45
+ **Independent Test**: Per [quickstart.md](quickstart.md) section 3: in a score with A, B, C, create a part at 4, 1 and 2 (undoing between) and check where it lands; 0 and 9 are held to 1 and 4; the new part goes in as one undo step.
46
+
47
+ ### Implementation for User Story 1
48
+
49
+ - [X] T005 [US1] In `src/smo/data/score.ts` add `resolveNewPartIndex(location: number): number` to `SmoScore`: round the location (use N+1 if it is not a finite number), hold it to 1..N+1 where N is `this.staves.length`, and return `location - 1`. (The two-stave rule is added in T012.) See [data-model.md](data-model.md) Placement
50
+ - [X] T006 [US1] In `src/smo/xform/operations.ts` export the `AddPartParams` interface from [contracts/create-part-api.md](contracts/create-part-api.md) and add `static addPart(score: SmoScore, params: AddPartParams): number` to `SmoOperation`: resolve the index with `score.resolveNewPartIndex(params.location)`; build `SmoSystemStaff.defaults` parameters with `staffId` set to the index and `measureInstrumentMap[0]` set to a copy of `params.instrument` whose `startSelector.measure` is 0 and `endSelector.measure` is the last measure; build the part information from `SmoPartInfo.defaults` with `partName` set to `params.name.trim()` or `params.instrumentLabel` and `partAbbreviation` to `params.abbreviation.trim()`, and pass it as `partInfo`; call `score.addStaff`; return the index. Keep a single staff here; `twoStaves` is added in T013. Return the index of the new staff
51
+ - [X] T007 [US1] Write the placement tests P1, A1 and A2 in `tests/createPart.ts`: `resolveNewPartIndex` on a 3-staff score for locations 1, 2, 3, 4 and 9 (expect 0, 1, 2, 3, 3), and `addPart` at each of 1..4 checking the new staff's name is at the resolved index and the other names keep their order. Run `npm run test:create-part`
52
+ - [X] T008 [US1] In `src/render/sui/scoreViewOperations.ts` add `async createPart(params: AddPartParams): Promise<void>`: call `this._undoScore('Create part')` once; set the instrument's measure range as `addStaff` does (`startSelector.measure = 0`, `endSelector.measure` = last measure of `this.storeScore.staves[0]`); call `SmoOperation.addPart(this.storeScore, params)`; call `updateInstrumentOffsets()` on the new staff and `this.storeScore.setNoteInstrumentProperties()`; join the new staff to the system group of the staff above it, widening the group instead of assigning (`end = Math.max(end, newIndex)`), or create a two-staff group, exactly as `addStaff` does for a staff id above 0 (research R5); then `this.viewAll()` and `return this.renderer.updatePromise()`. Leave `addStaff` unchanged
53
+ - [X] T009 [US1] In `src/ui/dialogs/instrument.ts` rewrite `SuiCreatePartVue`: keep `staffLocation` as a one-based `ref` starting at `parameters.view.storeScore.staves.length + 1`; `setStaffId` stores the value held to 1..N+1; `commitCb` calls `parameters.view.createPart({ location: staffLocation.value, instrument, twoStaves: addStave, name: '', instrumentLabel: '', abbreviation: '' })` (name fields are filled in T017); remove the two `addStaff` calls and the `partInfo.stavesAfter = 1` code
54
+ - [X] T010 [US1] In `src/ui/components/dialogs/newPart.vue` set the Staff Location input's `initialValue` to `props.staffLength + 1`, `maxValue` to `props.staffLength + 1` and keep `minValue` 1; in `SuiCreatePartVue` (`instrument.ts`) pass `staffLength: storeScore.staves.length` as before. Fix the 2-stave toggle in the component so it calls `props.addStaveCb()` (it currently calls an undefined `addStaveCb`)
55
+ - [ ] T011 [US1] Run `npx tsc --noEmit -p tsconfig.json` and `npm run test:create-part`; then do the quickstart section 3 manual check *(compile and automated tests done; the manual app check is not done)*
56
+
57
+ **Checkpoint**: User Story 1 is complete: a part can be created at any position.
58
+
59
+ ---
60
+
61
+ ## Phase 4: User Story 2 - Never split an existing two-stave part (Priority: P1)
62
+
63
+ **Goal**: A location inside a two-stave part puts the new part after it, and the dialog's own two-stave parts are properly linked.
64
+
65
+ **Independent Test**: Per [quickstart.md](quickstart.md) section 4: create a 2-stave part, then a part at a location between its staves; the part stays together and the new one is below it.
66
+
67
+ ### Implementation for User Story 2
68
+
69
+ - [X] T012 [US2] In `src/smo/data/score.ts` extend `resolveNewPartIndex`: after computing the index, if `index < this.staves.length` and `this.staves[index].partInfo.stavesBefore > 0`, return `index + this.staves[index].partInfo.stavesAfter + 1`. See [research.md](research.md) R3
70
+ - [X] T013 [US2] In `SmoOperation.addPart` (`src/smo/xform/operations.ts`) support `params.twoStaves`: after inserting the first staff at the resolved index, insert a second staff at index + 1 with `measureInstrumentMap[0]` a new `SmoInstrument` of the same instrument and the opposite clef (`instrument.clef === 'treble' ? 'bass' : 'treble'`, as the dialog did), the same name and abbreviation; set the first staff's `partInfo.stavesAfter = 1, stavesBefore = 0` and the second's `stavesAfter = 0, stavesBefore = 1`, on the staves in the score returned from `addStaff` (not on a copy). Build each staff's `SmoPartInfo` separately so they are not shared objects. See [research.md](research.md) R6
71
+ - [X] T014 [US2] In `createPart` (`src/render/sui/scoreViewOperations.ts`) call `updateInstrumentOffsets()` on both new staves when `twoStaves`, and join the second staff to the group with the first (the group end becomes the second staff's index)
72
+ - [X] T015 [US2] Write the two-stave tests P2-P5, A6 and A7 in `tests/createPart.ts`: a score A, P1+P2, C built with `addPart(twoStaves)` then locations 3 (expect 3), 2 (expect 1), 4 (expect 3) and 1 (expect 0); a score of two adjacent two-stave parts; the link values and opposite clefs of a created two-stave part; a two-stave part created at a location inside an existing one lands after it intact. Run `npm run test:create-part`
73
+ - [ ] T016 [US2] Run `npx tsc --noEmit -p tsconfig.json`; then do the quickstart section 4 manual check *(compile and automated tests done; the manual app check is not done)*
74
+
75
+ **Checkpoint**: User Stories 1 and 2 work together: any position, no split parts.
76
+
77
+ ---
78
+
79
+ ## Phase 5: User Story 3 - Name the part when creating it (Priority: P2)
80
+
81
+ **Goal**: The dialog is titled "Create Part", has Name and Abbreviation fields, and the Name placeholder follows the chosen instrument.
82
+
83
+ **Independent Test**: Per [quickstart.md](quickstart.md) section 5: choose Cello with no name and get a part named Cello; type "Cello I" and "Vc. I" and get exactly those.
84
+
85
+ ### Implementation for User Story 3
86
+
87
+ - [X] T017 [US3] Create `src/ui/dialogs/createPartHelpers.ts` (no Vue or DOM imports) exporting `instrumentChoices: SelectOption[]` (move the list from `newPart.vue`, dropping the duplicate "Grand Piano" entry), `instrumentLabelFor(value: string): string`, `clampPartLocation(value: unknown, staffCount: number): number` and `resolvePartName(typed: string, instrumentLabel: string): string` per [contracts/create-part-api.md](contracts/create-part-api.md); import `SelectOption` as a type from `../common`. Use `clampPartLocation` in `SuiCreatePartVue` (T009's `setStaffId`)
88
+ - [X] T018 [P] [US3] Write the helper tests C1-C3 and the name tests A2-A3 in `tests/createPart.ts`: `clampPartLocation` with 0, 1, N+1, N+2, 2.6, NaN and a string; `resolvePartName` with '', ' ', 'Cello I', ' Vc '; no duplicate `value` in `instrumentChoices`; `instrumentLabelFor('cello') === 'Cello'`; `addPart` with a typed name and abbreviation gives exactly those, and with a blank name gives the label. Run `npm run test:create-part`
89
+ - [X] T019 [US3] In `src/ui/components/dialogs/newPart.vue` import `instrumentChoices` from `../../dialogs/createPartHelpers` in place of the local list; add two text inputs (Name and Abbreviation) styled like the text input in `tempo.vue`, with v-models bound to two refs and `@input` callbacks passed in as props `setName(value: string)` and `setAbbreviation(value: string)`; set the Name input's `placeholder` to `instrumentLabelFor(currentInstrument)` where `currentInstrument` is a local ref that `updateInstrumentCb` updates (the instrument object is not reactive here, as the tempo dialog showed)
90
+ - [X] T020 [US3] In `SuiCreatePartVue` (`src/ui/dialogs/instrument.ts`) set the dialog `label` to `'Create Part'`, keep `name` and `abbreviation` in local variables updated by `setName` and `setAbbreviation` (pass them as props), and in `commitCb` pass `name`, `abbreviation` and `instrumentLabel: instrumentLabelFor(instrument.instrument)` to `createPart`
91
+ - [ ] T021 [US3] Run `npx tsc --noEmit -p tsconfig.json`; compile the template with `@vue/compiler-sfc` as a syntax check; then do the quickstart section 5 manual check *(compile and automated tests done; the manual app check is not done)*
92
+
93
+ **Checkpoint**: User Stories 1-3 work: placed, protected and named.
94
+
95
+ ---
96
+
97
+ ## Phase 6: User Story 4 - Keep the text of new parts by default (Priority: P3)
98
+
99
+ **Goal**: A part made with the dialog has Preserve Text Groups on; nothing else changes.
100
+
101
+ **Independent Test**: Per [quickstart.md](quickstart.md) section 6.
102
+
103
+ ### Implementation for User Story 4
104
+
105
+ - [X] T022 [US4] In `SmoOperation.addPart` (`src/smo/xform/operations.ts`) set `preserveTextGroups = true` on every `SmoPartInfo` it builds (one or two staves); do not touch `SmoPartInfo.defaults` or the `SmoSystemStaff` constructor default
106
+ - [X] T023 [US4] Write the tests A4, A5 and S1 in `tests/createPart.ts`: a part from `addPart` has `preserveTextGroups` true on each of its staves; `SmoPartInfo.defaults.preserveTextGroups` is still false after the call; a staff added with `score.addStaff(SmoSystemStaff.defaults)` has it false; and a score with a one-stave and a two-stave part created by `addPart` survives `SmoScore.deserialize(JSON.stringify(score.serialize({ skipStaves: false, useDictionary: false, preserveStaffIds: true })))` with names, abbreviations, the setting and the before/after links intact. Run `npm run test:create-part`
107
+ - [ ] T024 [US4] Run `npx tsc --noEmit -p tsconfig.json`; then do the quickstart section 6 manual check *(compile and automated tests done; the manual app check is not done)*
108
+
109
+ **Checkpoint**: All four stories work.
110
+
111
+ ---
112
+
113
+ ## Phase 7: Polish & Cross-Cutting Concerns
114
+
115
+ - [X] T025 [P] Add a changelog entry to `changes.md`: Create Part dialog fixes (Staff Location 1 to N+1 starting after the last staff; never splits a two-stave part; Name and Abbreviation fields and the "Create Part" title; Preserve Text Groups on for parts made there); one undo step for a two-stave part; inserting a staff above others now keeps slurs, hairpins, brackets and groups attached to the right staves; library note: `SmoScore.addStaff` now shifts references when inserting above existing staves
116
+ - [X] T026 [P] Regenerate declarations with `npm run types` (run it in the background, it takes more than two minutes), keep only the files for sources changed here (`score.d.ts`, `systemStaff.d.ts`, `operations.d.ts`, `scoreViewOperations.d.ts`, `createPartHelpers.d.ts`, `instrument.d.ts` if its signature changed) and restore every other changed or untracked file under `types/`
117
+ - [ ] T027 Run the full [quickstart.md](quickstart.md) sections 1, 2 and 7 *(sections 1 and 2 done; the manual checks are not done)*
118
+ - [X] T028 Run `tsc --noEmit -p tsconfig.json` and every `test:*` script in `package.json`; fix regressions
119
+
120
+ ---
121
+
122
+ ## Dependencies & Execution Order
123
+
124
+ ### Phase dependencies
125
+
126
+ - **Setup (Phase 1)**: none.
127
+ - **Foundational (Phase 2)**: depends on T001. T002 then T003 (same concept, different files; T003 calls T002); T004 after T003.
128
+ - **User Story 1 (Phase 3)**: depends on Phase 2. T005 then T006 (T006 calls T005); T007 after T006; T008 after T006; T009 and T010 after T008 (T010 and T009 touch different files and can be done together).
129
+ - **User Story 2 (Phase 4)**: depends on User Story 1 (it extends T005 and T006 and T008).
130
+ - **User Story 3 (Phase 5)**: depends on User Story 1 (it fills the name fields T006 and T009 left empty). Independent of User Story 2.
131
+ - **User Story 4 (Phase 6)**: depends on T006 only.
132
+ - **Polish (Phase 7)**: depends on all stories.
133
+
134
+ ### Within each story
135
+
136
+ - Model before view; view before dialog; helper module before the component that imports it; tests written in the same step as the code they cover.
137
+
138
+ ### Parallel opportunities
139
+
140
+ - After User Story 1: User Stories 2, 3 and 4 touch mostly different places (T012-T014 model/view; T017-T020 UI; T022 one line) and can proceed in parallel, with T013 and T022 in the same function so those two should be done in order.
141
+ - T018 (tests) is independent of T019.
142
+ - T025 and T026 touch different files.
143
+
144
+ ```text
145
+ # Example: after Phase 3
146
+ Developer A: T012 -> T013 -> T014 -> T015 (US2) then T022 -> T023 (US4)
147
+ Developer B: T017 -> T019 -> T020 (US3), with T018 alongside
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Implementation Strategy
153
+
154
+ ### MVP first (User Story 1)
155
+
156
+ 1. Phase 1 and Phase 2 (shifting references, with tests).
157
+ 2. Phase 3: a part can be created at every position. The dialog already works better than today.
158
+ 3. Stop and check. User Story 2 is also P1: it should ship with it, because the new reach of the dialog makes splitting a two-stave part easy to do by accident.
159
+
160
+ ### Incremental delivery
161
+
162
+ 1. Foundational + US1 + US2: safe placement.
163
+ 2. US3: naming. US4: the setting. Each can ship alone.
164
+ 3. Polish.
165
+
166
+ ---
167
+
168
+ ## Notes
169
+
170
+ - Do not change `SmoPartInfo.defaults`.
171
+ - `SmoScore.addStaff` is used by library callers and by file import; the shifting in T003 must do nothing for an append.
172
+ - The instrument list is a bare list in two places today (the component and `createPartHelpers.ts` after T017); after T019 it must exist only in the helper.
173
+ - Never read the instrument's display label from the select component; use `instrumentLabelFor`.
174
+ - Implementation note: the system-group joining that T008 and T014 put in the view method is in `SmoOperation.addPart` instead, so the headless tests cover it (cases G1 and G2). `createPart` is just the undo step, `addPart`, and the redraw. `addPart` also calls `updateInstrumentOffsets` and `setNoteInstrumentProperties` itself.
@@ -0,0 +1,36 @@
1
+ # Specification Quality Checklist: Per-Measure Beam Groups
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+ **Created**: 2026-11-08
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
+ - The class names from the request (SmoBeamPreferences, SmoMeasureModifierBase, SmoScorePreferences) appear only in the quoted input. The spec body describes the behaviour; mapping to those classes is left to planning.
35
+ - Assumptions record two readings of the request for the user to confirm: "measures" and "selection" are treated as one scope, and "remaining measures" is out of scope.
36
+ - The rule for measures with more beam groups than numbers was settled in the 2026-11-08 clarification: the grouping repeats from its first number.
@@ -0,0 +1,74 @@
1
+ # Contract: Beam Groups
2
+
3
+ This lists the behaviour that `tests/beamGroups.ts` checks, and the interfaces the dialog depends on. Case ids are used in the test names.
4
+
5
+ ## Model
6
+
7
+ ### `SmoBeamPreferences`
8
+
9
+ - `new SmoBeamPreferences({ groups: [3, 2] })` keeps the list; `serialize()` returns `{ ctor: 'SmoBeamPreferences', groups: [3, 2] }`.
10
+ - Values outside 1 to 4, or not whole numbers, are rejected (`isValidGroups` is false; the constructor throws).
11
+
12
+ ### `SmoMeasure`
13
+
14
+ - `getBeamGroups()` on a measure with no modifier returns `[]`.
15
+ - `setBeamGroups([3, 2])` then `getBeamGroups()` returns `[3, 2]`; a second `setBeamGroups([2, 3])` leaves exactly one modifier.
16
+ - `setBeamGroups([])` removes the modifier; the serialized measure has no `SmoBeamPreferences` entry.
17
+ - `setBeamGroups` resets every note in the measure to `beamState` auto.
18
+
19
+ ### `SmoBeamer.groupBoundaries(measure)`
20
+
21
+ | Id | Meter | Grouping | Expected boundaries (units of the measure's unit) |
22
+ |----|-------|----------|----------------------|
23
+ | B1 | 5/8 | `[3, 2]` | 3, 5 |
24
+ | B2 | 5/8 | `[2, 3]` | 2, 5 |
25
+ | B3 | 12/8 | `[3]` | 3, 6, 9, 12 |
26
+ | B4 | 8/8 | `[3, 3, 2]` | 3, 6, 8 |
27
+ | B5 | 10/8 | `[3, 2]` | 3, 5, 8, 10 |
28
+ | B6 | 7/8 | `[3, 2]` | 3, 5, 7 |
29
+ | B7 | 6/16 | `[3]` | 3, 6 (1024-tick units) |
30
+ | B8 | 4/4 | `[]` | no boundaries |
31
+ | B9 | 3/4 | `[2, 1]` | 2, 3, 5, 6 |
32
+
33
+ ### Beaming (`SmoBeamer.applyBeams`)
34
+
35
+ Sizes are the number of notes in each beam group, in order.
36
+
37
+ | Id | Measure | Grouping | Expected beam groups |
38
+ |----|---------|----------|----------------------|
39
+ | M1 | 5/8, five eighths | `[3, 2]` | 3, 2 |
40
+ | M2 | 5/8, five eighths | `[2, 3]` | 2, 3 |
41
+ | M3 | 5/8, five eighths | none | same as before this feature |
42
+ | M4 | 12/8, twelve eighths | `[3]` | 3, 3, 3, 3 |
43
+ | M5 | 8/8, eight eighths | `[3, 3, 2]` | 3, 3, 2 |
44
+ | M6 | 10/8, ten eighths | `[3, 2]` | 3, 2, 3, 2 |
45
+ | M7 | 6/16, six sixteenths | `[3]` | 3, 3 |
46
+ | M8 | 5/8: quarter, eighth, eighth, eighth | `[3, 2]` | 2 (the lone first eighth is not beamed) |
47
+ | M9 | 4/4: dotted eighth, sixteenth, dotted eighth, sixteenth, quarter, quarter | `[4]` | 4 (the two dotted figures beam together across the beat) |
48
+ | M10 | 5/8, five eighths, `end` set on the second note by hand | `[3, 2]` | 2, 2 (the hand `end` closes the first group, the third note is alone before the boundary, the last two beam) |
49
+ | M11 | 5/8, five eighths, hand beam over notes 2 to 4 as `beamSelections` leaves it: note 1 `end`, notes 2 and 3 `continue`, note 4 `end` | `[3, 2]` | 3 (the hand beam is not split at the boundary; notes 1 and 5 are alone) |
50
+ | M15 | 5/8, five eighths, hand beam over the last three notes | `[3, 2]` | 2, 3 |
51
+ | M16 | 5/8, five eighths, hand beam over the first three notes | `[2, 3]` | 3, 2 |
52
+ | M12 | a tuplet in a measure with a grouping | any | the tuplet is beamed as before |
53
+
54
+ ### Operations
55
+
56
+ - `SmoOperation.setBeamGroups(score, selections, [3, 2])` sets the grouping on exactly the measures of the selections and no others. Other staves are unchanged.
57
+ - `SmoOperation.setBeamGroups(score, selections, [])` clears the grouping on those measures.
58
+ - `SmoOperation.setAllBeamGroups(score, groups)` sets or clears it on every measure of every staff.
59
+ - `SmoOperation.beamSelections` on a grouped measure marks every note of the span except the last `continue` (the last is `end`); on an ungrouped measure the result is identical to today.
60
+
61
+ ### Serialization
62
+
63
+ - S1: a score with groupings on measures 2 and 4 serializes, deserializes, and reports the same groupings.
64
+ - S2: a score JSON with no `SmoBeamPreferences` entries loads, every measure reports `[]`, and the beam groups equal those produced by the previous version.
65
+ - S3: the same score through the `.smz` compression round trip keeps the groupings.
66
+
67
+ ## View
68
+
69
+ `SuiScoreViewOperations.setBeamGroups(groups: number[], scope: 'selections' | 'all'): Promise<void>` applies the operation to the displayed score and the stored score as one undo step and waits for the render. Undo restores the previous groupings and beam states.
70
+
71
+ ## UI
72
+
73
+ - The Beams menu has a "Beam Groups" entry that opens the dialog.
74
+ - The dialog has one number field (1 to 4) per group, initialized from the first selected measure, an **Add group** (+) button, a remove button on each group, a Clear button, an Apply To choice ("Selected measures", "Whole score"), and OK/Cancel. Values outside 1 to 4 cannot be entered. No groups means the default for the meter.
@@ -0,0 +1,75 @@
1
+ # Data Model: Per-Measure Beam Groups
2
+
3
+ ## SmoBeamPreferences (new measure modifier)
4
+
5
+ Derives from `SmoMeasureModifierBase`. At most one per measure (a singleton, like the rehearsal mark).
6
+
7
+ | Field | Type | Rules |
8
+ |-------|------|-------|
9
+ | `ctor` | string | `'SmoBeamPreferences'`, set by the base class |
10
+ | `groups` | number[] | Each entry a whole number from 1 to 4. Never empty while the modifier exists. |
11
+
12
+ Static helpers:
13
+
14
+ - `SmoBeamPreferences.maxGroup` = 4, `minGroup` = 1.
15
+ - `SmoBeamPreferences.isValidGroups(values)`: true when every entry is a whole number 1 to 4 (an empty list is valid and means "no grouping").
16
+ - `SmoBeamPreferences.unitTicks(timeSignature)`: 1024 when the lower number of the time signature is 16 or more, otherwise 2048.
17
+
18
+ Serialized form (in the measure's `modifiers` array):
19
+
20
+ ```json
21
+ { "ctor": "SmoBeamPreferences", "groups": [3, 2] }
22
+ ```
23
+
24
+ An empty grouping is not serialized: the modifier is removed from the measure instead.
25
+
26
+ ## SmoMeasure (changed)
27
+
28
+ | Member | Behaviour |
29
+ |--------|-----------|
30
+ | `getBeamGroups(): number[]` | The measure's grouping, or `[]` when it has none. Returns a copy. |
31
+ | `setBeamGroups(groups: number[])` | Replaces the singleton modifier. An empty list removes it. Throws on invalid values. Resets the measure's notes to `beamState` auto (see [research.md](research.md) R5). |
32
+
33
+ Not changed: `beamGroups` (the rendered beam groups), `SmoNote.beamBeats`, `SmoNote.beamState`, `SmoScorePreferences.defaultDupleDuration` and `defaultTripleDuration`.
34
+
35
+ ## Boundary list (derived, not stored)
36
+
37
+ `SmoBeamer.groupBoundaries(measure): number[]` returns tick positions, in order, at which a beam group must end.
38
+
39
+ Given unit `u` (R3), grouping `g` (length `n`), and measure length `L` ticks (from the time signature):
40
+
41
+ ```text
42
+ positions = []; pos = 0; i = 0
43
+ while pos < L:
44
+ pos += g[i % n] * u
45
+ positions.push(min(pos, L))
46
+ i += 1
47
+ ```
48
+
49
+ An empty grouping returns `[]`, which tells the beamer to use the existing logic.
50
+
51
+ Examples (eighth-note unit is 2048 ticks):
52
+
53
+ | Meter | Grouping | Boundaries in eighths |
54
+ |-------|----------|-----------------------|
55
+ | 5/8 | `[3, 2]` | 3, 5 |
56
+ | 12/8 | `[3]` | 3, 6, 9, 12 |
57
+ | 8/8 | `[3, 3, 2]` | 3, 6, 8 |
58
+ | 10/8 | `[3, 2]` | 3, 5, 8, 10 |
59
+ | 7/8 | `[3, 2]` | 3, 5, 7 |
60
+ | 6/16 | `[3]` | 3, 6 (in sixteenths, 1024 ticks each) |
61
+
62
+ ## Beam decision rules (changed in SmoBeamer.beamNote, only when boundaries are non-empty)
63
+
64
+ For each non-tuplet note, with `start` the measure tick position where it begins and `end` the position where it ends:
65
+
66
+ 1. Skip every boundary at or before `start`.
67
+ 2. Add the note to the group (a note that cannot be beamed still closes the group, as now).
68
+ 3. If `end` is at or past the next boundary, close the group, unless the note is marked `continue`. This is the meaning `continue` already has in the beamer: do not break the beam after this note at a beat. Then skip every boundary at or before `end`.
69
+ 4. Skip the legacy checks (the 8192 half-measure rule, the beat-alignment rule and `beamBeats`). An `end` beam state and the last note of the voice still close the group.
70
+
71
+ Notes that are part of a tuplet follow the existing tuplet code. An `end` beam state still closes a group.
72
+
73
+ ## Score-wide preferences (unchanged)
74
+
75
+ `SmoScorePreferences.defaultDupleDuration` / `defaultTripleDuration` remain the fallback for measures with no grouping.
@@ -0,0 +1,84 @@
1
+ # Implementation Plan: Per-Measure Beam Groups
2
+
3
+ **Branch**: `038-per-measure-beam-groups` (work is on `main`; no feature branch was created) | **Date**: 2026-11-08 | **Spec**: [spec.md](spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/038-per-measure-beam-groups/spec.md`
6
+
7
+ ## Summary
8
+
9
+ Add a measure modifier, `SmoBeamPreferences`, that holds a list of 1 to 4 for the measure's beam groups, and teach the beamer to use it. Today the beamer decides where a beam ends from a per-note value (`beamBeats`) that comes from the score-wide duple/triple default. A measure with a non-empty grouping skips that logic: the beamer turns the list into tick positions (the list repeated from its first number, in eighth-note or sixteenth-note units) and ends a beam group at each position. Measures with no grouping keep the existing logic untouched, so old scores beam as before.
10
+
11
+ On top of that sit one model operation (apply a grouping to a set of measures, or clear it), one view method that wraps it in a single undo step, a "Beam Groups" dialog (a Vue dialog like the key signature dialog, with an Apply To choice of selected measures or whole score), and a menu entry in the Beams menu.
12
+
13
+ ## Technical Context
14
+
15
+ **Language/Version**: TypeScript; Vue 3 single-file component for the dialog. Tests run with `ts-node`.
16
+
17
+ **Primary Dependencies**: None new. Reuses `SmoMeasureModifierBase`, `SmoDynamicCtor`, `SmoBeamer`, `SmoSelection`, `InstallDialog`, `dialogContainer.vue`, `select.vue`.
18
+
19
+ **Storage**: The grouping is a measure modifier, saved in the measure's `modifiers` array as `{ ctor: 'SmoBeamPreferences', groups: [3, 2] }`. An empty grouping is not stored, so scores that never use the feature serialize exactly as before. The `.smz` dictionary compression builds its key dictionary from the data, so the new key needs no table entry (checked in research R6).
20
+
21
+ **Testing**: Headless `ts-node` script `tests/beamGroups.ts` (npm script `test:beam-groups`), following `tests/beamDotted.ts` and `tests/createPart.ts`. It covers the boundary calculation, beaming results, serialization round trip and legacy load, and the model operation. The dialog and menu are checked by compilation and the manual steps in [quickstart.md](quickstart.md), as the constitution allows.
22
+
23
+ **Target Platform**: Browser application and library.
24
+
25
+ **Project Type**: Single project.
26
+
27
+ **Performance Goals**: The boundary list is computed once per measure per beaming pass (a handful of additions). No extra DOM measurement and no extra repaint. Applying a grouping re-renders only the changed measures, or the score once for "whole score".
28
+
29
+ **Constraints**: Measures with no grouping must beam exactly as before (FR-002, FR-017). Tuplet beaming is not changed. The smo layer must not import UI code.
30
+
31
+ **Scale/Scope**: One new modifier class, a few measure accessors, one beamer change, two model operations, one view method, one dialog (TypeScript and Vue), one menu entry, 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. The new modifier serializes and deserializes through the existing measure modifier path. A test saves a score with groupings and reloads it, and loads a score JSON written without any grouping and checks the beams are unchanged. An empty grouping is never written. |
40
+ | #2 Editing and transformation logic regression tested | Pass. Boundary calculation (5/8, 6/8, 9/8, 12/8, 8/8, 6/16, 7/8 cut-off repeat), beamed results, the apply/clear operation, and hand-placed beams are headless tests. |
41
+ | #3 Rendering performance | Pass. Changes are in `SmoBeamer`, which already runs per measure at layout. No new DOM reads. The view re-renders only changed measures. |
42
+ | #4 Logical dependencies | Pass. The modifier, the boundary calculation and the operation are in `src/smo` with no UI imports. The dialog only parses text and 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/038-per-measure-beam-groups/
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
+ │ └── beam-groups-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/data/measureModifiers.ts # NEW SmoBeamPreferences (+ params types, validation, unit ticks); registered in measureModifierDynamicCtorInit
67
+ src/smo/data/measure.ts # getBeamGroups(), setBeamGroups() (singleton modifier; empty removes it)
68
+ src/smo/xform/beamers.ts # NEW SmoBeamer.groupBoundaries(); beamNote uses boundaries when the measure has a grouping
69
+ src/smo/xform/operations.ts # NEW setBeamGroups(), setAllBeamGroups(); beamSelections marks interior notes 'continue' in grouped measures
70
+ src/render/sui/scoreViewOperations.ts # NEW setBeamGroups(groups, scope): one undo step, re-render
71
+ src/ui/dialogs/beamGroupsVue.ts # NEW SuiBeamGroupsDialogVue: adapter + creation function
72
+ src/ui/components/dialogs/beamGroups.vue # NEW dialog form: one number field per group, add and remove buttons, Apply To, Clear
73
+ src/ui/menus/beams.ts # NEW "Beam Groups" menu option that opens the dialog
74
+ types/src/... # regenerated declarations for the files above only
75
+ tests/beamGroups.ts # NEW
76
+ package.json # test:beam-groups script
77
+ changes.md # changelog entry
78
+ ```
79
+
80
+ **Structure Decision**: Single-project layout as it exists. The modifier goes with the other measure modifiers in `measureModifiers.ts`, the position logic goes in the beamer where beam decisions already live, and the dialog follows the existing adapter/Vue pattern used by the key signature and tab stave dialogs.
81
+
82
+ ## Complexity Tracking
83
+
84
+ No constitution violations to justify.