smoosic 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/build/smoosic.js +167 -74
  2. package/package.json +82 -77
  3. package/release/smoosic.js +171 -78
  4. package/release/styles/menus.css +26 -0
  5. package/specs/022-text-reposition-on-resize/spec.md +1 -0
  6. package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
  7. package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
  8. package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
  9. package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
  10. package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
  11. package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
  12. package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
  13. package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
  14. package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
  15. package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
  16. package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
  17. package/specs/028-unsaved-changes-indicator/plan.md +96 -0
  18. package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
  19. package/specs/028-unsaved-changes-indicator/research.md +68 -0
  20. package/specs/028-unsaved-changes-indicator/spec.md +135 -0
  21. package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
  22. package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
  23. package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
  24. package/specs/029-remove-promise-helpers/data-model.md +45 -0
  25. package/specs/029-remove-promise-helpers/plan.md +86 -0
  26. package/specs/029-remove-promise-helpers/quickstart.md +53 -0
  27. package/specs/029-remove-promise-helpers/research.md +71 -0
  28. package/specs/029-remove-promise-helpers/spec.md +107 -0
  29. package/specs/029-remove-promise-helpers/tasks.md +164 -0
  30. package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
  31. package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
  32. package/specs/030-copy-paste-voices/data-model.md +63 -0
  33. package/specs/030-copy-paste-voices/plan.md +80 -0
  34. package/specs/030-copy-paste-voices/quickstart.md +50 -0
  35. package/specs/030-copy-paste-voices/research.md +80 -0
  36. package/specs/030-copy-paste-voices/spec.md +124 -0
  37. package/specs/030-copy-paste-voices/tasks.md +183 -0
  38. package/specs/031-select-voice/checklists/requirements.md +39 -0
  39. package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
  40. package/specs/031-select-voice/data-model.md +47 -0
  41. package/specs/031-select-voice/plan.md +79 -0
  42. package/specs/031-select-voice/quickstart.md +43 -0
  43. package/specs/031-select-voice/research.md +55 -0
  44. package/specs/031-select-voice/spec.md +113 -0
  45. package/specs/031-select-voice/tasks.md +171 -0
  46. package/src/application/application.ts +464 -459
  47. package/src/common/promiseHelpers.ts +2 -2
  48. package/src/render/audio/samples.ts +117 -118
  49. package/src/render/sui/pageDivisions.ts +58 -0
  50. package/src/render/sui/renderState.ts +469 -464
  51. package/src/render/sui/scoreChangeState.ts +62 -0
  52. package/src/render/sui/scoreView.ts +30 -0
  53. package/src/render/sui/scoreViewOperations.ts +2555 -2380
  54. package/src/render/sui/svgPageMap.ts +16 -17
  55. package/src/render/sui/textEdit.ts +310 -311
  56. package/src/render/sui/tracker.ts +40 -0
  57. package/src/render/vex/vxNote.ts +3 -1
  58. package/src/smo/xform/copypaste.ts +304 -4
  59. package/src/smo/xform/selections.ts +68 -0
  60. package/src/smo/xform/undo.ts +9 -0
  61. package/src/styles/menus.css +26 -0
  62. package/src/ui/buttons/ribbon.ts +3 -1
  63. package/src/ui/components/buttons/sidebar.vue +15 -6
  64. package/src/ui/components/dialogs/library.vue +3 -1
  65. package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
  66. package/src/ui/dialogs/adapter.ts +181 -183
  67. package/src/ui/dialogs/addMeasure.ts +97 -97
  68. package/src/ui/dialogs/annotationVue.ts +56 -56
  69. package/src/ui/dialogs/audioSettings.ts +121 -123
  70. package/src/ui/dialogs/chordChangeVue.ts +46 -46
  71. package/src/ui/dialogs/clefChange.ts +53 -53
  72. package/src/ui/dialogs/customTuplets.ts +95 -96
  73. package/src/ui/dialogs/customTupletsVue.ts +47 -47
  74. package/src/ui/dialogs/dialog.ts +627 -620
  75. package/src/ui/dialogs/durations.ts +34 -34
  76. package/src/ui/dialogs/dynamics.ts +140 -142
  77. package/src/ui/dialogs/factory.ts +198 -198
  78. package/src/ui/dialogs/fileDialogs.ts +245 -179
  79. package/src/ui/dialogs/fonts.ts +93 -93
  80. package/src/ui/dialogs/globalLayout.ts +40 -40
  81. package/src/ui/dialogs/gracenote.ts +31 -31
  82. package/src/ui/dialogs/hairpin.ts +108 -110
  83. package/src/ui/dialogs/hairpinVue.ts +51 -51
  84. package/src/ui/dialogs/instrument.ts +111 -111
  85. package/src/ui/dialogs/keySignature.ts +175 -176
  86. package/src/ui/dialogs/keySignatureVue.ts +47 -47
  87. package/src/ui/dialogs/library.ts +207 -207
  88. package/src/ui/dialogs/libraryVue.ts +62 -48
  89. package/src/ui/dialogs/lyricVue.ts +46 -46
  90. package/src/ui/dialogs/measureFormat.ts +78 -78
  91. package/src/ui/dialogs/microtones.ts +147 -147
  92. package/src/ui/dialogs/noteHead.ts +319 -319
  93. package/src/ui/dialogs/pageLayout.ts +61 -61
  94. package/src/ui/dialogs/partInfo.ts +60 -60
  95. package/src/ui/dialogs/pedalMarking.ts +117 -117
  96. package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
  97. package/src/ui/dialogs/pitch.ts +352 -352
  98. package/src/ui/dialogs/preferences.ts +40 -40
  99. package/src/ui/dialogs/rehearsalMark.ts +64 -64
  100. package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
  101. package/src/ui/dialogs/scoreId.ts +35 -36
  102. package/src/ui/dialogs/scoreView.ts +42 -42
  103. package/src/ui/dialogs/slur.ts +308 -310
  104. package/src/ui/dialogs/slurVue.ts +91 -91
  105. package/src/ui/dialogs/staffGroup.ts +112 -112
  106. package/src/ui/dialogs/tabNote.ts +84 -84
  107. package/src/ui/dialogs/tabStave.ts +182 -182
  108. package/src/ui/dialogs/tempo.ts +261 -263
  109. package/src/ui/dialogs/tempoVue.ts +73 -73
  110. package/src/ui/dialogs/textBlockVue.ts +127 -127
  111. package/src/ui/dialogs/textBracket.ts +114 -116
  112. package/src/ui/dialogs/textBracketVue.ts +56 -56
  113. package/src/ui/dialogs/tie.ts +140 -142
  114. package/src/ui/dialogs/timeSignature.ts +65 -66
  115. package/src/ui/dialogs/transposeScore.ts +39 -39
  116. package/src/ui/dialogs/unsavedChanges.ts +43 -0
  117. package/src/ui/dialogs/volta.ts +120 -122
  118. package/src/ui/dialogs/voltaVue.ts +51 -51
  119. package/src/ui/fileio/library.ts +110 -111
  120. package/src/ui/menus/edit.ts +100 -1
  121. package/src/ui/menus/file.ts +19 -3
  122. package/tests/pageDivisions.ts +156 -0
  123. package/tests/promiseHelpersUsage.ts +142 -0
  124. package/tests/scoreChangeState.ts +102 -0
  125. package/tests/selectVoice.ts +189 -0
  126. package/tests/voiceCopyPaste.ts +417 -0
@@ -0,0 +1,164 @@
1
+ ---
2
+
3
+ description: "Task list for Replace Promise Helpers with Native Async"
4
+ ---
5
+
6
+ # Tasks: Replace Promise Helpers with Native Async
7
+
8
+ **Input**: Design documents from `/specs/029-remove-promise-helpers/`
9
+
10
+ **Prerequisites**: [plan.md](./plan.md), [spec.md](./spec.md), [research.md](./research.md), [data-model.md](./data-model.md), [contracts/public-api-contract.md](./contracts/public-api-contract.md), [quickstart.md](./quickstart.md)
11
+
12
+ **Tests**: Included. The plan commits to a headless guard script `tests/promiseHelpersUsage.ts` (cases P1 to P9). Its "no application use" cases (P1, P2) are expected to fail until the call sites are converted, and then pass; that is how the guard is proven to work.
13
+
14
+ **Organization**: Tasks are grouped by user story. Almost all edits are in different files, so most can run in parallel.
15
+
16
+ ## Format: `[ID] [P?] [Story] Description`
17
+
18
+ - **[P]**: Can run in parallel (different files, no dependencies on incomplete tasks)
19
+ - **[Story]**: Which user story this task belongs to (US1, US2, US3)
20
+
21
+ ## Path Conventions
22
+
23
+ Single project: `src/`, `tests/`, repo-root `package.json`.
24
+
25
+ ---
26
+
27
+ ## Phase 1: Setup
28
+
29
+ - [X] T001 Add the script `"test:promise-helpers": "ts-node -P tests/tsconfig.json tests/promiseHelpersUsage.ts"` to `package.json`, next to the existing `test:score-change-state` entry.
30
+ - [X] T002 Create `tests/promiseHelpersUsage.ts` with the scaffold only: a header comment pointing at `specs/029-remove-promise-helpers/contracts/public-api-contract.md`, the `failures` counter and `check(name, condition, detail?)` helper copied from `tests/pageDivisions.ts`, and the final summary block (`all checks passed`, or `process.exitCode = 1`). Use only Node's `fs` and `path` plus the helper class; no DOM.
31
+
32
+ ---
33
+
34
+ ## Phase 2: Foundational (Blocking Prerequisites)
35
+
36
+ **Purpose**: The guard test, written before the edits so it can fail first.
37
+
38
+ **CRITICAL**: No user story work can begin until this phase is complete.
39
+
40
+ - [X] T003 In `tests/promiseHelpersUsage.ts`, add cases P1 and P2: recursively read every `.ts`, `.vue` and `.js` file under `src/`, skip `src/common/promiseHelpers.ts` and `src/application/exports.ts`, and fail for each file that contains `PromiseHelpers` (P1) or `emptyPromise(` / `makePromise(` (P2), printing the offending file names in the failure detail.
41
+ - [X] T004 In `tests/promiseHelpersUsage.ts`, add cases P3 to P9: P3 reads `src/application/exports.ts` and checks that it contains `export * from '../common/promiseHelpers'` and a `PromiseHelpers` entry; P4 to P9 import `PromiseHelpers` and `TEmptyPromise` from `../src/common/promiseHelpers` and exercise `emptyPromise`, `makePromise` (condition true on the 3rd poll, with pre-resolve and poll methods counted; and an already-true condition), `promiseChainThen` over two parameter sets, and `TEmptyPromise('x')`, using a 5 ms poll time.
42
+ - [X] T005 Run `npm run test:promise-helpers` and confirm: P3 to P9 pass, and P1 and P2 fail naming the files listed in [data-model.md](./data-model.md). If `promiseHelpers.ts` fails to load under `ts-node` because of its renderer import, that is resolved by T006 (do T006 first).
43
+
44
+ **Checkpoint**: The guard is in place and fails for the right reasons.
45
+
46
+ ---
47
+
48
+ ## Phase 3: User Story 3 - External applications that use the helper keep working (Priority: P1)
49
+
50
+ **Goal**: The helper class stays complete and exported; it no longer pulls the renderer into every importer.
51
+
52
+ **Independent Test**: `npm run test:promise-helpers` cases P3 to P9 pass.
53
+
54
+ - [X] T006 [US3] In `src/common/promiseHelpers.ts`, remove the unused `import { SuiRenderState } from "../render/sui/renderState";` (confirm with a search that `SuiRenderState` is not otherwise used in the file), and add a short doc comment on the class stating that the application no longer uses it and that it is kept for external applications. Do not change any method, type or export.
55
+ - [X] T007 [US3] Re-run `npm run test:promise-helpers` and confirm P3 to P9 pass.
56
+
57
+ **Checkpoint**: The retained class is verified independent of the application.
58
+
59
+ ---
60
+
61
+ ## Phase 4: User Story 1 - Application code no longer builds placeholder promises by hand (Priority: P1) MVP
62
+
63
+ **Goal**: All 19 `emptyPromise()` calls are plain returns from `async` functions, with no change to declared result types.
64
+
65
+ **Independent Test**: A search of `src/` finds no `emptyPromise`; `tsc` and the build pass; the manual pass in quickstart.md steps 5 to 10 shows no change.
66
+
67
+ ### Implementation for User Story 1
68
+
69
+ For each file below: replace the `return PromiseHelpers.emptyPromise();` with `return;` (or an empty body where it is the only statement), make the method `async` if it is not, do not change the declared result type, and remove the `PromiseHelpers` import if it is now unused.
70
+
71
+ - [X] T008 [P] [US1] `src/application/application.ts`: in `createScore`, replace the translate-mode `return PromiseHelpers.emptyPromise();` with `return null;` (the declared type is `Promise<SmoScore | null>`; the only caller ignores the value, per research.md section 2). Drop the import if unused.
72
+ - [X] T009 [P] [US1] `src/render/sui/scoreViewOperations.ts`: replace the seven early-exit calls in `removeLyric`, `removeAnnotation`, `toggleBeamDirection`, `setPitch`, `addOrUpdateStaffModifier`, `deleteMeasure` and `removeStaff` with `return;`. All seven methods are already `async`. Drop the import if unused.
73
+ - [X] T010 [P] [US1] `src/ui/dialogs/adapter.ts`: make `remove()` of `SuiDialogAdapterBase` `async` with an empty body (keep the `Promise<any>` return type). Drop the import.
74
+ - [X] T011 [P] [US1] `src/ui/dialogs/dialog.ts`: change `SuiDialogBase.commit()` to `async commit(): Promise<any> { }`. Drop the import.
75
+ - [X] T012 [P] [US1] `src/ui/dialogs/audioSettings.ts`, `dynamics.ts`, `hairpin.ts`, `slur.ts`, `tempo.ts`, `textBracket.ts`, `tie.ts`, `volta.ts`: in each, make `commit()` an empty `async` method (they are already `async`). Drop each import. (These are eight small files with no shared edits; do them together.)
76
+ - [X] T013 [P] [US1] `src/ui/fileio/library.ts`: declare `SmoLibrary.load()` `async`, replace the already-loaded `return PromiseHelpers.emptyPromise();` with `return;`, and leave the XHR `return new Promise<void>(...)` as it is. Drop the import. Check `libraryVue.ts` and `library.vue` still compile: they `await` the call.
77
+ - [X] T014 [P] [US1] Remove the unused `PromiseHelpers` import (and any `import` line that becomes empty) from `src/ui/dialogs/scoreId.ts`, `timeSignature.ts`, `keySignature.ts`, `fileDialogs.ts`, `customTuplets.ts`, `src/render/sui/textEdit.ts` and `src/render/audio/samples.ts`. Confirm each file has no other mention of the name.
78
+ - [X] T015 [US1] Run `npx tsc --noEmit -p tsconfig.json` and fix any errors (for example a caller that relied on a method being synchronous, per research.md section 3).
79
+ - [ ] T016 [US1] Manual validation: quickstart.md section 4, steps 5 to 10.
80
+
81
+ **Checkpoint**: No `emptyPromise` remains in the application.
82
+
83
+ ---
84
+
85
+ ## Phase 5: User Story 2 - Polling for render state needs no helper class (Priority: P2)
86
+
87
+ **Goal**: The wait for a rendered state is ordinary async code with the same timing.
88
+
89
+ **Independent Test**: `npm run test:promise-helpers` passes P1 and P2; the manual pass in quickstart.md steps 1 to 4 shows no change.
90
+
91
+ ### Implementation for User Story 2
92
+
93
+ - [X] T017 [US2] In `src/render/sui/renderState.ts`, rewrite `_renderStatePromise(condition)` as an `async` method that saves `suspendRendering`, sets it to `false`, then `do { await this.delay2(); } while (!condition());`, and then restores `suspendRendering`, exactly as shown in research.md section 4 (the first check must come only after one `delay2()`, as `makePromise` did). Keep the `Promise<void>` result type, leave `renderPromise()` and `updatePromise()` unchanged, and drop the `PromiseHelpers` import. Ensure `delay2` is defined before use (it is a class property arrow function; `_renderStatePromise` is only called after construction).
94
+ - [X] T018 [US2] Run `npx tsc --noEmit -p tsconfig.json`, then `npm run test:promise-helpers` and confirm all cases P1 to P9 now pass.
95
+ - [ ] T019 [US2] Manual validation: quickstart.md section 4, steps 1 to 4 (render waits: add notes, delete measure, undo, layout change, New, Open, Library).
96
+
97
+ **Checkpoint**: The application has no remaining use of either helper method.
98
+
99
+ ---
100
+
101
+ ## Phase 6: Polish & Cross-Cutting Concerns
102
+
103
+ - [X] T020 Run `npm run test:promise-helpers` and the six existing scripts (`test:score-change-state`, `test:page-divisions`, `test:global-layout-reposition`, `test:text-drag-placement`, `test:attached-text`, `test:rehearsal-measure-number`) and confirm all pass.
104
+ - [X] T021 Run `npm run build` and confirm it succeeds with no new warnings.
105
+ - [ ] T022 Run through all of quickstart.md (sections 1 to 4) and note the result.
106
+
107
+ ---
108
+
109
+ ## Dependencies & Execution Order
110
+
111
+ ### Phase Dependencies
112
+
113
+ - **Setup (Phase 1)**: none.
114
+ - **Foundational (Phase 2)**: depends on Setup. T003 and T004 both edit the same test file, so do them in order; T005 needs both (and T006 if the helper's import breaks loading).
115
+ - **US3 (Phase 3)**: depends on Phase 2 (T006 may be needed before T005 can run).
116
+ - **US1 (Phase 4)**: depends on Phase 2; independent of US3 except for the shared test.
117
+ - **US2 (Phase 5)**: depends on Phase 2; independent of US1 (different file).
118
+ - **Polish (Phase 6)**: depends on all stories.
119
+
120
+ ### Within Each Story
121
+
122
+ - T008 to T014 each touch different files and can run in parallel; T015 runs after all of them.
123
+ - T017 touches only `renderState.ts` and can run in parallel with the US1 edits.
124
+
125
+ ### Parallel Opportunities
126
+
127
+ - T008, T009, T010, T011, T012, T013, T014, and T017 are all different files.
128
+
129
+ ---
130
+
131
+ ## Parallel Example: after Phase 2
132
+
133
+ ```text
134
+ Task: "createScore return null in src/application/application.ts" (T008)
135
+ Task: "Seven early returns in src/render/sui/scoreViewOperations.ts" (T009)
136
+ Task: "adapter.ts / dialog.ts / eight dialog commit() methods" (T010-T012)
137
+ Task: "SmoLibrary.load async in src/ui/fileio/library.ts" (T013)
138
+ Task: "Remove 7 unused imports" (T014)
139
+ Task: "_renderStatePromise async with delay2 in src/render/sui/renderState.ts" (T017)
140
+ ```
141
+
142
+ ---
143
+
144
+ ## Implementation Strategy
145
+
146
+ ### MVP First (User Story 1)
147
+
148
+ 1. Phases 1 and 2 (guard test fails for the right reasons).
149
+ 2. Phase 3 (US3: the retained class is verified), then Phase 4 (US1).
150
+ 3. Stop and validate: the guard's P2 still fails only because of `makePromise` in `renderState.ts`.
151
+
152
+ ### Incremental Delivery
153
+
154
+ 1. US1 removes 19 of the 20 call sites.
155
+ 2. US2 removes the last one and brings the guard fully green.
156
+ 3. Polish runs the full verification.
157
+
158
+ ---
159
+
160
+ ## Notes
161
+
162
+ - These are mechanical edits, but each early-exit call site was checked for dependence on the old extra timer tick (research.md section 3); no explicit delay is introduced anywhere.
163
+ - `src/application/exports.ts` is intentionally not edited.
164
+ - Commit after each phase.
@@ -0,0 +1,39 @@
1
+ # Specification Quality Checklist: Copy and Paste Voices
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+
5
+ **Created**: 2026-10-15
6
+
7
+ **Feature**: [spec.md](../spec.md)
8
+
9
+ ## Content Quality
10
+
11
+ - [x] No implementation details (languages, frameworks, APIs)
12
+ - [x] Focused on user value and business needs
13
+ - [x] Written for non-technical stakeholders
14
+ - [x] All mandatory sections completed
15
+
16
+ ## Requirement Completeness
17
+
18
+ - [x] No [NEEDS CLARIFICATION] markers remain
19
+ - [x] Requirements are testable and unambiguous
20
+ - [x] Success criteria are measurable
21
+ - [x] Success criteria are technology-agnostic (no implementation details)
22
+ - [x] All acceptance scenarios are defined
23
+ - [x] Edge cases are identified
24
+ - [x] Scope is clearly bounded
25
+ - [x] Dependencies and assumptions identified
26
+
27
+ ## Feature Readiness
28
+
29
+ - [x] All functional requirements have clear acceptance criteria
30
+ - [x] User scenarios cover primary flows
31
+ - [x] Feature meets measurable outcomes defined in Success Criteria
32
+ - [x] No implementation details leak into specification
33
+
34
+ ## Notes
35
+
36
+ - The Input line quotes the request verbatim, so it names the existing copy code. The rest of the spec uses behavioral terms.
37
+ - Defaults chosen without asking: a paste past the end of the score is limited to existing measures; All appears in Paste Voice only when more than one voice was copied; a voice pasted into an existing voice replaces it rather than merging; per-voice choices in Copy Voices list only voices present in the selection.
38
+ - Differing time signatures between source and destination reuse the existing paste behavior; the plan phase should confirm how that behaves for whole-measure voice pastes.
39
+ - Ready for `/speckit-clarify` or `/speckit-plan`.
@@ -0,0 +1,47 @@
1
+ # Contract: Voice Copy and Paste
2
+
3
+ Headless cases V1 to V20 are verified by `tests/voiceCopyPaste.ts` (`npm run test:voice-copy-paste`), which builds real scores in memory and drives the real `PasteBuffer`. Manual cases M1 to M10 are in [quickstart.md](../quickstart.md). Spec references: [spec.md](../spec.md).
4
+
5
+ ## Test score used by V-cases
6
+
7
+ A single-staff score of 12 measures in 4/4. Measure notes are four quarter notes whose pitches encode their position (so a pasted note can be traced to its source). Voice 1 is on every measure; voice 2 exists on measures 1 to 4 only, as four quarter notes of different pitches; voice 3 on measure 2 only. Measure 6 contains a triplet in voice 1. Measure 10 has one voice only. Helper functions read back "voice v of measure m as a list of `pitch:ticks`".
8
+
9
+ ## Headless cases
10
+
11
+ | ID | Case | Expected | Spec |
12
+ |----|------|----------|------|
13
+ | V1 | `copyVoiceChoices(0 / 1 / 2 / 3)` | `[]`, `[0]`, `[0,1,'all']`, `[0,1,2,'all']` | FR-002 |
14
+ | V2 | `pasteVoiceChoices([], n)` | `[]` | FR-006 |
15
+ | V3 | `pasteVoiceChoices([1], 1)`, `([0], 2)`, `([0], 3)`, `([0], 4)`, `([0], 0)` | `[0,'new']`, `[0,1,'new']`, `[0,1,2,'new']`, `[0,1,2,3]` (no new voice at four), `[]` | FR-006, US2.2 |
16
+ | V4 | `pasteVoiceChoices([0,1], 1)` | `['all']` | FR-006 |
17
+ | V5 | Copy voice 1 with a selection of the 3rd to 4th note of measure 2 through the 2nd note of measure 3 | copy covers measures 2 to 3 whole; `measureCount` 2; 8 notes | FR-003, US3.1 |
18
+ | V6 | Paste that copy, voice 1, into measure 8 voice 1 | measures 8, 9 voice 1 equal measures 2, 3 voice 1, note for note | US2, SC-001 |
19
+ | V7 | Paste of V6 leaves voice 2 and 3 of measures 8 to 9 as they were | unchanged | FR-008 |
20
+ | V8 | Copy voice 1 of measure 1, paste into voice 2 (existing) of measure 3 | measure 3 voice 2 equals measure 1 voice 1; measure 3 voice 1 unchanged | FR-008, US2.3 |
21
+ | V9 | Copy voice 1 of measure 1, paste into voice 2 of measure 10 (no voice 2) | measure 10 now has voice 2 equal to the copied notes; voice 1 unchanged | FR-010, US2.4, SC-003 |
22
+ | V10 | Copy voice 2 (measure 1), paste into voice 1 of measure 11 | measure 11 voice 1 equals measure 1 voice 2 (voice number changed) | US2.5 |
23
+ | V11 | Copy All of measures 1 to 2 (voices 1, 2, 3 present), paste All at measure 8 (only voice 1) | measures 8 and 9 have voices 1, 2 and 3 equal to the source; measure 9's voice 3 is rests where the source had none | US1.2, FR-009, FR-010, SC-003 |
24
+ | V12 | As V11 but destination measure 9 already has voices 1 and 2 | all three voices replaced to match the source; no extra voice | US1.3 |
25
+ | V13 | Copy All, paste All onto a measure with a 4th voice not copied | the uncopied voice is unchanged | FR-009 |
26
+ | V14 | Copy voice 1 of measures 1 to 4, paste at measure 11 (only 2 measures remain) | measures 11 and 12 receive the first two copied measures; no error | FR-011 |
27
+ | V15 | Copy voice 2 across measures 3 to 5 (voice 2 exists only on 3 and 4) | the measure 5 portion is a measure of rests | FR-005 |
28
+ | V16 | Copy voice 1 including measure 6 (triplet), paste at measure 9 voice 1 | pasted measure has the triplet intact, registered for voice 1 | FR-012 |
29
+ | V17 | Triplet in voice 2 of measure 7 survives a three-measure voice-1 paste over measures 6 to 8 | measure 7's voice-2 tuplet tree is still present | research §3 |
30
+ | V18 | Paste into a destination voice that has a tuplet in the second-to-last pasted measure | no stale tuplet tree remains for the replaced notes | research §3 |
31
+ | V19 | Copy All, paste All, voices keep their numbers and slurs placed within a voice are carried; copy voice 1, paste into voice 2: a slur is not carried | as stated | FR-012 |
32
+ | V20 | Existing Copy and Paste (`setSelections`, `pasteSelections`) on the same score | same result as before this change for single-voice, multi-voice-selected and multi-measure cases | FR-001, SC-005 |
33
+
34
+ ## Manual cases
35
+
36
+ | ID | Case | Expected | Spec |
37
+ |----|------|----------|------|
38
+ | M1 | Edit menu shows Copy, Paste, Paste Chords, Undo and the two new entries | present | FR-001 |
39
+ | M2 | Copy Voices submenu on a one-voice selection | Voice 1 only | FR-002 |
40
+ | M3 | Paste Voice before any Copy Voices | entry not shown | FR-006 |
41
+ | M4 | Copy Voices > All, Paste Voice > All | passage appears with all voices | SC-001 |
42
+ | M5 | Paste Voice > New Voice at a one-voice destination, and at a destination with four voices | the first adds voice 2 with the copied notes, drawn correctly; the second does not offer New Voice | SC-003, FR-006 |
43
+ | M6 | One Undo after M4 and after M5 | all measures restored; created voices gone | FR-013, SC-004 |
44
+ | M7 | Part view: copy and paste voices | works on the displayed measures | research §9 |
45
+ | M8 | Paste twice at different places | both pastes work | FR-015 |
46
+ | M9 | Existing Copy/Paste still work | unchanged | SC-005 |
47
+ | M10 | Paste near the end of the score | pastes what fits, no error | FR-011 |
@@ -0,0 +1,63 @@
1
+ # Data Model: Copy and Paste Voices
2
+
3
+ All structures are in-memory clipboard state. Nothing is serialized into a score, and no saved format changes (constitution Principle #1).
4
+
5
+ ## VoiceCopy (new, held by `PasteBuffer`)
6
+
7
+ | Field | Type | Meaning |
8
+ |-------|------|---------|
9
+ | `voices` | `number[]` | The voice numbers (0 to 3) that were copied, ascending. One entry for a single-voice copy, two or more for All |
10
+ | `firstStaff` | `number` | Index of the first copied staff |
11
+ | `staffCount` | `number` | Number of consecutive staves copied |
12
+ | `firstMeasure` | `number` | Index of the first copied measure (whole measures) |
13
+ | `measureCount` | `number` | Number of whole measures copied |
14
+ | `notes` | `Record<voice, Record<staff, PasteNote[]>>` | For each copied voice and staff, every note of every copied measure, in order. A measure where the voice does not exist contributes that measure's default rests |
15
+ | `modifiers` | `Record<voice, StaffModifierBase[]>` | Staff modifiers (slurs and the like) that start on the copied notes, used only when the voice number is kept |
16
+
17
+ `PasteNote` is the existing structure (`note`, `selector`, `originalKey`, `tupletStart`). The notes are stored in concert pitch with the original key, exactly like the existing copy.
18
+
19
+ **Invariants**
20
+
21
+ - `voices` is non-empty only after a successful voice copy; any new copy (voice copy or normal copy) clears the previous voice copy.
22
+ - Each voice's note list covers exactly `measureCount` whole measures on each copied staff (the total ticks of a voice equal the sum of the copied measures' lengths).
23
+ - At most 4 voices.
24
+
25
+ ## Choice functions (pure, static on `PasteBuffer`)
26
+
27
+ ```ts
28
+ copyVoiceChoices(voicesInSelection: number): Array<number | 'all'>
29
+ // 0 -> []; 1 -> [0]; n>1 -> [0 .. n-1, 'all']
30
+
31
+ pasteVoiceChoices(copiedVoices: number[], destVoiceCount: number): Array<number | 'all' | 'new'>
32
+ // no copy, or no destination (count 0) -> []
33
+ // one voice copied -> [0 .. count-1], plus 'new' if count < 4 (existing voices to replace, and a new voice)
34
+ // several voices copied -> ['all']
35
+ ```
36
+
37
+ ## PasteBuffer additions
38
+
39
+ | Member | Meaning |
40
+ |--------|---------|
41
+ | `voiceCopy: VoiceCopy \| null` | The current voice copy, or null |
42
+ | `setVoiceSelections(score, selections, voice)` | Build a voice copy from selections: whole measures, one voice or `'all'`. Returns false if nothing could be copied |
43
+ | `pasteVoice(destination, voice)` | Paste a single-voice copy into destination voice `voice` (0 to 3) at tick 0 of `destination.measure`, on `staffCount` staves from `destination.staff`. Returns the measures affected |
44
+ | `pasteAllVoices(destination)` | Paste a multi-voice copy, each voice into the voice of the same number |
45
+ | `hasVoiceCopy()`, `copiedVoiceNumbers()`, `getVoiceCopyTickCount()` | Queries used by the menus and the view to compute undo ranges |
46
+
47
+ ## View additions (`SuiScoreViewOperations`)
48
+
49
+ | Method | Meaning |
50
+ |--------|---------|
51
+ | `copyVoices(voice: number \| 'all')` | Copy from the tracker selection, mapped to the store score |
52
+ | `pasteVoices(voice: number | 'all' | 'new')` | Paste at the tracker selection with one grouped undo; 'new' pastes a single copied voice into voice number `getDestinationVoiceCount()` |
53
+ | `getSelectionVoiceCount()` | Highest voice count among the selected measures, for Copy Voices choices |
54
+ | `getDestinationVoiceCount()` | The most voices in any destination measure the paste would cover (on the copied number of staves), for Paste Voice choices; the 'new' voice number is this count |
55
+
56
+ ## State transitions
57
+
58
+ | Event | Effect on `voiceCopy` |
59
+ |-------|----------------------|
60
+ | Copy Voices | replaced |
61
+ | Existing Copy (`setSelections`) | cleared, so Paste Voice is not offered for stale music |
62
+ | Paste Voice (any) | unchanged (pasteable repeatedly) |
63
+ | Loading a new score | cleared (the buffer is tied to the score it was copied from) |
@@ -0,0 +1,80 @@
1
+ # Implementation Plan: Copy and Paste Voices
2
+
3
+ **Branch**: `030-copy-paste-voices` | **Date**: 2026-10-15 | **Spec**: [spec.md](./spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/030-copy-paste-voices/spec.md`
6
+
7
+ ## Summary
8
+
9
+ `PasteBuffer` (`src/smo/xform/copypaste.ts`) gains a second, separate kind of clipboard content: a **voice copy**. `setVoiceSelections` takes the selected notes, widens them to whole measures on each selected staff, and records the notes of each requested voice (one voice, or all) as ordinary `PasteNote` lists, filling measures that lack a copied voice with default rests so every voice stays aligned. `pasteVoice` and `pasteAllVoices` then place those lists at tick 0 of the destination measure by calling the existing `pasteNoteSelections` machinery once per voice and staff. That machinery already creates a missing voice measure by measure, replaces the destination voice's notes, and splits music that overruns a measure into the next one, so voice creation, replacement and the end-of-score limit are inherited rather than reimplemented. Two flaws in that machinery would damage other voices and are fixed narrowly: it forces the destination voice up to the copied voice's number, and it clears the tuplets of every voice in middle measures. The view (`scoreViewOperations.ts`) adds `copyVoices`, `pasteVoices` and the choice helpers, with one grouped undo over the affected columns. `edit.ts` adds two submenu options whose choices are computed by pure functions. The existing Copy and Paste paths are untouched.
10
+
11
+ ## Technical Context
12
+
13
+ **Language/Version**: TypeScript (built by `build/build.js`).
14
+
15
+ **Primary Dependencies**: None new. Existing `PasteBuffer`, `SmoSelection`, `SmoMeasure`, `SmoNote`, `SmoTupletTree`, the menu `subMenu` support (`menu.vue` filters submenu items with `display`), and the view's undo helpers (`_undoColumn`, `storeUndo.grouping`).
16
+
17
+ **Storage**: None. The voice copy is in-memory clipboard state like the existing paste buffer; the saved score format does not change.
18
+
19
+ **Testing**: A headless `ts-node` script `tests/voiceCopyPaste.ts` (`npm run test:voice-copy-paste`) that drives the real `PasteBuffer` against a real `SmoScore` built in memory (verified: `copypaste.ts` loads headless). It covers copy extent, paste into new, existing and different voices, "All", end-of-score limiting, missing voices, tuplets, the preserved-voice cases and the pure menu-choice functions. Undo, the menus and redraw are verified manually (quickstart.md).
20
+
21
+ **Target Platform**: Browser application; tests run under Node.
22
+
23
+ **Project Type**: Single project (library + application).
24
+
25
+ **Performance Goals**: No regression. A voice paste does the same per-measure work as an existing paste, once per pasted voice and staff, in a user-initiated action.
26
+
27
+ **Constraints**: Existing Copy and Paste behavior unchanged; at most 4 voices; paste always at tick 0 of a measure; no change to the score format; the smo layer keeps no UI or rendering dependency (it already imports `SvgHelpers` for measure boxes, unchanged).
28
+
29
+ **Scale/Scope**: One class extended, one view area, one menu file, one test, one small package script.
30
+
31
+ ## Constitution Check
32
+
33
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
34
+
35
+ - **Principle #1 (Serialization)**: PASS. The voice copy is not serialized, and pasted measures are produced through the existing measure serialization round trip, so they carry only fields the format already has.
36
+ - **Principle #2 (Music editing logic regression testing)**: PASS, and this is the main deliverable of the test: transformations of notes and voices get a headless regression script with a contract case list, as for specs 019, 022, 023, 027 and 028.
37
+ - **Principle #3 (Rendering performance)**: PASS. Follows the existing paste pattern: undo columns, unrender the affected columns, replace measures, re-render those measures once. No DOM measurement is added.
38
+ - **Principle #4 (Logical dependencies)**: PASS. The copy and paste logic and the menu-choice rules are in `src/smo` (pure, no UI). The view orchestrates; `edit.ts` only maps choices to view calls.
39
+ - **Async (core principles)**: `copyVoices` and `pasteVoices` are `async` and await the render update, like `paste`.
40
+
41
+ No violations; Complexity Tracking is not needed. Re-check after Phase 1: unchanged, still PASS.
42
+
43
+ ## Project Structure
44
+
45
+ ### Documentation (this feature)
46
+
47
+ ```text
48
+ specs/030-copy-paste-voices/
49
+ ├── plan.md
50
+ ├── research.md
51
+ ├── data-model.md
52
+ ├── quickstart.md
53
+ ├── contracts/
54
+ │ └── voice-copy-paste-contract.md
55
+ ├── checklists/
56
+ │ └── requirements.md
57
+ └── tasks.md # created later by /speckit-tasks
58
+ ```
59
+
60
+ ### Source Code (repository root)
61
+
62
+ ```text
63
+ src/
64
+ ├── smo/xform/copypaste.ts # PasteBuffer: VoiceCopy state; setVoiceSelections, pasteVoice, pasteAllVoices;
65
+ │ # static copyVoiceChoices / pasteVoiceChoices; targeted tuplet fixes in
66
+ │ # _populateMeasureArray (middle measures keep other voices' tuplets)
67
+ ├── render/sui/scoreViewOperations.ts # copyVoices(voice), pasteVoices(voice), voice-choice helpers, grouped undo
68
+ └── ui/menus/edit.ts # "Copy Voices" and "Paste Voice" options with subMenu choices
69
+
70
+ tests/
71
+ └── voiceCopyPaste.ts # NEW headless regression script
72
+
73
+ package.json # add "test:voice-copy-paste"
74
+ ```
75
+
76
+ **Structure Decision**: Extend `PasteBuffer` rather than add a parallel class, because the paste step reuses its private measure/voice machinery. Keep voice-copy state in clearly named separate fields so the existing `notes` / `setSelections` / `pasteSelections` path is not touched.
77
+
78
+ ## Complexity Tracking
79
+
80
+ *No Constitution Check violations; table not needed.*
@@ -0,0 +1,50 @@
1
+ # Quickstart: Validating Copy and Paste Voices
2
+
3
+ Contract cases are in [contracts/voice-copy-paste-contract.md](./contracts/voice-copy-paste-contract.md); structures are in [data-model.md](./data-model.md).
4
+
5
+ ## 1. Headless regression test
6
+
7
+ ```bash
8
+ npm run test:voice-copy-paste
9
+ ```
10
+
11
+ Expected: every case V1 to V20 prints `PASS`, the run ends with `all checks passed`, and the exit code is 0.
12
+
13
+ ## 2. Type check, build, and existing tests
14
+
15
+ ```bash
16
+ npx tsc --noEmit -p tsconfig.json
17
+ npm run build
18
+ npm run test:promise-helpers
19
+ npm run test:score-change-state
20
+ npm run test:page-divisions
21
+ npm run test:global-layout-reposition
22
+ npm run test:text-drag-placement
23
+ npm run test:attached-text
24
+ npm run test:rehearsal-measure-number
25
+ ```
26
+
27
+ Expected: no errors; all scripts pass.
28
+
29
+ ## 3. Manual check in the app
30
+
31
+ Prerequisite: build and open the app. Make a score of about 12 measures: voice 1 on every measure, voice 2 on measures 1 to 4 (use the Voices menu to add voice 2 and enter notes), and one measure with a triplet.
32
+
33
+ **Menus**
34
+ 1. Edit menu: Copy, Paste, Paste Chords, Copy Voices, Paste Voice and Undo are present (Paste Voice only after a Copy Voices).
35
+ 2. Select notes in a one-voice measure: Edit > Copy Voices offers Voice 1 only. Select in measures 1 to 4: it offers Voice 1, Voice 2 and All.
36
+
37
+ **Copy all, paste all**
38
+ 3. Select two notes in the middle of measure 2 and one in measure 3. Edit > Copy Voices > All. Click a note in the middle of measure 8. Edit > Paste Voice > All. Measures 8 and 9 show both voices from measures 2 and 3; the paste started at the beginning of measure 8.
39
+ 4. Edit > Undo once: measures 8 and 9 are back as they were, including the removal of any voice the paste created.
40
+
41
+ **Single voice**
42
+ 5. Select measure 1, Copy Voices > Voice 1. Click measure 10 (one voice). Paste Voice offers Voice 1 and New Voice. Choose New Voice: measure 10 gets a second voice with the copied notes, voice 1 unchanged. On a measure with four voices, New Voice is not offered.
43
+ 6. Copy Voices > Voice 2 on measure 1, then Paste Voice > Voice 1 on measure 11: voice 1 of measure 11 now holds the copied notes.
44
+ 7. Paste again at another measure with the same copy: it works (the copy stays).
45
+
46
+ **Edges**
47
+ 8. Copy 4 measures, paste with the destination at the second-to-last measure: only the measures that exist are filled; no error.
48
+ 9. Copy the measure with the triplet and paste it: the triplet is intact.
49
+ 10. Use plain Copy and Paste on a selection: the same behavior as before.
50
+ 11. Expose a part (part view) and repeat step 3.
@@ -0,0 +1,80 @@
1
+ # Research: Copy and Paste Voices
2
+
3
+ No NEEDS CLARIFICATION items remained after the spec. Findings from reading the code:
4
+
5
+ ## 1. How the current copy and paste work
6
+
7
+ **Finding**: `PasteBuffer.setSelections` records the selected notes as `PasteNote`s (a cloned note in concert pitch, its source selector, its original key and, for a tuplet start, a cloned tuplet tree) in `notes[staff]`, plus staff modifiers that start on the selection. `pasteSelections` → `pasteIntoScore` loops the copied staves, then `pasteNoteSelections(selector, notes)`:
8
+
9
+ 1. `_populateMeasureArray` clones the destination measure(s) the notes will cover, extending to following measures as the notes overrun, and aligns voices (`_alignVoices`).
10
+ 2. `_populateVoice` builds the new note lists per measure, creating any missing voice with default rests (`SmoMeasure.getDefaultNotes`) before filling it, and `_populatePost` keeps the existing notes after the end of the paste.
11
+ 3. Each rebuilt measure is serialized, the destination voice replaced (`_pasteVoiceSer`, which also appends a missing voice), and swapped into the score.
12
+
13
+ **Consequence for this feature**: Replacing a voice, creating a missing voice for every measure it covers, splitting music that overruns a measure, and stopping at the end of the score (the loop only continues while `SmoSelection.measureSelection` finds a next measure) are all already handled. A voice paste can reuse `pasteNoteSelections` unchanged, called once per voice and staff, with the destination voice number placed in the selector and the notes placed from tick 0.
14
+
15
+ ## 2. Flaw: the destination voice is overridden
16
+
17
+ **Finding**: In `pasteNoteSelections`:
18
+
19
+ ```ts
20
+ const maxCutVoice = notes.map(n => n.selector.voice).reduce((a, b) => a > b ? a : b);
21
+ const minCutVoice = notes.map(n => n.selector.voice).reduce((a, b) => a > b ? a : b); // same as max
22
+ if (minCutVoice === maxCutVoice && minCutVoice > selector.voice) { selector.voice = minCutVoice; }
23
+ ```
24
+
25
+ `minCutVoice` is computed with the same comparison as the max, so the two are always equal, and the destination voice is always raised to the copied notes' voice number. (`pasteIntoScore` also builds its working selector with voice 0, so today a paste always goes into the copied voice.) That rule would make "copy voice 2, paste into voice 1" impossible.
26
+
27
+ **Decision**: Do not change this code. For a voice paste, hand `pasteNoteSelections` copies of the notes whose selector voice already equals the chosen destination voice (and whose tuplet tree voice is set to match), so the rule is a no-op. The existing Copy and Paste keep their current behavior exactly.
28
+
29
+ ## 3. Flaw: middle-measure tuplets of every voice are cleared
30
+
31
+ **Finding**: In `_populateMeasureArray`, for a paste covering more than two measures:
32
+
33
+ ```ts
34
+ for (let i = 1; i < this.measures.length - 2; i++) { this.measures[i].tupletTrees = []; }
35
+ ```
36
+
37
+ `tupletTrees` holds the trees of all voices in the measure, so a paste into one voice wipes the tuplet definitions of the other voices in the middle measures, leaving their notes marked as tuplets with no tree. The loop bound also skips the second-to-last measure (`length - 2`), leaving stale trees of the destination voice there.
38
+
39
+ **Decision**: Change the loop to run to the second-to-last measure inclusive (`i < length - 1`) and remove only the trees of the destination voice (`tree.voice === this.destination.voice`). For the existing Copy and Paste this keeps other voices' tuplets in middle measures (previously lost) and removes stale destination-voice trees in the second-to-last measure; it never changes the pasted notes. This is a narrow bug fix, covered by test cases.
40
+
41
+ ## 4. Tuplet trees carry a voice number
42
+
43
+ **Finding**: `SmoTupletTree.voice` identifies the voice a tree belongs to; `adjustTupletIndexes` and `getTupletTreeForNoteIndex` match on it.
44
+
45
+ **Decision**: When remapping a copied voice to a different destination voice, set the cloned tree's `voice` to the destination voice at paste time, together with the note selector's voice, so the pasted tuplet is registered for the right voice.
46
+
47
+ ## 5. Staff modifiers (slurs, hairpins) when the voice number changes
48
+
49
+ **Finding**: Modifiers are located by selectors that include the voice (`_findPlacedModifier` compares the end selector to the note's selector), and their span is measured with `SmoSelection.countTickIndices` using the source coordinates.
50
+
51
+ **Decision**: Carry staff modifiers only when the voice is pasted into the same voice number it was copied from (including every voice of "All"). When the voice number changes, notes and everything attached to the notes themselves (lyrics, chords, dynamics, articulations, tuplets) come along, but staff-spanning modifiers are left behind. This is stated in the spec's assumptions.
52
+
53
+ ## 6. Whole measures
54
+
55
+ **Finding**: `PasteNote.selector` carries the voice, measure and tick, and the paste starts at `selector.tick` within the first measure.
56
+
57
+ **Decision**: Copy records, for every selected staff, every note of the chosen voice(s) in every measure from the first to the last selected measure, in order. Paste always calls `pasteNoteSelections` with `tick: 0`. A voice that has no notes in a copied measure contributes that measure's default rests (`SmoMeasure.getDefaultNotes` for its time signature and clef) so later measures stay aligned.
58
+
59
+ ## 7. Menu choices
60
+
61
+ **Finding**: `SuiConfiguredMenuOption.subMenu` lets an option open a nested list; `menu.vue` filters both levels with `display`, so an option disappears when its `display` returns false (used for the arpeggio and landmark submenus).
62
+
63
+ **Decision**: Copy Voices and Paste Voice are options with `subMenu` lists of choices (Voice 1 to 4, All). Their `display` functions call pure functions on `PasteBuffer`:
64
+
65
+ - `copyVoiceChoices(voicesInSelection: number): Array<number | 'all'>`: voices 0 to n-1, plus `'all'` when n > 1.
66
+ - `pasteVoiceChoices(copiedVoices: number[], destVoiceCount: number): Array<number | 'all' | 'new'>`: nothing if no voice copy exists or there is no destination; for one copied voice, each existing destination voice (to replace it) and `'new'` (a new voice after the existing ones) unless the destination already has four voices; for several copied voices, `'all'` only (FR-006). `'new'` is a separate, always-visible choice instead of an extra numbered entry, so adding a voice never depends on counting.
67
+
68
+ This is how the two kinds of copy map to the two kinds of paste: Copy Voices > Voice N makes a single-voice copy, which is pasted into a chosen voice; Copy Voices > All makes a multi-voice copy, which is pasted with All (each voice into the voice of the same number). A per-voice paste of a multi-voice copy has no clear meaning, so it is not offered. The spec's FR-006 and assumptions were updated to say so.
69
+
70
+ ## 8. Undo and redraw
71
+
72
+ **Finding**: The existing `paste` records `_undoColumn('paste', i)` for each affected measure inside one grouped undo, unrenders those columns, pastes, then calls `replaceMeasureView(range)`. The affected measure range is computed from the tick length of the buffer.
73
+
74
+ **Decision**: `pasteVoices` follows the same pattern. The affected range is the destination measure through the last measure needed to hold the copied ticks, found by adding up destination measure lengths (as `getPasteMeasureList` does), never past the last measure. Created voices are part of the measure state, so one undo removes them.
75
+
76
+ ## 9. Part view
77
+
78
+ **Finding**: In part view, `copy` maps tracker selections to store-score selections (`_getEquivalentSelection`) and pastes into the store score, then refreshes the displayed measures.
79
+
80
+ **Decision**: Voice copy and paste use the same mapping.