Skip to content

feat(editor): add 1/3T and 1/6T coarse triplet snap divisions - #70

Merged
byrongamatos merged 1 commit into
mainfrom
feat/snap-coarse-triplets
Jul 5, 2026
Merged

feat(editor): add 1/3T and 1/6T coarse triplet snap divisions#70
byrongamatos merged 1 commit into
mainfrom
feat/snap-coarse-triplets

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What

Adds two coarse triplet snap resolutions to the arrangement editor's snap grid — 1/3T (quarter-note triplet) and 1/6T (eighth-note triplet) — placed in value order (between 1/2→1/4 and 1/4→1/8). Triplet-family divisions now carry a T suffix (1/3T, 1/6T, 1/12T, 1/24T, 1/48T, 1/96T) so they read distinctly from the binary grid. Default snap stays 1/4.

Why

The grid jumped from 1/4 straight to 1/8, so triplet passages could only be snapped at 1/12T or finer. These two coarse triplets are the one division set #62 (feat/snap-grid-on-profile-stack) had over the merged #57/#58 snap options — ported onto the merged {value, subdivisions} model without adopting #62's {step} engine. (#62 was closed in favor of the merged options; this is the agreed follow-up.)

Implementation notes

The snap <select> options are static in screen.html and index-mapped via editorSetSnap(this.selectedIndex) — not JS-built — so screen.html, SNAP_OPTIONS (screen.js), and the snapIdx default move in lockstep. 1/4 shifts from index 2 → 3, so the S.snapIdx default (and the snap_options.test.js default-index assertion) move with it. snapIdx is not persisted, so no migration is required.

Tests

tests/snap_options.test.js updated — default index, new label list, and added 1/3→3 / 1/6→6 subdivision coverage. Full editor JS suite green (24 files, node tests/*.test.js).

🤖 Generated with Claude Code

https://claude.ai/code/session_01UR2Cr7GEu3yMY7SrfxH6c1

Summary by CodeRabbit

  • New Features
    • Added additional triplet-based snap grid resolutions (including 1/3T and 1/6T) and expanded the list of T-suffixed divisions.
    • Updated the Snap dropdown options while keeping the default snap resolution at 1/4.
  • Bug Fixes
    • Ensured the default snap selection remains effectively unchanged after the dropdown option list was updated.
  • Tests
    • Updated snap option tests to cover the new indexing and T-suffixed labels.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0695a4b5-d292-4ebb-9714-bb2dc33a01e0

📥 Commits

Reviewing files that changed from the base of the PR and between bbeb067 and 1683398.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • screen.html
  • screen.js
  • tests/snap_options.test.js

📝 Walkthrough

Walkthrough

Adds triplet-based snap resolutions to the editor’s snap grid, updates the default snap index and dropdown options, and refreshes tests and changelog text to match the new labels and mappings.

Changes

Triplet Snap Options

Layer / File(s) Summary
Snap options data and default index
screen.js
SNAP_OPTIONS gains triplet resolutions, and S.snapIdx shifts so 1/4 remains the default selection.
Snap dropdown UI update
screen.html
The editor-snap select replaces prior non-triplet entries with triplet-based options, keeping 1/4 selected while changing the emitted index values.
Snap options tests and changelog
tests/snap_options.test.js, CHANGELOG.md
Tests update the expected default index, label list, and subdivision mappings; the changelog records the new triplet divisions and T-suffix labeling.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the new coarse triplet snap divisions to the editor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/snap-coarse-triplets

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
screen.js

ast-grep timed out on this file


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
screen.html (1)

93-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Option order/selection correctly mirrors SNAP_OPTIONS.

1/4 sits at index 3 with selected, matching the new snapIdx: 3 default, and the full ordering matches screen.js's array exactly.

Since editorSetSnap(this.selectedIndex) couples this static list to SNAP_OPTIONS by position, any future edit to one without the other silently desyncs the label shown from the value applied. Consider generating these <option> elements from SNAP_OPTIONS at load time (e.g., populate the <select> in JS using the same array used for SNAP_VALUES) to remove this manual lockstep requirement, which the PR description itself flags as a maintenance burden.

♻️ Sketch: derive options from SNAP_OPTIONS instead of hardcoding
-        <select id="editor-snap" onchange="editorSetSnap(this.selectedIndex)" class="bg-dark-700 border border-gray-700 rounded px-1.5 py-0.5 text-xs text-gray-300 outline-none">
-            <option>1/1</option>
-            <option>1/2</option>
-            <option>1/3T</option>
-            <option selected>1/4</option>
-            <option>1/6T</option>
-            <option>1/8</option>
-            <option>1/12T</option>
-            <option>1/16</option>
-            <option>1/24T</option>
-            <option>1/32</option>
-            <option>1/48T</option>
-            <option>1/64</option>
-            <option>1/96T</option>
-        </select>
+        <select id="editor-snap" onchange="editorSetSnap(this.selectedIndex)" class="bg-dark-700 border border-gray-700 rounded px-1.5 py-0.5 text-xs text-gray-300 outline-none"></select>
// after SNAP_OPTIONS/S are defined
const el = document.getElementById('editor-snap');
el.innerHTML = SNAP_OPTIONS.map((o, i) =>
    `<option${i === S.snapIdx ? ' selected' : ''}>${o.label}</option>`).join('');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@screen.html` around lines 93 - 103, The snap dropdown in the static HTML is
manually duplicating the same ordering as SNAP_OPTIONS, which can silently drift
from the value applied by editorSetSnap(this.selectedIndex). Update the editor
snap select so it is populated from the shared SNAP_OPTIONS data in screen.js
rather than hardcoding the <option> list, and keep the default selection aligned
with the current snapIdx logic. This should be done in the code that initializes
the editor snap control and uses SNAP_VALUES/SNAP_OPTIONS so there is a single
source of truth for both label and selection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 10-19: The new changelog item is creating a second `### Added`
section inside the same Unreleased block, so update the `CHANGELOG.md` entry by
moving this bullet into the existing `### Added` section instead of introducing
a new heading. Keep the content of the new triplet snap note, but merge it with
the current Unreleased `### Added` list so there is only one `### Added` heading
per version block.

---

Nitpick comments:
In `@screen.html`:
- Around line 93-103: The snap dropdown in the static HTML is manually
duplicating the same ordering as SNAP_OPTIONS, which can silently drift from the
value applied by editorSetSnap(this.selectedIndex). Update the editor snap
select so it is populated from the shared SNAP_OPTIONS data in screen.js rather
than hardcoding the <option> list, and keep the default selection aligned with
the current snapIdx logic. This should be done in the code that initializes the
editor snap control and uses SNAP_VALUES/SNAP_OPTIONS so there is a single
source of truth for both label and selection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fb5e6599-f3c5-46a3-91d7-d43e48e8904b

📥 Commits

Reviewing files that changed from the base of the PR and between 977ec65 and bbeb067.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • screen.html
  • screen.js
  • tests/snap_options.test.js

Comment thread CHANGELOG.md
Comment on lines +10 to +19
### Added
- **Coarse triplet snap divisions — `1/3T` and `1/6T`.** The snap grid now offers
quarter-note (`1/3T`) and eighth-note (`1/6T`) triplet resolutions alongside the
existing binary and fine-triplet options, so triplet passages can be snapped
without dropping all the way to `1/12T`. Triplet-family divisions are now labelled
with a `T` suffix (`1/3T`, `1/6T`, `1/12T`, `1/24T`, `1/48T`, `1/96T`) to set them
apart from the binary grid; the default snap stays `1/4`. (Ports the one division
set #62 had over the merged snap options, without adopting its `{step}` engine.)
Tests: `tests/snap_options.test.js`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

New entry creates a duplicate ### Added heading in the same Unreleased section.

This inserts a fresh ### Added block at the top of [Unreleased], but another ### Added section already exists further down in the same block (around line 64). Two separate ### Added headings under one version reduces changelog scannability; consider merging this bullet into the existing ### Added section instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` around lines 10 - 19, The new changelog item is creating a
second `### Added` section inside the same Unreleased block, so update the
`CHANGELOG.md` entry by moving this bullet into the existing `### Added` section
instead of introducing a new heading. Keep the content of the new triplet snap
note, but merge it with the current Unreleased `### Added` list so there is only
one `### Added` heading per version block.

The snap grid jumped from 1/4 straight to 1/8 with no quarter- or
eighth-note triplet resolution, so triplet passages could only snap at
1/12T or finer. Add 1/3T (value 1/3) and 1/6T (value 1/6) in value order,
and label the triplet-family divisions (3/6/12/24/48/96) with a T suffix
so the grid reads clearly against the binary options.

The snap <select> options are static in screen.html and index-mapped via
editorSetSnap(selectedIndex), so screen.html, SNAP_OPTIONS, and the
snapIdx default are kept in lockstep; 1/4 shifts from index 2 to 3, so the
S.snapIdx default and snap_options.test.js move with it. snapIdx is not
persisted, so no migration is needed.

Ports the one division set #62 (feat/snap-grid-on-profile-stack) had over
the merged #57/#58 snap options, without adopting its {step} engine.

Tests: snap_options.test.js updated (+1/3, +1/6 subdivisions, new label
list, default index); full editor JS suite green (24 files).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UR2Cr7GEu3yMY7SrfxH6c1
@byrongamatos
byrongamatos force-pushed the feat/snap-coarse-triplets branch from bbeb067 to 1683398 Compare July 5, 2026 19:01
@byrongamatos
byrongamatos merged commit 2ebdc21 into main Jul 5, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants