smoosic 2.0.2 → 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 (352) hide show
  1. package/build/smoosic.js +546 -125
  2. package/changes.md +85 -0
  3. package/package.json +23 -2
  4. package/release/smoosic.js +549 -128
  5. package/release/styles/menus.css +26 -0
  6. package/specs/022-text-reposition-on-resize/spec.md +1 -0
  7. package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
  8. package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
  9. package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
  10. package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
  11. package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
  12. package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
  13. package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
  14. package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
  15. package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
  16. package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
  17. package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
  18. package/specs/028-unsaved-changes-indicator/plan.md +96 -0
  19. package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
  20. package/specs/028-unsaved-changes-indicator/research.md +68 -0
  21. package/specs/028-unsaved-changes-indicator/spec.md +135 -0
  22. package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
  23. package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
  24. package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
  25. package/specs/029-remove-promise-helpers/data-model.md +45 -0
  26. package/specs/029-remove-promise-helpers/plan.md +86 -0
  27. package/specs/029-remove-promise-helpers/quickstart.md +53 -0
  28. package/specs/029-remove-promise-helpers/research.md +71 -0
  29. package/specs/029-remove-promise-helpers/spec.md +107 -0
  30. package/specs/029-remove-promise-helpers/tasks.md +164 -0
  31. package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
  32. package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
  33. package/specs/030-copy-paste-voices/data-model.md +63 -0
  34. package/specs/030-copy-paste-voices/plan.md +80 -0
  35. package/specs/030-copy-paste-voices/quickstart.md +50 -0
  36. package/specs/030-copy-paste-voices/research.md +80 -0
  37. package/specs/030-copy-paste-voices/spec.md +124 -0
  38. package/specs/030-copy-paste-voices/tasks.md +183 -0
  39. package/specs/031-select-voice/checklists/requirements.md +39 -0
  40. package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
  41. package/specs/031-select-voice/data-model.md +47 -0
  42. package/specs/031-select-voice/plan.md +79 -0
  43. package/specs/031-select-voice/quickstart.md +43 -0
  44. package/specs/031-select-voice/research.md +55 -0
  45. package/specs/031-select-voice/spec.md +113 -0
  46. package/specs/031-select-voice/tasks.md +171 -0
  47. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  48. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  49. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  50. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  51. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  52. package/specs/032-split-multimeasure-rests/research.md +63 -0
  53. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  54. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  55. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  56. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  57. package/specs/033-key-distance-transposition/data-model.md +49 -0
  58. package/specs/033-key-distance-transposition/plan.md +87 -0
  59. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  60. package/specs/033-key-distance-transposition/research.md +82 -0
  61. package/specs/033-key-distance-transposition/spec.md +132 -0
  62. package/specs/033-key-distance-transposition/tasks.md +139 -0
  63. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  64. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  65. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  66. package/specs/034-smz-compressed-scores/plan.md +89 -0
  67. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  68. package/specs/034-smz-compressed-scores/research.md +86 -0
  69. package/specs/034-smz-compressed-scores/spec.md +137 -0
  70. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  71. package/specs/035-paste-special/checklists/requirements.md +35 -0
  72. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  73. package/specs/035-paste-special/data-model.md +47 -0
  74. package/specs/035-paste-special/plan.md +83 -0
  75. package/specs/035-paste-special/quickstart.md +51 -0
  76. package/specs/035-paste-special/research.md +97 -0
  77. package/specs/035-paste-special/spec.md +170 -0
  78. package/specs/035-paste-special/tasks.md +149 -0
  79. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  80. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  81. package/specs/036-autosave-recovery/data-model.md +70 -0
  82. package/specs/036-autosave-recovery/plan.md +87 -0
  83. package/specs/036-autosave-recovery/quickstart.md +65 -0
  84. package/specs/036-autosave-recovery/research.md +105 -0
  85. package/specs/036-autosave-recovery/spec.md +143 -0
  86. package/specs/036-autosave-recovery/tasks.md +165 -0
  87. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  88. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  89. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  90. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  91. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  92. package/specs/037-fix-new-part-dialog/research.md +86 -0
  93. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  94. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  95. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  96. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  97. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  98. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  99. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  100. package/specs/038-per-measure-beam-groups/research.md +72 -0
  101. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  102. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  103. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  104. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  105. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  106. package/specs/039-measure-fill-submenu/plan.md +81 -0
  107. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  108. package/specs/039-measure-fill-submenu/research.md +68 -0
  109. package/specs/039-measure-fill-submenu/spec.md +153 -0
  110. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  111. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  112. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  113. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  114. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  115. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  116. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  117. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  118. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  119. package/specs/041-delete-special/checklists/requirements.md +35 -0
  120. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  121. package/specs/041-delete-special/data-model.md +40 -0
  122. package/specs/041-delete-special/plan.md +93 -0
  123. package/specs/041-delete-special/quickstart.md +41 -0
  124. package/specs/041-delete-special/research.md +75 -0
  125. package/specs/041-delete-special/spec.md +136 -0
  126. package/specs/041-delete-special/tasks.md +106 -0
  127. package/src/application/application.ts +475 -459
  128. package/src/application/exports.ts +401 -395
  129. package/src/application/generateVexTests.ts +2 -2
  130. package/src/common/promiseHelpers.ts +2 -2
  131. package/src/render/audio/samples.ts +117 -118
  132. package/src/render/sui/NoteEntryCaret.ts +117 -16
  133. package/src/render/sui/autosave.ts +265 -0
  134. package/src/render/sui/formatter.ts +12 -2
  135. package/src/render/sui/pageDivisions.ts +58 -0
  136. package/src/render/sui/renderState.ts +469 -464
  137. package/src/render/sui/scoreChangeState.ts +67 -0
  138. package/src/render/sui/scoreView.ts +77 -2
  139. package/src/render/sui/scoreViewOperations.ts +363 -37
  140. package/src/render/sui/staffLineGeometry.ts +82 -0
  141. package/src/render/sui/svgPageMap.ts +16 -17
  142. package/src/render/sui/textEdit.ts +310 -311
  143. package/src/render/sui/tracker.ts +40 -0
  144. package/src/render/vex/vxMeasure.ts +22 -8
  145. package/src/render/vex/vxNote.ts +5 -5
  146. package/src/smo/data/measure.ts +58 -1
  147. package/src/smo/data/measureModifiers.ts +81 -1
  148. package/src/smo/data/music.ts +169 -359
  149. package/src/smo/data/note.ts +1 -1
  150. package/src/smo/data/noteModifiers.ts +12 -0
  151. package/src/smo/data/score.ts +167 -2
  152. package/src/smo/data/scoreModifiers.ts +46 -1
  153. package/src/smo/data/systemStaff.ts +43 -0
  154. package/src/smo/xform/beamers.ts +80 -6
  155. package/src/smo/xform/copypaste.ts +511 -51
  156. package/src/smo/xform/measureFill.ts +89 -0
  157. package/src/smo/xform/operations.ts +403 -61
  158. package/src/smo/xform/selections.ts +75 -0
  159. package/src/smo/xform/undo.ts +9 -0
  160. package/src/styles/menus.css +26 -0
  161. package/src/ui/buttons/ribbon.ts +3 -1
  162. package/src/ui/components/buttons/sidebar.vue +15 -6
  163. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  164. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  165. package/src/ui/components/dialogs/dynamics.vue +16 -3
  166. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  167. package/src/ui/components/dialogs/hairpin.vue +3 -3
  168. package/src/ui/components/dialogs/library.vue +3 -1
  169. package/src/ui/components/dialogs/newPart.vue +148 -184
  170. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  171. package/src/ui/components/dialogs/recovery.vue +66 -0
  172. package/src/ui/components/dialogs/save.vue +11 -4
  173. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  174. package/src/ui/components/dialogs/slur.vue +6 -6
  175. package/src/ui/components/dialogs/tempo.vue +11 -3
  176. package/src/ui/components/dialogs/timeSignature.vue +5 -0
  177. package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
  178. package/src/ui/components/dialogs/volta.vue +3 -3
  179. package/src/ui/dialogs/adapter.ts +181 -183
  180. package/src/ui/dialogs/addMeasure.ts +97 -97
  181. package/src/ui/dialogs/annotationVue.ts +56 -56
  182. package/src/ui/dialogs/audioSettings.ts +121 -123
  183. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  184. package/src/ui/dialogs/chordChangeVue.ts +46 -46
  185. package/src/ui/dialogs/clefChange.ts +53 -53
  186. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  187. package/src/ui/dialogs/customTuplets.ts +95 -96
  188. package/src/ui/dialogs/customTupletsVue.ts +47 -47
  189. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  190. package/src/ui/dialogs/dialog.ts +627 -620
  191. package/src/ui/dialogs/durations.ts +34 -34
  192. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  193. package/src/ui/dialogs/factory.ts +196 -198
  194. package/src/ui/dialogs/fileDialogs.ts +286 -179
  195. package/src/ui/dialogs/fonts.ts +93 -93
  196. package/src/ui/dialogs/globalLayout.ts +40 -40
  197. package/src/ui/dialogs/gracenote.ts +31 -31
  198. package/src/ui/dialogs/hairpin.ts +108 -110
  199. package/src/ui/dialogs/hairpinVue.ts +51 -51
  200. package/src/ui/dialogs/instrument.ts +119 -112
  201. package/src/ui/dialogs/keySignature.ts +175 -176
  202. package/src/ui/dialogs/keySignatureVue.ts +47 -47
  203. package/src/ui/dialogs/library.ts +207 -207
  204. package/src/ui/dialogs/libraryVue.ts +62 -48
  205. package/src/ui/dialogs/lyricVue.ts +46 -46
  206. package/src/ui/dialogs/measureFormat.ts +78 -78
  207. package/src/ui/dialogs/microtones.ts +147 -147
  208. package/src/ui/dialogs/noteHead.ts +319 -319
  209. package/src/ui/dialogs/pageLayout.ts +61 -61
  210. package/src/ui/dialogs/partInfo.ts +60 -60
  211. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  212. package/src/ui/dialogs/pedalMarking.ts +117 -117
  213. package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
  214. package/src/ui/dialogs/pitch.ts +352 -352
  215. package/src/ui/dialogs/preferences.ts +1 -0
  216. package/src/ui/dialogs/recovery.ts +49 -0
  217. package/src/ui/dialogs/rehearsalMark.ts +64 -64
  218. package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
  219. package/src/ui/dialogs/scoreId.ts +35 -36
  220. package/src/ui/dialogs/scoreView.ts +42 -42
  221. package/src/ui/dialogs/slur.ts +308 -310
  222. package/src/ui/dialogs/slurVue.ts +91 -91
  223. package/src/ui/dialogs/staffGroup.ts +112 -112
  224. package/src/ui/dialogs/tabNote.ts +84 -84
  225. package/src/ui/dialogs/tabStave.ts +182 -182
  226. package/src/ui/dialogs/tempo.ts +261 -263
  227. package/src/ui/dialogs/tempoVue.ts +73 -73
  228. package/src/ui/dialogs/textBlockVue.ts +127 -127
  229. package/src/ui/dialogs/textBracket.ts +114 -116
  230. package/src/ui/dialogs/textBracketVue.ts +56 -56
  231. package/src/ui/dialogs/tie.ts +140 -142
  232. package/src/ui/dialogs/timeSignature.ts +65 -66
  233. package/src/ui/dialogs/transposeScore.ts +39 -39
  234. package/src/ui/dialogs/unsavedChanges.ts +43 -0
  235. package/src/ui/dialogs/volta.ts +120 -122
  236. package/src/ui/dialogs/voltaVue.ts +51 -51
  237. package/src/ui/fileio/fileInput.ts +12 -3
  238. package/src/ui/fileio/library.ts +110 -111
  239. package/src/ui/fileio/scoreArchive.ts +151 -0
  240. package/src/ui/fileio/xhrLoader.ts +26 -0
  241. package/src/ui/i18n/language.ts +1 -1
  242. package/src/ui/menus/beams.ts +181 -112
  243. package/src/ui/menus/edit.ts +143 -6
  244. package/src/ui/menus/file.ts +40 -4
  245. package/src/ui/menus/measure.ts +40 -1
  246. package/tests/autosave.ts +332 -0
  247. package/tests/beamDotted.ts +56 -0
  248. package/tests/beamGroups.ts +338 -0
  249. package/tests/createPart.ts +292 -0
  250. package/tests/deleteSpecial.ts +350 -0
  251. package/tests/dynamicsFontSize.ts +132 -0
  252. package/tests/keyDistanceTransposition.ts +351 -0
  253. package/tests/measureFill.ts +295 -0
  254. package/tests/movePart.ts +94 -0
  255. package/tests/multimeasureRest.ts +338 -0
  256. package/tests/pageDivisions.ts +156 -0
  257. package/tests/pasteIntoMeasure.ts +103 -0
  258. package/tests/pasteSpecial.ts +541 -0
  259. package/tests/promiseHelpersUsage.ts +142 -0
  260. package/tests/quickBeam.ts +126 -0
  261. package/tests/scoreArchive.ts +218 -0
  262. package/tests/scoreChangeState.ts +104 -0
  263. package/tests/selectVoice.ts +189 -0
  264. package/tests/staffLineGeometry.ts +179 -0
  265. package/tests/timeSignatureDisplay.ts +58 -0
  266. package/tests/voiceCopyPaste.ts +417 -0
  267. package/tools/smoosic-schema.json +37 -0
  268. package/typedoc.ts +1 -1
  269. package/types/src/application/exports.d.ts +453 -447
  270. package/types/src/common/promiseHelpers.d.ts +30 -30
  271. package/types/src/common/vex.d.ts +224 -224
  272. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  273. package/types/src/render/sui/autosave.d.ts +99 -0
  274. package/types/src/render/sui/scoreView.d.ts +23 -0
  275. package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
  276. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  277. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  278. package/types/src/render/sui/textEdit.d.ts +96 -96
  279. package/types/src/render/sui/textRender.d.ts +199 -199
  280. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  281. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  282. package/types/src/render/vex/vxNote.d.ts +56 -56
  283. package/types/src/render/vex/vxSystem.d.ts +71 -71
  284. package/types/src/smo/data/measure.d.ts +30 -0
  285. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  286. package/types/src/smo/data/music.d.ts +74 -32
  287. package/types/src/smo/data/note.d.ts +498 -498
  288. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  289. package/types/src/smo/data/score.d.ts +476 -421
  290. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  291. package/types/src/smo/data/scoreText.d.ts +334 -334
  292. package/types/src/smo/data/systemStaff.d.ts +14 -0
  293. package/types/src/smo/xform/beamers.d.ts +23 -1
  294. package/types/src/smo/xform/copypaste.d.ts +138 -2
  295. package/types/src/smo/xform/measureFill.d.ts +21 -0
  296. package/types/src/smo/xform/operations.d.ts +245 -129
  297. package/types/src/smo/xform/selections.d.ts +154 -154
  298. package/types/src/smo/xform/undo.d.ts +142 -142
  299. package/types/src/ui/buttons/button.d.ts +100 -100
  300. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  301. package/types/src/ui/common.d.ts +76 -76
  302. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  303. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  304. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  305. package/types/src/ui/composable/draggable.d.ts +15 -15
  306. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  307. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  308. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  309. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  310. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  311. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  312. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  313. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  314. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  315. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  316. package/types/src/ui/dialogs/factory.d.ts +15 -15
  317. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  318. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  319. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  320. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  321. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  322. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  323. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  324. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  325. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  326. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  327. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  328. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  329. package/types/src/ui/dialogs/slur.d.ts +57 -57
  330. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  331. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  332. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  333. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  334. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  335. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  336. package/types/src/ui/dialogs/tie.d.ts +41 -41
  337. package/types/src/ui/dialogs/volta.d.ts +40 -40
  338. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  339. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  340. package/types/src/ui/fileio/library.d.ts +40 -40
  341. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  342. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  343. package/types/src/ui/menus/file.d.ts +8 -8
  344. package/types/src/ui/menus/language.d.ts +7 -7
  345. package/types/src/ui/menus/manager.d.ts +58 -58
  346. package/types/src/ui/menus/menu.d.ts +159 -159
  347. package/types/src/ui/menus/partSelection.d.ts +14 -14
  348. package/types/src/ui/menus/score.d.ts +8 -8
  349. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  350. package/types/typedoc.d.ts +147 -147
  351. package/src/ui/dialogs/dynamics.ts +0 -143
  352. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -0,0 +1,51 @@
1
+ # Quickstart: Validating Paste Special
2
+
3
+ ## Prerequisites
4
+
5
+ - `npm install` done at the repository root.
6
+ - For the manual checks, a built application or the development page you normally use.
7
+
8
+ ## Automated check
9
+
10
+ ```bash
11
+ npm run test:paste-special
12
+ ```
13
+
14
+ Expected: every line prints `PASS`, exit code 0. See [contracts/paste-special-api.md](contracts/paste-special-api.md) for the invariants and [data-model.md](data-model.md) for the shapes.
15
+
16
+ | # | Scenario | Expected |
17
+ |---|----------|----------|
18
+ | 1 | Each kind alone (six runs), same rhythm | Only that kind arrives on the destination; others untouched |
19
+ | 2 | All six ticked | All arrive |
20
+ | 3 | Pitches, durations, note types before and after | Identical |
21
+ | 4 | Replace over existing articulations; copied note has none | Destination left with none |
22
+ | 5 | Add over existing articulations | Destination keeps its own and gains the copied ones |
23
+ | 6 | Add: dynamic over existing dynamic; same-verse lyric over same-verse lyric | Pasted one wins, never two |
24
+ | 7 | 4 quarters (lyrics 1-4) onto 8 eighths | Lyrics land on eighths 1, 3, 5, 7; 2, 4, 6, 8 unchanged |
25
+ | 8 | 2 quarters onto whole notes in two measures | First to measure 1's note, second to measure 2's note |
26
+ | 9 | 4 copied quarters onto half, quarter, quarter | Pairing is destination notes 1, 2, 2, 3 (by position); the 2nd quarter gets copied notes 2 and 3 together; later dynamic and same-verse lyric win |
27
+ | 10 | Copy longer than the destination part | Stops at the end, no error, no notes added |
28
+ | 11 | Rests in the copy and in the destination | Aligned by length like notes |
29
+ | 12 | 2-measure copy onto 2 following measures | Aligned across the barline |
30
+ | 13 | 2-staff copy | Staves pair in order; a missing second staff ends the paste |
31
+ | 14 | Chords C, F, G, Am onto a staff transposed up a whole step; and onto a concert-pitch staff in another key | D, G, A, Bm; and unchanged. Lyrics, annotations and the rest identical on both |
32
+ | 15 | Dry-run extent vs the measures actually edited | Equal, including case 8 |
33
+ | 16 | Edit a pasted marking afterwards | The copied marking is unchanged |
34
+ | 17 | Serialize and deserialize the pasted score | Markings survive |
35
+ | 18 | `removeAllAnnotations` on a note with lyrics, chords and annotations | Only annotations removed |
36
+
37
+ ## Manual check in the application
38
+
39
+ 1. Put a dynamic, a lyric and an articulation on the notes of staff 1; give staff 2 different pitches.
40
+ 2. Select staff 1's measures and Copy. Select staff 2's first note.
41
+ 3. Open the Edit menu: **Paste Special...** is listed and **Paste Chords** is not. With nothing copied (fresh page), Paste Special is not listed.
42
+ 4. Choose Paste Special. Confirm is disabled. Turn on **Dynamics** only; confirm is enabled. Confirm. Staff 2 shows staff 1's dynamics and nothing else changed.
43
+ 5. Undo once: staff 2 is as before.
44
+ 6. Repeat with **Replace existing** off and staff 2 already holding its own dynamics: it keeps and gains.
45
+ 7. Paste lyrics from a quarter-note line onto an eighth-note line: they land on every other note.
46
+ 8. Paste chords onto a transposing instrument's part (for example a B-flat clarinet): names are spelled for it. Onto a concert-pitch part in another key they are unchanged.
47
+ 9. Cancel the dialog: nothing changes.
48
+
49
+ ## Regression
50
+
51
+ Run the other `test:*` scripts in `package.json` to confirm nothing else changed.
@@ -0,0 +1,97 @@
1
+ # Research: Paste Special
2
+
3
+ No NEEDS CLARIFICATION remained in the Technical Context. Findings come from reading the code.
4
+
5
+ ## R1. The existing alignment, exactly
6
+
7
+ **Finding**: `PasteBuffer.pasteChordNotes` ([copypaste.ts](../../src/smo/xform/copypaste.ts)) walks the copied notes and the destination notes with two running totals of *elapsed time* (it calls them `srcTick` and `destTick`; they are sums of `note.tickCount`, which is a duration):
8
+
9
+ ```text
10
+ destNote = note at the cursor
11
+ for each copied note n (in order):
12
+ apply n's chords to destNote
13
+ srcElapsed += n.tickCount
14
+ while destElapsed < srcElapsed and destNote exists:
15
+ destElapsed += destNote.tickCount
16
+ destNote = next note in the same voice (crossing measures)
17
+ ```
18
+
19
+ Stated as a rule, which is what the spec adopts: copied note *k* starts at `T_k` (the total length of the copied notes before it) and goes to the first destination note, counting from the cursor, whose start time is at or after `T_k`. Because the destination only moves forward, a destination note that starts after several copied notes can receive all of them, and destination notes in between receive nothing. Hand-traced cases (each is a test):
20
+
21
+ | Copy | Destination | Result |
22
+ |------|-------------|--------|
23
+ | 4 quarters | 8 eighths | copied notes go to eighths 1, 3, 5, 7 |
24
+ | 2 quarters | 1 whole + 1 whole | the first goes to the first whole; the second starts 1 quarter in and the first destination note starting at or after that is the second whole (next measure) |
25
+ | 4 quarters | half, quarter, quarter | pairing is destination notes 0, 1, 1, 2: the second and third copied notes both go to the first quarter, because it starts at or after both of their start times |
26
+ | same rhythm | same rhythm | one to one |
27
+
28
+ The second row shows a consequence the old code shares: a paste can reach a measure beyond the span of the copied duration.
29
+
30
+ **Decision**: Keep this algorithm for every kind (the user confirmed, 2026-10-31). Extract it into one routine, `alignAttributeNotes`, that returns `{ copied, destination }` pairs and touches nothing.
31
+
32
+ **Terminology note** (raised by the user): `SmoSelector.tick` is the *index* of a note within its voice, while `tickCount` and these running totals are *durations*. The new code names the totals `copiedElapsed` and `destinationElapsed`, and the index is always called `noteIndex` or "the selector's tick" in comments.
33
+
34
+ ## R2. Where each kind of marking is stored
35
+
36
+ | Kind | Stored in | Add (replaces on key match) | Clear all of the kind |
37
+ |------|-----------|----------------------------|----------------------|
38
+ | Dynamics | `note.textModifiers`, type `SmoDynamicText` | `addDynamic` (replaces any dynamic) | filter out type `SmoDynamicText` |
39
+ | Lyrics | `note.textModifiers`, `SmoLyric` with parser `lyric` | `addLyric` (replaces same parser and verse) | filter out `SmoLyric` with parser `lyric` |
40
+ | Annotations | `textModifiers`, `SmoLyric` with parser `annotation` | `addAnnotation` (same parser and verse) | filter out parser `annotation` |
41
+ | Chords | `textModifiers`, `SmoLyric` with parser `chord` | `addLyric` (same parser and verse) | filter out parser `chord` |
42
+ | Articulations | `note.articulations` | `setArticulation(a, true)` (replaces the same articulation) | `clearArticulations()` |
43
+ | Ornaments | `note.ornaments` | `setOrnament(o, true)` (replaces the same ornament) | assign `[]` |
44
+
45
+ **Decision**: Add mode is "call the add method for each copied item". Replace mode is "clear the ticked kind on the destination note first, then do the same". The add methods already give the spec's rule that a single-valued marking (dynamic, same-verse lyric) is superseded rather than doubled, so no extra logic is needed.
46
+
47
+ **Alternatives considered**: Compare and merge items by value (more code, and the add methods already define identity); copy `textModifiers` arrays wholesale (would paste kinds the user did not tick).
48
+
49
+ ## R3. Copies must be independent
50
+
51
+ **Finding**: A modifier's constructor gives it a fresh `attrs.id`, and `SmoNoteModifierBase.deserialize(modifier.serialize())` produces a new object with its own state. This is how `SmoNote.clone` works.
52
+
53
+ **Decision**: Clone each pasted item with `SmoNoteModifierBase.deserialize(item.serialize())` so later edits to the pasted marking never affect the source (FR-014).
54
+
55
+ ## R4. Chords
56
+
57
+ **Decision**: Chords go through `SmoLyric.transposeChordToKey(chord, destMeasure.transposeIndex, copiedNote.originalKey, destMeasure.keySignature)`, as the old Paste Chords did. That function already returns a new `SmoLyric`, so it needs no extra clone. (It was reworked for key-distance spelling in feature 033; the behavior needed here is unchanged.)
58
+
59
+ ## R5. Which measures a paste touches (undo and refresh)
60
+
61
+ **Finding**: `pasteChords` and `paste` compute the measure range to undo and re-render from `getPasteMeasureList()`, which is based on the copied duration. By R1, a paste can reach past that span (a short copy onto long destination notes), so the old range can miss a changed measure.
62
+
63
+ **Decision**: Before changing anything, run the alignment for each staff as a dry run and take the lowest and highest destination measure over all pairs. The view undoes and re-renders exactly that range. Both runs use the same routine, so they cannot disagree. Undo is the existing grouped `_undoColumn('paste', i)` over the range, giving one undo step (FR-012).
64
+
65
+ ## R6. Multi-staff copies
66
+
67
+ **Finding**: `pasteIntoScore` already walks the copied staves, keeps them in a rectangle, and calls a function once per staff with the destination selector advanced by one staff.
68
+
69
+ **Decision**: Reuse it for both the dry run and the apply, passing a function that does the work for one staff and returns the notes unchanged.
70
+
71
+ ## R7. Removing Paste Chords
72
+
73
+ **Finding**: `SuiViewOperations.pasteChords`, `PasteBuffer.pasteChords` and `PasteBuffer.pasteChordNotes` are used only by the Edit menu entry. `PasteBuffer` is part of the exported library surface.
74
+
75
+ **Decision**: Remove all three and the menu entry (FR-001). Library users who called `pasteChords` need the new `pasteAttributes` with `kinds: ['chords']`; note this in the changelog. Behavior differs slightly in Replace mode: the old command left a destination note's chords alone when the copied note had none.
76
+
77
+ ## R8. The dialog
78
+
79
+ **Finding**: Recent dialogs follow one pattern: a TypeScript function installs a Vue component with `InstallDialog`, the component wraps its content in `dialogContainer.vue` (which takes an `enable` prop for the confirm button), and boolean options use `toggle.vue`. `addMeasure.ts` is the closest example, and menus open dialogs by passing the menu's `view`, `tracker`, `eventSource`, `completeNotifier` and `startPromise` (see `file.ts`).
80
+
81
+ **Decision**: New `SuiPasteSpecialDialog` in `src/ui/dialogs/pasteSpecial.ts` and `pasteSpecial.vue`: six toggles, one "Replace existing" toggle (on by default, off means add), and confirm disabled until a kind is ticked. The dialog collects `{ kinds, mode }` and calls `view.pasteAttributes`.
82
+
83
+ **Alternatives considered**: Checkboxes (the code base has just moved away from checkboxes to toggles, spec 003); a separate menu entry per kind (the request asks for one dialog).
84
+
85
+ ## R9. Menu availability
86
+
87
+ **Decision**: The Edit menu entry shows only when something has been copied. `PasteBuffer.hasNotes()` and `SuiViewOperations.hasCopiedNotes()` answer that, using the same `display` hook the voice entries use (FR-013).
88
+
89
+ ## R10. A latent defect found on the way
90
+
91
+ **Finding**: `SmoNote.removeAllAnnotations` keeps a modifier only if `type !== 'SmoLyric' && parser !== annotation`, which drops every lyric, chord and annotation, not just annotations. It has no callers today.
92
+
93
+ **Decision**: Fix it (keep everything except `SmoLyric` annotations) as a small task, so a future caller, or this feature's Replace code if it reuses it, does not erase lyrics and chords. The new code uses its own per-kind filters (R2) and does not depend on it.
94
+
95
+ ## R11. Tests
96
+
97
+ **Decision**: `tests/pasteSpecial.ts` builds a small score with two staves, puts distinctive markings of all six kinds on the first staff and different ones on the second, copies with `PasteBuffer.setSelections`, and calls `pasteAttributes`. It checks each kind alone, replace vs add, same and different rhythms (including the 4-quarters-onto-8-eighths case and the long-destination-note case), running off the end of the part, rests, a two-measure copy, a two-staff copy, chords transposed between keys, unticked kinds untouched, pitches and durations unchanged, independence of the copies, the dry-run range, and a serialization round trip.
@@ -0,0 +1,170 @@
1
+ # Feature Specification: Paste Special for Note Attachments
2
+
3
+ **Feature Branch**: `035-paste-special`
4
+
5
+ **Created**: 2026-10-31
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "make it easier to cut/paste things attached to notes. Currently in the UI edit menu there is a 'Paste Chords' that lets you paste chord changes from one part to another, without affecting notes. We should generalize this so that you can go 'Paste Special' and it will bring up a dialog with some checkboxes of things to paste. Included in this should be: dynamics, lyrics, annotations, chords, articulations, ornaments. This will allow you to paste to a different part or different part of the score, replacing or adding the specific attribute but not changing the chords or pitches. The paste is done by counting notes, not their values. For things other than chords, there is no need to transpose or change them in any other way."
10
+
11
+ ## Clarifications
12
+
13
+ ### Session 2026-10-31
14
+
15
+ - Q: The request says the paste counts notes, not their values. The existing Paste Chords actually lines notes up by adding up their lengths (elapsed time). Which should Paste Special use? -> A: Keep the existing behavior for all the markings: line up by elapsed time, exactly as Paste Chords does today. (The earlier "count notes" wording in the request came from reading the existing code differently.)
16
+
17
+ ## User Scenarios & Testing *(mandatory)*
18
+
19
+ ### User Story 1 - Paste only chosen kinds of markings onto existing notes (Priority: P1)
20
+
21
+ An arranger has lyrics, dynamics and articulations written on one part and wants the same markings on another part (or on another passage of the same part) without retyping them and without touching the music already there. They copy the passage, place the cursor on the first note of the destination, and choose **Paste Special** from the Edit menu. A dialog lists the kinds of markings that can be pasted: dynamics, lyrics, annotations, chords, articulations and ornaments, each with a checkbox. They tick the ones they want and confirm. Only those kinds of markings are copied onto the destination notes. The destination's pitches and rhythms are not changed, and neither are any kinds of marking left unticked.
22
+
23
+ **Why this priority**: This is the whole point of the feature: moving markings between parts and passages quickly, which today takes retyping or only works for chords.
24
+
25
+ **Independent Test**: In a score with two staves, put a dynamic, a lyric and an articulation on the notes of staff 1, give staff 2 different pitches, copy staff 1's measures, put the cursor on staff 2's first note, open Paste Special, tick only Dynamics, and confirm. Staff 2 gains staff 1's dynamics; its pitches, rhythms, lyrics and articulations are exactly as before.
26
+
27
+ **Acceptance Scenarios**:
28
+
29
+ 1. **Given** a copied passage and a destination cursor, **When** the user chooses Paste Special, **Then** a dialog appears with checkboxes for dynamics, lyrics, annotations, chords, articulations and ornaments.
30
+ 2. **Given** the dialog is open, **When** the user ticks one or more kinds and confirms, **Then** only those kinds of markings are applied to the destination notes.
31
+ 3. **Given** a Paste Special has been applied, **When** the destination is inspected, **Then** every pitch, duration, rest, tie, slur, beam and tuplet is unchanged from before the paste.
32
+ 4. **Given** the dialog is open and no checkbox is ticked, **Then** the confirm button is unavailable, so an empty paste cannot be performed by mistake.
33
+ 5. **Given** the user cancels the dialog, **Then** the score is unchanged.
34
+
35
+ ---
36
+
37
+ ### User Story 2 - Choose to replace or add to what is already there (Priority: P1)
38
+
39
+ The destination notes may already have some of the same kind of marking. The dialog lets the user decide whether the pasted markings **replace** the existing ones of the chosen kinds, or are **added** to them. With replace, the destination's markings of each ticked kind end up matching the copied ones, including being cleared where the copied note has none. With add, the destination keeps what it has and gains the copied ones.
40
+
41
+ **Why this priority**: Without this choice the feature either destroys work the user wanted to keep or leaves old markings behind. The request calls for both behaviors.
42
+
43
+ **Independent Test**: Give destination notes their own lyrics. Paste Special lyrics from a source in replace mode: the destination lyrics become the source's. Undo, then paste in add mode: the destination keeps its lyrics and also shows the source's.
44
+
45
+ **Acceptance Scenarios**:
46
+
47
+ 1. **Given** destination notes with their own articulations, **When** the user pastes articulations in replace mode, **Then** each destination note has exactly the articulations of the corresponding copied note, and a note whose copied counterpart has none ends up with none.
48
+ 2. **Given** the same destination, **When** the user pastes articulations in add mode, **Then** each destination note keeps its articulations and also has those of the corresponding copied note.
49
+ 3. **Given** replace mode with several kinds ticked, **When** the paste is applied, **Then** each ticked kind is replaced and each unticked kind is left alone.
50
+ 4. **Given** a kind where a note can hold only one (a dynamic, or a lyric for a given verse), **When** the pasted one meets an existing one in add mode, **Then** the pasted one takes its place, so the note never ends up with two.
51
+
52
+ ---
53
+
54
+ ### User Story 3 - Markings land where the music lines up in time (Priority: P1)
55
+
56
+ The source and destination often have different rhythms: a vocal line in quarter notes and a piano part in eighths, or a part with a long note where another has several. The paste lines the copied passage up with the destination the same way Paste Chords does today, by elapsed time: it adds up the lengths of the copied notes to find when each copied note starts, measured from the beginning of the copied passage. The markings of each copied note go to the first destination note, counting from the cursor, that starts at or after that moment. Time runs on across barlines, so a copy of several measures keeps lining up in the destination's following measures. When the two parts have the same rhythm, this is simply one note to one note.
57
+
58
+ **Why this priority**: It decides which notes receive the markings, so every paste depends on it. Keeping the existing alignment means users who already use Paste Chords see no surprise.
59
+
60
+ **Independent Test**: Copy four quarter notes with lyrics "one two three four". Put the cursor on the first of eight eighth notes and Paste Special lyrics. The 1st, 3rd, 5th and 7th eighth notes get "one", "two", "three" and "four"; the other four eighth notes are unchanged.
61
+
62
+ **Acceptance Scenarios**:
63
+
64
+ 1. **Given** a copy and a destination with the same rhythm, **When** markings are pasted, **Then** each destination note gets the markings of the copied note in the same position.
65
+ 2. **Given** four copied quarter notes and a destination of eighth notes, **When** markings are pasted, **Then** they land on every second destination note and the notes in between are not changed.
66
+ 3. **Given** a copied passage that spans several measures, **When** the paste crosses barlines in the destination, **Then** the alignment continues by elapsed time in the following measures.
67
+ 4. **Given** four copied quarter notes and a destination of a half note followed by two quarter notes, **When** markings are pasted, **Then** the first copied note goes to the half note, the second and third both go to the first quarter note (their markings are combined, see FR-009 for single-valued kinds), and the fourth goes to the last quarter note.
68
+ 5. **Given** the copied passage is longer than the rest of the destination part, **When** the paste reaches the end of the part, **Then** it stops there and the remaining copied markings are ignored; nothing is added past the end of the part.
69
+ 6. **Given** the copied passage is shorter than the destination, **Then** the destination notes after the last matched note are not changed.
70
+ 7. **Given** rests in the source or destination, **Then** a rest is aligned by its length like any other note.
71
+
72
+ ---
73
+
74
+ ### User Story 4 - Chords follow the destination's key; everything else is copied as is (Priority: P2)
75
+
76
+ Chord symbols pasted onto a transposing instrument (for example a B-flat clarinet part) are spelled for that instrument, as Paste Chords does today. A part in concert pitch keeps the chord names as they are, even when its key signature differs. All other kinds (dynamics, lyrics, annotations, articulations, ornaments) are copied exactly as they are, without any transposing or other change.
77
+
78
+ **Why this priority**: It preserves the behavior users already rely on for chords while keeping the rest simple, but it matters less than the paste itself working.
79
+
80
+ **Independent Test**: Copy a passage with chord symbols C, F, G, Am and paste Special chords onto a staff for an instrument written a whole step higher; the chords become D, G, A, Bm. Paste annotations and lyrics from the same source onto the same staff; the text is identical.
81
+
82
+ **Acceptance Scenarios**:
83
+
84
+ 1. **Given** chords copied from a concert-pitch passage, **When** pasted onto a transposing instrument's part, **Then** the chord names are transposed for that instrument.
85
+ 2. **Given** the same chords, **When** pasted onto a concert-pitch part whose key signature is different, **Then** the chord names are not changed.
86
+ 3. **Given** lyrics, annotations, dynamics, articulations or ornaments, **When** pasted onto a part in a different key or transposition, **Then** they are unchanged.
87
+ 4. **Given** the same source pasted twice with different tick choices, **Then** the second paste does not disturb markings applied by the first unless it covers the same kinds.
88
+
89
+ ---
90
+
91
+ ### User Story 5 - One undo step, and the old command is folded in (Priority: P3)
92
+
93
+ A Paste Special can be undone in one step. The separate **Paste Chords** command is replaced by Paste Special, in which chords is one of the checkboxes, so there is one place to go for this kind of paste.
94
+
95
+ **Why this priority**: Undo safety and a tidy menu are important to trust and discoverability but do not add new capability.
96
+
97
+ **Independent Test**: Apply a Paste Special with several kinds ticked; one Undo restores the score exactly. Open the Edit menu: Paste Special is there and Paste Chords is not.
98
+
99
+ **Acceptance Scenarios**:
100
+
101
+ 1. **Given** a completed Paste Special, **When** the user chooses Undo once, **Then** the score is exactly as it was before.
102
+ 2. **Given** the Edit menu, **Then** it offers Paste Special and no longer offers Paste Chords.
103
+ 3. **Given** nothing has been copied, **When** the user looks at Paste Special, **Then** it is unavailable (or says there is nothing to paste) and no dialog changes the score.
104
+
105
+ ---
106
+
107
+ ### Edge Cases
108
+
109
+ - The destination cursor is on a note near the end of the part: the paste applies as far as the part goes and stops, without error.
110
+ - Several copied notes are aligned to one destination note (for example four copied quarter notes against a half note followed by two quarters: the second and third copied notes both go to the first quarter): the destination note receives all their markings; a dynamic or a same-verse lyric from the later copied note wins.
111
+ - The destination has notes between those that receive markings (for example copied quarter notes against destination eighth notes): those in-between notes are left exactly as they were, even in replace mode.
112
+ - The copied passage includes several staves: markings are matched staff to staff in the same arrangement as an ordinary paste, and each staff's destination is the corresponding staff below the cursor; if there aren't enough staves, the same limit as ordinary paste applies.
113
+ - The destination voice is the one the cursor is in; other voices of the destination are not touched.
114
+ - A copied note has several markings of one kind (for example two articulations): all of them are pasted.
115
+ - A destination note is a rest: it receives the markings like any other note.
116
+ - The same kind is ticked in replace mode and the copied note has none: the destination's markings of that kind are removed.
117
+ - The user pastes into the same place they copied from: the markings end up the same as before; nothing breaks.
118
+ - The copied passage was taken from a score that has since changed (notes deleted): the paste uses what was copied, not the current source.
119
+ - Dynamics and annotations that were drawn or placed by hand (offset or custom position) keep their position settings when pasted.
120
+ - Grace notes, ties, slurs, hairpins, tuplets, and rehearsal marks or other measure-level and staff-level items are not part of this feature and are not pasted.
121
+
122
+ ## Requirements *(mandatory)*
123
+
124
+ ### Functional Requirements
125
+
126
+ - **FR-001**: The Edit menu MUST offer a **Paste Special** command that opens a dialog, and the separate Paste Chords command MUST be removed from the menu.
127
+ - **FR-002**: The dialog MUST present one checkbox each for dynamics, lyrics, annotations, chords, articulations and ornaments, and a choice between replacing and adding to what the destination already has.
128
+ - **FR-003**: The dialog's confirm action MUST be unavailable until at least one checkbox is ticked; cancelling MUST leave the score unchanged.
129
+ - **FR-004**: Paste Special MUST apply only the ticked kinds of marking to the destination, and MUST NOT change the destination's pitches, durations, rests, ties, slurs, beams, tuplets or any unticked kind of marking.
130
+ - **FR-005**: The markings MUST be aligned to destination notes by elapsed time, exactly as the existing Paste Chords does: a copied note starts at the sum of the lengths of the copied notes before it, and its markings go to the first destination note, counting from the cursor in the cursor's voice and staff, that starts at or after that time. Elapsed time continues across barlines and measures. For the same rhythm in both, this is one note to one note.
131
+ - **FR-006**: Rests MUST be aligned by their length like any other note, in both the copied passage and the destination.
132
+ - **FR-007**: When the copy runs past the end of the destination part, the paste MUST stop at the end of the part without adding notes or raising an error. Destination notes that no copied note is aligned to MUST be left unchanged.
133
+ - **FR-008**: In replace mode, for each ticked kind, a destination note that receives markings from one or more copied notes MUST first lose its existing markings of that kind and then have exactly the markings of those copied notes, which may be none.
134
+ - **FR-009**: In add mode, for each ticked kind, a destination note MUST keep its existing markings and gain those of the copied notes aligned to it; where a note can hold only one of a kind (a dynamic, or a lyric for one verse), the last pasted one MUST take the place of any existing one. When several copied notes are aligned to one destination note, their markings are combined in order (in both modes), with the same single-valued rule.
135
+ - **FR-010**: Chord symbols MUST be spelled for the destination's instrument transposition, as the existing Paste Chords does (a concert-pitch destination keeps the chord names unchanged, whatever its key signature); all other kinds MUST be pasted unchanged.
136
+ - **FR-011**: Paste Special MUST work from one staff to another, within the same staff, and between different parts of the score, for copies of one or several staves arranged as in an ordinary paste.
137
+ - **FR-012**: The whole Paste Special MUST be a single undoable step.
138
+ - **FR-013**: The command MUST be unavailable, or report that there is nothing to paste, when nothing has been copied.
139
+ - **FR-014**: The pasted markings MUST be independent copies: changing or deleting a pasted marking MUST NOT affect the original, and the other way round.
140
+ - **FR-015**: Automated tests MUST cover each of the six kinds, replace and add modes, mismatched rhythms, running past the end of the destination, rests, multi-measure copies, chord transposition, unticked kinds left untouched, and that pitches and durations never change.
141
+
142
+ ### Key Entities
143
+
144
+ - **Marking kind**: One of dynamics, lyrics, annotations, chords, articulations, ornaments. The user chooses which kinds to paste.
145
+ - **Copied passage**: The notes the user copied, in order, with their markings. Each copied note starts at the sum of the lengths of the copied notes before it.
146
+ - **Destination run**: The notes from the cursor onward in the cursor's voice and staff. A copied note is aligned to the first of them that starts at or after the copied note's start time.
147
+ - **Paste mode**: Replace (destination's markings of the ticked kinds become the copied ones) or Add (destination keeps its markings and gains the copied ones).
148
+
149
+ ## Success Criteria *(mandatory)*
150
+
151
+ ### Measurable Outcomes
152
+
153
+ - **SC-001**: A user can move a set of markings (for example the lyrics of a vocal line) to another part in one dialog visit and no more than 4 actions after copying (place cursor, open Paste Special, tick, confirm), with no retyping.
154
+ - **SC-002**: In every test case, 100% of destination pitches, durations, rests and unticked markings are identical before and after a Paste Special.
155
+ - **SC-003**: In 100% of tested cases the markings of each copied note land on the destination note that Paste Chords would pick for it: one note to one note when the rhythms match, and the first destination note starting at or after the copied note's start time when they differ.
156
+ - **SC-004**: Replace mode leaves each destination note with exactly the copied note's markings of the ticked kinds in 100% of tested cases; add mode never removes an existing marking except a single-valued one that is explicitly superseded.
157
+ - **SC-005**: Chord symbols pasted onto concert-pitch and transposing parts match what Paste Chords gave before the change for the same cases (verified for eight rhythm and transposition scenarios).
158
+ - **SC-006**: One Undo returns the score to exactly its state before the paste in 100% of tested cases.
159
+ - **SC-007**: Pasting markings across a 16-measure passage completes without any visible delay beyond a normal paste.
160
+
161
+ ## Assumptions
162
+
163
+ - "Cut/paste" in the request refers to the existing Copy followed by Paste Special; no new Cut variant is added. Copying works as it does today.
164
+ - Paste Special replaces Paste Chords, with chords as one of the checkboxes.
165
+ - No checkbox is pre-ticked, so a paste always reflects an explicit choice. The dialog's replace/add choice defaults to replace.
166
+ - The dialog does not remember its settings between uses (it may remember them for the current session).
167
+ - "Annotations" means the free-text note annotations; "lyrics" means sung text by verse; "chords" are chord symbols; "dynamics" are the dynamic marks attached to notes; "articulations" and "ornaments" are those attached to notes.
168
+ - Grace notes, tab or fret information, microtones, ties, slurs, hairpins, tuplets, and anything attached to measures or staves rather than notes are out of scope.
169
+ - Alignment starts at the note under the cursor in its voice and staff and uses elapsed time, like Paste Chords does today (the same rule for every kind of marking), and follows the same rules as an ordinary paste for copies that span several staves.
170
+ - This feature builds on the existing copy buffer and does not change how Copy or Paste work.
@@ -0,0 +1,149 @@
1
+ ---
2
+
3
+ description: "Task list for Paste Special"
4
+ ---
5
+
6
+ # Tasks: Paste Special for Note Attachments
7
+
8
+ **Input**: Design documents from `/specs/035-paste-special/`
9
+
10
+ **Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/paste-special-api.md, quickstart.md
11
+
12
+ **Tests**: Requested (FR-015). One headless file, `tests/pasteSpecial.ts`, grown story by story.
13
+
14
+ **Organization**: Grouped by user story. The alignment routine (Foundational) serves every story. US1 is the paste itself plus the dialog and menu, US2 replace/add, US3 alignment with different rhythms, US4 chords and unchanged kinds, US5 undo and removal of Paste Chords.
15
+
16
+ ## Format: `[ID] [P?] [Story] Description`
17
+
18
+ - **[P]**: Can run in parallel (different files, no dependencies)
19
+ - **[Story]**: Which user story this task belongs to
20
+
21
+ ## Phase 1: Setup
22
+
23
+ - [X] T001 Create `tests/pasteSpecial.ts` with the `check()`/failure-count harness and the dynamic-ctor registration used in `tests/voiceCopyPaste.ts`, plus a `buildScore()` helper: two staves, 4 measures of 4/4 quarter notes on staff 0 each carrying a distinctive dynamic, lyric (verse 0), annotation, chord, articulation and ornament (text includes the note's position), and staff 1 with different pitches and its own different markings; helpers `markings(note)` (per-kind lists of comparable strings), `pitchesAndDurations(score)` and `selectNotes()`/`dest()` like `voiceCopyPaste.ts`; register `"test:paste-special": "ts-node -P tests/tsconfig.json tests/pasteSpecial.ts"` in `package.json`
24
+
25
+ ---
26
+
27
+ ## Phase 2: Foundational (Blocking Prerequisites)
28
+
29
+ **Purpose**: The types and the alignment routine every story uses. See [research.md](research.md) R1 and [data-model.md](data-model.md).
30
+
31
+ - [X] T002 In `src/smo/xform/copypaste.ts` add the exported types `PasteAttributeKind`, `PasteAttributeMode`, `PasteAttributeOptions`, `PasteAttributePair` and a static `PasteBuffer.attributeKinds` list in dialog order (dynamics, lyrics, annotations, chords, articulations, ornaments), per [contracts/paste-special-api.md](contracts/paste-special-api.md)
32
+ - [X] T003 Add `PasteBuffer.hasNotes()` in `src/smo/xform/copypaste.ts`: true when any staff in `this.notes` has at least one note
33
+ - [X] T004 Add `PasteBuffer.alignAttributeNotes(selector, notes)` in `src/smo/xform/copypaste.ts`: the algorithm of the existing `pasteChordNotes` with the same two running totals of `tickCount` (named `copiedElapsed` and `destinationElapsed` in the new code), returning the `{ copied, destination }` pairs in order and changing nothing; returns `[]` for no notes or no score; stops when the destination part ends
34
+ - [X] T005 Add `PasteBuffer.getAttributePasteExtent(selector)` in `src/smo/xform/copypaste.ts`: use `pasteIntoScore` with a function that calls `alignAttributeNotes` and records the lowest and highest measure over all pairs, returns the notes unchanged, and returns `null` when there are no pairs
35
+ - [X] T006 Tests in `tests/pasteSpecial.ts` for the foundation: `hasNotes()` false before and true after a copy; alignment with the same rhythm pairs note *i* with note *i*; alignment returns `[]` for empty input and never changes the score; extent is `null` for no pairs and equals the pairs' min and max measure
36
+
37
+ **Checkpoint**: Alignment and extent exist and are verified in isolation.
38
+
39
+ ---
40
+
41
+ ## Phase 3: User Story 1 - Paste only chosen kinds onto existing notes (Priority: P1) 🎯 MVP
42
+
43
+ **Goal**: Choose kinds in a dialog from the Edit menu and have only those kinds appear on the destination, leaving pitches and rhythms alone.
44
+
45
+ **Independent Test**: With dynamics ticked only, staff 2 gains staff 1's dynamics and nothing else changes.
46
+
47
+ ### Tests for User Story 1
48
+
49
+ - [X] T007 [US1] In `tests/pasteSpecial.ts` add: for each of the six kinds alone, same rhythm, only that kind arrives on the destination (compare `markings()` of every kind) and the others are unchanged; all six ticked; empty `kinds` does nothing; `pitchesAndDurations()` identical before and after for every case; a pasted marking is a different object from the copied one and editing the pasted one leaves the copied unchanged (FR-014); serialize then deserialize the score and the markings survive
50
+
51
+ ### Implementation for User Story 1
52
+
53
+ - [X] T008 [US1] In `src/smo/xform/copypaste.ts` add the per-kind helpers from research R2 and R3: a `cloneModifier()` using `SmoNoteModifierBase.deserialize(item.serialize())`; for each kind a function that returns the copied note's items of that kind and one that adds a clone to a destination note (`addDynamic`, `addLyric`, `addAnnotation`, `addLyric` for chords after `SmoLyric.transposeChordToKey(chord, destMeasure.transposeIndex, copied.originalKey, destMeasure.keySignature)`, `setArticulation(a, true)`, `setOrnament(o, true)`)
54
+ - [X] T009 [US1] Add `PasteBuffer.pasteAttributes(selector, options)` in `src/smo/xform/copypaste.ts`: return when `kinds` is empty; use `pasteIntoScore`; group the alignment pairs by destination note (keyed by the note's `attrs.id`) keeping copied-note order; for each destination note add the items of each ticked kind (add mode only for now); never touch pitches, durations or unticked kinds
55
+ - [X] T010 [US1] In `src/render/sui/scoreViewOperations.ts` add `hasCopiedNotes()` and `pasteAttributes(options)`: return if nothing is copied or selected; compute the target as the existing `pasteChords` does (equivalent selection of the tracker's first selection, tick from the tracker); call `getAttributePasteExtent` for the measure range and return if `null`; then group undo with `_undoColumn('paste', i)` and `unrenderColumn` for each measure in the range, call `storePaste.pasteAttributes`, `replaceMeasureView(range)`, `await renderer.updatePromise()` (the structure of `paste()`)
56
+ - [X] T011 [P] [US1] Create `src/ui/components/dialogs/pasteSpecial.vue`: `dialogContainer` with six `toggle.vue` rows labelled Dynamics, Lyrics, Annotations, Chords, Articulations, Ornaments (all off), the container's `enable` bound to "at least one is on", following `addMeasures.vue`
57
+ - [X] T012 [US1] Create `src/ui/dialogs/pasteSpecial.ts` exporting `SuiPasteSpecialDialog(parameters)` using `InstallDialog` and `replaceVueRoot(modalContainerId)` like `addMeasure.ts`; its commit calls `parameters.view.pasteAttributes({ kinds, mode: 'replace' })`; cancel does nothing; export it from `src/application/exports.ts`
58
+ - [X] T013 [US1] In `src/ui/menus/edit.ts` replace `pasteChordsMenuOption` with `pasteSpecialMenuOption` (text "Paste Special...", `display` = `menu.view.hasCopiedNotes()`) whose handler calls `SuiPasteSpecialDialog` with the menu's `view`, `tracker`, `eventSource`, `completeNotifier` and `startPromise: menu.closePromise` as `file.ts` does; update the options list
59
+ - [X] T014 [US1] Run `npx tsc --noEmit -p tsconfig.json` and `npm run test:paste-special`
60
+
61
+ **Checkpoint**: Copy, then Paste Special with chosen kinds, works from the Edit menu.
62
+
63
+ ---
64
+
65
+ ## Phase 4: User Story 2 - Replace or add (Priority: P1)
66
+
67
+ **Goal**: The dialog chooses whether pasted markings replace or add to the destination's.
68
+
69
+ **Independent Test**: Over existing lyrics, replace gives the copied lyrics; add keeps both.
70
+
71
+ ### Tests for User Story 2
72
+
73
+ - [X] T015 [P] [US2] In `tests/pasteSpecial.ts` add: replace over existing articulations, copied note has none, destination ends with none; replace with several kinds replaces only the ticked ones; add keeps existing and adds copied (articulations, ornaments, annotations, chords); add of a dynamic over an existing dynamic leaves exactly one (the pasted); add of a same-verse lyric leaves one while a different verse keeps both; replace clears only on destination notes that are aligned to a copied note
74
+
75
+ ### Implementation for User Story 2
76
+
77
+ - [X] T016 [US2] In `PasteBuffer.pasteAttributes` add the replace step before adding: for each ticked kind clear the destination note's items of that kind (research R2 table: filter `textModifiers` by type or parser, `clearArticulations()`, `ornaments = []`), only for destination notes that appear in an alignment pair
78
+ - [X] T017 [US2] In `pasteSpecial.vue` add a "Replace existing" `toggle.vue` row (on by default) and pass its value through; update `pasteSpecial.ts` to send `mode: 'replace'` when on and `'add'` when off
79
+
80
+ **Checkpoint**: Both modes work from the dialog.
81
+
82
+ ---
83
+
84
+ ## Phase 5: User Story 3 - Alignment by elapsed time (Priority: P1)
85
+
86
+ **Goal**: Different rhythms line up exactly as the existing Paste Chords did.
87
+
88
+ **Independent Test**: Four quarter notes with lyrics onto eight eighth notes land on eighths 1, 3, 5, 7.
89
+
90
+ ### Tests for User Story 3
91
+
92
+ - [X] T018 [P] [US3] In `tests/pasteSpecial.ts` add cases 7–13 and 15 of [quickstart.md](quickstart.md): quarters onto eighths (1, 3, 5, 7, others unchanged even in replace mode), two quarters onto whole notes in two measures, four quarters onto half, quarter, quarter (pairing 0, 1, 1, 2; the shared quarter gets both markings, later dynamic wins), copy longer than the destination part (stops, no error, no notes added), rests in copy and destination, a two-measure copy across the barline, a two-staff copy and a destination with too few staves; and for each, the dry-run extent equals the measures actually edited
93
+ - [X] T019 [US3] Run the tests; if the pairing or extent disagrees with the hand-traced results in research R1, fix `alignAttributeNotes` (it must reproduce `pasteChordNotes` exactly) without changing the rule
94
+
95
+ **Checkpoint**: Alignment verified against the old behavior.
96
+
97
+ ---
98
+
99
+ ## Phase 6: User Story 4 - Chords follow the key; the rest unchanged (Priority: P2)
100
+
101
+ **Goal**: Chords are transposed for the destination; every other kind is copied as is.
102
+
103
+ **Independent Test**: Chords pasted onto a transposing part are spelled for it and left alone on a concert-pitch part; lyrics and annotations are identical.
104
+
105
+ - [X] T020 [P] [US4] In `tests/pasteSpecial.ts` add: chords from a C-major measure pasted onto a D-major measure are transposed (compare with `SmoLyric.transposeChordToKey` output) and onto a transposing-instrument measure follow its `transposeIndex`; lyrics, annotations, dynamics, articulations and ornaments pasted onto the D-major measure have identical text and settings (including position offsets); two successive pastes of different kinds leave the first paste's kinds alone
106
+ - [X] T021 [US4] Fix `pasteAttributes` chord handling if the test shows a difference from the old Paste Chords output for the same input (compare against the removed `pasteChordNotes` logic, kept in git history)
107
+
108
+ **Checkpoint**: Key handling matches the old chord paste; other kinds untouched by transposition.
109
+
110
+ ---
111
+
112
+ ## Phase 7: User Story 5 - One undo step; Paste Chords folded in (Priority: P3)
113
+
114
+ **Goal**: One undo restores the score; the old command is gone.
115
+
116
+ **Independent Test**: Paste Special then Undo once restores the score; the Edit menu has Paste Special and no Paste Chords.
117
+
118
+ - [X] T022 [US5] Remove `PasteBuffer.pasteChords` and `PasteBuffer.pasteChordNotes` from `src/smo/xform/copypaste.ts` and `SuiScoreViewOperations.pasteChords` from `src/render/sui/scoreViewOperations.ts`; grep `src`, `tests`, `types` for remaining references and fix them
119
+ - [X] T023 [US5] Review `pasteAttributes` in `scoreViewOperations.ts` against `paste()`: the undo grouping spans every measure in the extent so one Undo restores them all; add a comment saying so. (Undo and refresh are exercised in the manual steps of [quickstart.md](quickstart.md); there is no headless view. Not yet run in the application.)
120
+
121
+ **Checkpoint**: Menu shows only Paste Special; old code removed.
122
+
123
+ ---
124
+
125
+ ## Phase 8: Polish & Cross-Cutting
126
+
127
+ - [X] T024 [P] Fix `SmoNote.removeAllAnnotations` in `src/smo/data/note.ts` to keep everything except `SmoLyric` annotations (research R10), and add a test: a note with a lyric, a chord and an annotation keeps the lyric and chord
128
+ - [X] T025 [P] Add a changelog entry to `changes.md`: Paste Special replaces Paste Chords; six kinds; replace or add; alignment by elapsed time unchanged; library users replace `pasteChords` with `pasteAttributes({ kinds: ['chords'], mode: 'replace' })`
129
+ - [X] T026 [P] Regenerate declarations with `npm run types`, keep only the files for sources changed here (`copypaste.d.ts`, `scoreViewOperations.d.ts`, `pasteSpecial.d.ts`, `exports.d.ts`, `note.d.ts` if its doc changed), and restore every other changed or untracked file under `types/`
130
+ - [X] T027 Run `tsc --noEmit -p tsconfig.json` and every `test:*` script in `package.json`; fix regressions
131
+ - [ ] T028 Walk through the manual checks in [quickstart.md](quickstart.md) in the running application
132
+
133
+ ---
134
+
135
+ ## Dependencies & Execution Order
136
+
137
+ - Phase 1 → Phase 2 → stories. Phase 2 blocks everything.
138
+ - US1 first (it creates `pasteAttributes`, the view method, dialog and menu). US2 modifies `pasteAttributes` and the dialog. US3 and US4 are mainly tests over the same code and can follow in either order. US5 last because it deletes the old code the earlier tests compare against by hand.
139
+ - Most tasks touch `copypaste.ts` or `tests/pasteSpecial.ts`, so serialize those edits.
140
+ - Polish after all stories.
141
+
142
+ ## Parallel Opportunities
143
+
144
+ T011 (Vue file) alongside T008–T010; T015, T018 and T020 (test additions) alongside the implementation tasks of their own phase if written first; T024, T025, T026 at the end.
145
+
146
+ ## Implementation Strategy
147
+
148
+ 1. Phases 1–2 (alignment), then US1 for a usable Paste Special, then US2 for the mode choice (the pair is the MVP).
149
+ 2. US3 and US4 harden alignment and chords against the old behavior; US5 finishes the migration.
@@ -0,0 +1,36 @@
1
+ # Specification Quality Checklist: Autosave Buffers and Crash Recovery
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+
5
+ **Created**: 2026-11-01
6
+
7
+ **Feature**: [spec.md](../spec.md)
8
+
9
+ ## Content Quality
10
+
11
+ - [x] No implementation details (languages, frameworks, APIs)
12
+ - [x] Focused on user value and business needs
13
+ - [x] Written for non-technical stakeholders
14
+ - [x] All mandatory sections completed
15
+
16
+ ## Requirement Completeness
17
+
18
+ - [x] No [NEEDS CLARIFICATION] markers remain
19
+ - [x] Requirements are testable and unambiguous
20
+ - [x] Success criteria are measurable
21
+ - [x] Success criteria are technology-agnostic (no implementation details)
22
+ - [x] All acceptance scenarios are defined
23
+ - [x] Edge cases are identified
24
+ - [x] Scope is clearly bounded
25
+ - [x] Dependencies and assumptions identified
26
+
27
+ ## Feature Readiness
28
+
29
+ - [x] All functional requirements have clear acceptance criteria
30
+ - [x] User scenarios cover primary flows
31
+ - [x] Feature meets measurable outcomes defined in Success Criteria
32
+ - [x] No implementation details leak into specification
33
+
34
+ ## Notes
35
+
36
+ - Resolved in `/speckit-clarify` (2026-11-01): snapshots use browser local storage; settings live in the score preferences (no global browser settings); minimum snapshot count is 1.
@@ -0,0 +1,111 @@
1
+ # Contract: Autosave Module and UI Entry Points
2
+
3
+ The interfaces below are the testable surface. Names are the intended public API; the cases at the end are the headless test list for `tests/autosave.ts`.
4
+
5
+ ## Preferences (`src/smo/data/scoreModifiers.ts`)
6
+
7
+ ```ts
8
+ interface SmoScorePreferencesParams {
9
+ // ...existing fields
10
+ autosaveInterval?: number; // minutes, 5-60
11
+ autosaveCount?: number; // 1-20
12
+ }
13
+ const autosaveLimits = { minInterval: 5, maxInterval: 60, defaultInterval: 10,
14
+ minCount: 1, maxCount: 20, defaultCount: 10 };
15
+ function clampAutosaveInterval(value: unknown): number; // integer in 5..60, default 10 if not a number
16
+ function clampAutosaveCount(value: unknown): number; // integer in 1..20, default 10 if not a number
17
+ ```
18
+
19
+ `new SmoScorePreferences(params)` applies both clamps. `SmoScorePreferences.defaults` includes both fields at their defaults. `serialize()` includes them.
20
+
21
+ ## Store (`src/render/sui/autosave.ts`)
22
+
23
+ ```ts
24
+ /** the part of the browser's storage that is used, so a test can supply a fake */
25
+ interface AutosaveStorage {
26
+ getItem(key: string): string | null;
27
+ setItem(key: string, value: string): void; // may throw when full
28
+ removeItem(key: string): void;
29
+ }
30
+ interface AutosaveEntry { id: number; time: number; title: string; size: number; }
31
+
32
+ class AutosaveStore {
33
+ constructor(storage: AutosaveStorage);
34
+ /** entries oldest first; entries with no stored text are dropped from the index first */
35
+ list(): AutosaveEntry[];
36
+ /** add a snapshot and keep at most `maxCount` (oldest dropped); returns the entry, or null if it could not be stored */
37
+ add(text: string, title: string, time: number, maxCount: number): AutosaveEntry | null;
38
+ /** the stored text of a snapshot, or null if missing or its length does not match the entry */
39
+ read(id: number): string | null;
40
+ /** drop the oldest snapshots so at most `maxCount` remain */
41
+ trim(maxCount: number): void;
42
+ }
43
+ ```
44
+
45
+ Quick Save's key is never read or written by the store.
46
+
47
+ ## Scheduler (`src/render/sui/autosave.ts`)
48
+
49
+ ```ts
50
+ interface AutosaveTimer {
51
+ set(cb: () => void, ms: number): unknown;
52
+ clear(handle: unknown): void;
53
+ }
54
+ class AutosaveScheduler {
55
+ /** takeSnapshot is called when the timer fires; it may be asynchronous */
56
+ constructor(timer: AutosaveTimer, takeSnapshot: () => void | Promise<void>);
57
+ /** the score changed: arm the timer if idle, otherwise do nothing */
58
+ noteChange(intervalMinutes: number): void;
59
+ /** forget any pending snapshot (a different score was loaded) */
60
+ reset(): void;
61
+ /** the interval setting changed: restart a pending timer from now using the new interval */
62
+ retime(intervalMinutes: number): void;
63
+ readonly armed: boolean;
64
+ }
65
+ ```
66
+
67
+ ## View (`SuiScoreView` / `SuiScoreViewOperations`)
68
+
69
+ | Member | Behavior |
70
+ |--------|----------|
71
+ | `markScoreChanged()` | As today, plus `scheduler.noteChange(score.preferences.autosaveInterval)` |
72
+ | `changeScore(score)` | As today, plus `scheduler.reset()` |
73
+ | `updateScorePreferences(pref)` | As today, plus `store.trim(count)` and `scheduler.retime(interval)` if either changed |
74
+ | `listSnapshots(): AutosaveEntry[]` | Newest first, each with an `available` flag from `read(id) !== null` |
75
+ | `recoverSnapshot(id): Promise<void>` | Decode the stored text, `changeScore`, then `markScoreChanged`. Throws an Error with a user-readable message if the snapshot cannot be read; the open score is left unchanged. |
76
+
77
+ ## Dialog and menu
78
+
79
+ - **File menu**: new entry `Recovery` (value `recovery`) after Quick Save. Handler opens `SuiRecoveryDialog` with the usual dialog parameters.
80
+ - **`SuiRecoveryDialog(parameters)`**: lists `view.listSnapshots()`; selecting an entry enables OK; entries not `available` cannot be selected; with no entries, shows "No autosaved scores are available" and no OK. On close with a choice, in `afterCloseCb`: `confirmReplaceScore(parameters)`, then `view.recoverSnapshot(id)`; a thrown error is shown with `showLoadError`.
81
+ - **Score Preferences**: new "Autosave" section. Two `numberInput` fields, precision 0: "Minutes between autosaves" (5 to 60) and "Autosaves to keep" (1 to 20). Edits write `preferences.autosaveInterval` / `preferences.autosaveCount`, which the existing watcher sends to `updateScorePreferences`.
82
+
83
+ ## Test cases (`tests/autosave.ts`)
84
+
85
+ | # | Case | Expected |
86
+ |---|------|----------|
87
+ | A1 | `new SmoScorePreferences({})`-style legacy params with no autosave fields | interval 10, count 10 |
88
+ | A2 | Interval 0, 4, 61, 7.6, NaN, a string | 5, 5, 60, 8, 10, 10 (clamped or defaulted, whole numbers) |
89
+ | A3 | Count 0, 21, 3.2, undefined | 1, 20, 3, 10 |
90
+ | A4 | Serialize then construct from the result | Both values unchanged |
91
+ | A5 | `defaults` | Both fields at their defaults |
92
+ | S1 | Empty store, `list()` | `[]` |
93
+ | S2 | Add three, `list()` | Three entries, ids increasing, oldest first |
94
+ | S3 | `add` with `maxCount` 3 when three exist | Oldest removed; its storage key is gone; three remain |
95
+ | S4 | `trim(2)` with four stored | Two newest remain; removed keys are gone |
96
+ | S5 | Storage that throws on the first write | Oldest dropped and write retried; new snapshot stored |
97
+ | S6 | Storage that always throws | `add` returns `null`; the index lists only snapshots whose text is still stored (the retry may have removed older ones to make room) |
98
+ | S7 | An entry key removed behind the store's back | `list()` omits it |
99
+ | S8 | Entry text truncated | `read(id)` returns `null` |
100
+ | S9 | Next id after the newest snapshot is removed | Largest remaining id plus one; ids in the list stay strictly increasing |
101
+ | S10 | The Quick Save key present in storage | Never read, changed or removed by any store call |
102
+ | S11 | Two stores over the same storage | Each `add` sees the other's entries; the count limit holds across both |
103
+ | T1 | `noteChange` when idle | Timer set for interval minutes in ms; `armed` true |
104
+ | T2 | `noteChange` ten times while armed | One timer only; one snapshot when it fires |
105
+ | T3 | Timer fires | `takeSnapshot` called once; `armed` false; no timer remains |
106
+ | T4 | Fires with no change since | Not possible: no timer is set without a change |
107
+ | T5 | Change after a fire | Re-armed; second snapshot at a second interval |
108
+ | T6 | `reset()` while armed | Timer cleared; `armed` false |
109
+ | T7 | `retime(20)` while armed | Old timer cleared; new timer for 20 minutes; `armed` true |
110
+ | T8 | `retime` while idle | No timer is set |
111
+ | T9 | `takeSnapshot` rejects | Scheduler goes idle and a later change re-arms it |