Repository navigation
Editor: collapse direct-mode / arrangement-mode split - #32
Merged
Merged
Conversation
Single-take and long-form jobs now feed the editor through the same
data path. Direct-mode jobs synthesize arrangementSegments=[{in:0,
out:duration}] plus a single arrangement-item + chunk; long-form jobs
pass through their persisted arrangement.
Pill IDs are stable: the synthetic item id is __default__ (= the legacy
DEFAULT_ITEM_ID sentinel), so persisted user edits on existing
direct-mode jobs survive the unification.
isArrMode branches still exist; this commit only makes them dispatch
identically for both modes via the synthetic single-segment shape.
Phase B will strip the branches file by file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop generateDefaultPills + the early-out branch in generatePills. The
function now has one body that walks any arrangement+chunks input —
single-take jobs feed it the synthetic single-item arrangement from
synthesizeJobLoadShape, long-form jobs feed it their persisted one,
and pill IDs (`${camId}::${itemId}`) come out the same shape either
way thanks to the __default__ sentinel.
reconcilePills tests previously called with [] / [] for direct-mode
input; updated to pass the synthetic shape that production now uses.
The race-/pollution-protection assertions still cover the same bugs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
useAudioMaster walker: drop the [{in:0, out:dur}] fallback. The store's
loadJob now defaults arrangementSegments to the synthetic single-segment
when callers omit it, so the walker can rely on segs.length > 0.
clampLoopToBounds: project master-trim through `masterToArr` and
intersect with [0, totalArrDuration]. Loop now respects master-trim
in long-form too — previously trim was ignored once an arrangement
was present.
buildEditSpec: slice arrangementSegments at master-trim via
sliceByArrSegments. Single-take with trim {1, 5} keeps emitting
[{in:1, out:5}]; long-form with trim cuts each chunk at the trim
window (was: trim ignored entirely).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The lockfile was generated by `pnpm install` in this worktree and slipped into the previous refactor commit unintentionally. Repo had never tracked it before; this restores that state. The local file stays in the working tree (gitignored as install side-effect). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
shiftLoop and moveLoop projected the playhead through masterToArr only when arrangementSegments was non-empty. The store now invariantly carries at least one segment, so always project — single-take's whole-master segment makes it Identity. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The lockfile is generated locally by pnpm install; it was never tracked historically and keeps slipping into refactor commits via `git add -A`. Mirroring the uv.lock entry so git stays clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
12 isArrMode branches collapsed: - seekStartS / seekEndS land on master-time trim.in / trim.out (was: master-time min/max segment bounds in arr-mode, ignoring trim) - step() always round-trips through arr-time so chunk seams are honoured - IN/OUT loop case + toggleLoop project playhead via masterToArr unconditionally (Identity for single-take) - Arrow-key handler always uses stepByActiveSnap; per-chunk-grid rationale is gone (master bar grid runs continuously across the song, not per-chunk) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
~30 isArrMode branches removed. Highlights: - Range / time-conversion: liveTimelineRange is invariant `[0, arrTotal]`; masterToView / viewToMaster always project through arrangementSegments (Identity for single-take). Candidate-marker range extension dropped. - Trim-dim, trim-handles, audio-start marker render universally — master trim is projected through `mastersToArrAll` so single-take keeps its one tick / one dimmed band, long-form gets one per chunk-occurrence. - Splice marks render only when `arrangementSegments.length > 1` (no-op for single-take's single segment). - Loop drag clamps to the master-trim's arr-projection — same trim- universal contract clampLoopToBounds enforces in the store. - camLookupsForStrip is always pills-derived (pills now exist for every job); ProgramStrip onRemoveCut / onCutDrag / paintPreview always round-trip through master ↔ view, Identity in single-take. - findPillAt no longer early-exits in direct-mode. - Drop unused setLoop dependency that fell out of B.5. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Editor.tsx: drop the `arrangementSegments.length > 0` guards on the trim-default + segment-0 seek paths. Both run for every job — the trim default now derives from the master span across all segments (single-take's whole-master segment yields [0, duration]); seek to segments[0].in lands at 0 in single-take. build-descriptor: collapse `useArrMode` into one path. activeCamAtArr + pill-based source-time mapping is the only resolver now; buildPreviewLayers (master-time-only) and computeCamRanges drop out along with the cuts.ts:activeCamAt import. Pill-based source-time mapping was missing drift handling — fix it to linearly interpolate between pill.sourceInS and pill.sourceOutS across pill.arrStartS/arrEndS, which bakes driftRatio into the pill's source-span (already done by generateArrangementPills via camSourceTimeS). Pre-refactor direct-mode tests catch this through the syncOffset/drift placement test. Tests: build-descriptor + preview-runtime + preview-export-convergence synthesize pills + arrangementSegments from clips (mirroring what synthesizeJobLoadShape does in production), so test setups stay focused on cam/cut/rotation behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
selectors/timing.ts: drop the segment[0].audioStartMs branch from effectiveBeatPhaseS / effectiveAudioStartS / effectiveBarPhaseS. They return pure master-time. The arrangementSegments parameter is gone — the editor uses one master bar grid for every job, anchored on `meta.bpm.phase + audioStartNudgeS` regardless of arrangement order. Per-chunk grid was the previous behavior (each chunk's audioStartMs seeded its own phase) and produced inconsistent bar lines across chunk reorders; the song now renders into a coherent master grid. Consumer projection at the call site: - store.ts (stepByActiveSnap, snapMasterTime, startQuantizeHold): both the input `t` and the bar phase are master-time, snap directly. - Timeline.snapped() and the loop-drag snap path: convert master phase to arr-time via masterToArr so the bar grid the user sees on the arr-time canvas matches what snap rounds to. - BeatRuler: same projection; ticks drawn on the arr-time canvas. - BeatRuler.onClick: arr-time → master via arrToMaster before seek, fixing a pre-existing seek-domain mismatch in long-form. - TransportBar.effectiveStart: pure master-time (no segments needed). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced May 6, 2026
johannboehme
added a commit
that referenced
this pull request
May 6, 2026
Pill body-drag (`pill-move`) only had edge-to-edge magnetic snap to neighbour pills — no grid snap, even with snap mode "1" / "1/4" / etc. Pre-refactor the symptom was hidden because pills only existed in arr-mode; after #32 made pills universal, single-take drag exposes the gap. Pill-trim-in / pill-trim-out called `snapped(arrAtPointer, e)` but `arrAtPointer` is arr-time and `snapped()` interprets master-time. Identity in single-take's whole-master segment, double-projected (broken) in long-form. Fix: introduce `snappedArr(arrT, e)` — same snap pipeline but the input domain is arr-time. Apply to pill-move (new grid snap on top of the existing edge-to-edge magnet) and pill-trim-{in,out} (replace the master-domain `snapped()` with the arr-domain helper). Verified locally: pill-move with snap "1" lands on bar boundaries; snap OFF passes through unchanged; existing 935 tests still pass. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
johannboehme
added a commit
that referenced
this pull request
May 6, 2026
Trim is master-time, but the audio canvas runs in arr-time. With a chunk repeated N times in a long-form arrangement, the trim master- time has N arr-time occurrences. After #32, the trim-dim band and handles only rendered at min(in)..max(out) — one big region spanning the whole song with handles only at the earliest/latest occurrence. That's wrong: the un-trimmed parts of repeated chunks didn't get dimmed, and only one of the N pairs of handles was draggable. Fix: - Dim path uses sliceByArrSegments(trim.in, trim.out, segments) to get the playable arr-time slices directly. Everything outside any slice is dimmed. Trim entirely outside all segments → whole canvas dimmed. Per-occurrence dim bands fall out for free. - Handles render at every mastersToArrAll(trim.in/out) occurrence. All clipped to canvas extent; off-screen positions don't render. - classifyAudioHit walks all occurrences of trim.in / trim.out and reports trim-in / trim-out on hit at any of them. Drag handler unchanged — it sets master-trim, so dragging any occurrence moves every visual handle in lockstep. Single-take and long-form-without-duplicates: identical to before (one occurrence each). Long-form-with-duplicates: now visually truthful + interactable at every chunk repeat. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The editor used to carry two parallel data flows: a direct-mode path for single-take uploads (
arrangementSegmentsempty) and an arrangement-mode path for long-form jobs (arrangementSegmentspopulated). 59 mode-split branches threaded throughEditor.tsx,Timeline.tsx,TransportBar.tsx,store.ts,useAudioMaster.ts,build-descriptor.ts, and the timing selectors.This PR collapses both flows into a single mode-agnostic path by synthesising a single
[{in:0, out:duration}]arrangement segment for direct-mode jobs at load time. Every arr-time helper in arrangement-time.ts is already Identity for that single-segment input, so all the consumers can drop theirif (isArrMode) ... else ...branches and call the helpers unconditionally.After: 59 → 1 remaining occurrence of
isArrMode/arrangementSegments.length > 0in editor code (the legitimateloadJobdefensive default).What changed
arrangementSegments+arrangement+chunksfor every job. Pill IDs stay stable on existing direct-mode jobs (syntheticarrangement[0].id = "__default__"matches the legacy sentinel).generateDefaultPills;generatePillsis single-bodied.effectiveSegsfallback;loadJobdefaults to a synthetic single-segment so the walker can rely onsegs.length > 0.clampLoopToBoundsprojects trim throughmasterToArr;buildEditSpecslicesarrangementSegmentsat the master-trim window viasliceByArrSegments. Long-form export now respects master-trim too (it was silently ignored before).isArrModebranches gone. Skip-to-in/out anchor ontrim.in/trim.outuniversally; arrow-keys universally usestepByActiveSnap(per-chunk-grid rationale removed).mastersToArrAll; splice marks render only whensegments.length > 1; cuts/fx strip projections always run; loop-drag clamps to master-trim's arr-projection.useArrModegone;activeCamAtArris the only resolver.buildPreviewLayers(master-time-only) andcomputeCamRangesdeleted from build-descriptor. Drift-fix in pill-source-time mapping: linear interpolation betweenpill.sourceInSandpill.sourceOutSacross the arr-span (was naivesourceIn + delta, ignoreddriftRatio).arrangementSegments[0].audioStartMsbranch fromeffectiveBeatPhaseS/effectiveAudioStartS/effectiveBarPhaseS. Selectors return pure master-time. Consumers project viamasterToArrat the call site. The editor now uses one master bar grid for every job — anchored onmeta.bpm.phase + audioStartNudgeSregardless of arrangement order. Per-chunk grid (each chunk'saudioStartMsseeding its own phase) is gone — that lives only in Triage now.Test plan
pnpm test --run: 935 passing (920 baseline + 12 new for synthesizeJobLoadShape, master-trim slicing, drift fix; +3 from the WebGPU-probe upstream)pnpm tsc --noEmit: clean (excluding pre-existingwasm/sync-corepackage-not-built warnings)isArrMode|arrangementSegments\.length > 0in editor + Editor.tsx → 1 (the legitimateloadJobdefensive default)buildEditSpecwith narrow trim slices to[trim.in, trim.out]✅activeCamIdresolves correctly through cuts ✅<audio>metadata, so audio playback + compositor preview frames couldn't be visually verified live; covered instead by the vitest pipeline (useAudioMaster + descriptor + walker tests)Risks
buildEditSpecslicing in long-form is a new behavior (export was previously ignoring trim entirely). If any user had a long-form job where they'd set trim "for navigation only" and still expected the full arrangement to render, that contract changes. Addressed explicitly with the user — they confirmed master-trim must be universal.🤖 Generated with Claude Code