Repository navigation
Long-form workflow + data-driven phases (kill JobStatus lifecycle) 8000 - #27
Merged
Merged
Conversation
Adds the long-form session-footage workflow at the entry-point level: - Upload page now ends in a "03 · Routing" step with two ChunkyCards — 03A · DIRECT (existing happy path → editor) and 03B · SESSION (long-form → triage). Routing-cable glyph tells you where each path lands without prose. - LocalJob gains optional `mode`, `silenceConfig`, `sessionBpmOverride`, `chunks[]`, `arrangement[]` plus the matching Chunk + ArrangementItem types. All optional — pre-existing jobs read as `mode: "direct"`. - nextRouteForJob() picks the right next screen given the job state (triage → arrange → edit), with full unit-test coverage for the state-machine. JobPage's "Open editor" button now routes via this helper so long-form jobs land on the right phase. - Triage and Arrange pages exist as functional placeholders so the flow is end-to-end navigable; the real UI lands in phases 3+5. Phase 1 of the long-form workflow plan; editor data model and detection backend stay untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three fixes from first-pass review: - Long-form upload now goes through /job/:id (sync) before reaching Triage. Triage needs the decoded master audio (silence detection, per-chunk BPM) and per-cam frame strips (Cam-Preview), all of which the existing sync pipeline produces. Both modes now share the same sync screen; the JobPage button (already routed via nextRouteForJob) forwards to Triage when ready. - Triage + Arrange go full-bleed (TopBar hidden, like the Editor) and the page chrome shrinks to a thin 48px PhaseStrip — phase breadcrumb, job title, Back, Continue. Frees the rest of the viewport for the Mini-Arranger / Waveform-Overview etc. that land in phases 3+5. - The 03B SESSION card's two-line "patch cable" glyph wouldn't align reliably across font fallbacks. Replaced with a single-line linear diagram: ●━▶ TRIAGE ━▶ EDITOR — same metaphor, no rendering risk. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dashed borders are the established drop-affordance in this design system (AudioDropZone, VideoDropList) — wrong signal for cards that expect a click. Replaced with the ChunkyButton bevel pattern (shadow-emboss, active depress) and dropped the "● PRESS" indicator which was also drop-zone language. Disabled state collapses to a flat 40 %-opacity surface instead of staying dashed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Quick render is the lightweight "drop video + audio → aligned MP4" shortcut — valid use case for direct-mode jobs (mobile clip + finished song, no editor needed). It doesn't fit the long-form workflow where chunks have to be triaged, arranged, then composed in the editor, so the button is hidden when mode === "longform" and the "Continue → Triage" CTA gets the primary slot instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Phase 2 of the long-form workflow. Pure backend — no UI yet. WASM (sync-core): - New silence.rs module: silence_segments(envelope, threshold_lin, min_pause_ms) returns audio chunks (gap-inverted regions). Threshold is linear amplitude; the TS layer converts from dBFS. min_pause_ms guards against splitting between e.g. drum hits — pauses below the threshold get glued back into the surrounding chunk. 9 Rust unit tests cover empty/all-silent/single-chunk/long-gap/short-gap/quiet- threshold/trailing-silence/eof-open/long-form-smoke cases. - New JS-bridge exports: computeRmsEnvelope (re-uses existing tier-0 envelope code, now public) and silenceSegments. Both work directly on Float32Array — no copy, suitable for 1h envelopes. TS orchestrator (frontend/src/local/triage/chunk-detect.ts): - detectChunks(pcm, sampleRate, silenceConfig) returns Chunk[] + the cached envelope so the UI can re-run silence detection on threshold/min-pause changes without recomputing. - detectChunksFromEnvelope() is the live-re-run fast path. - Per-chunk BPM via the existing analyzeAudio() pipeline on the chunk PCM slice. Chunks shorter than 4 s skip BPM detection (autocorrelation needs ~3-4 bars to lock); chunk's `effectiveBpm` falls back to 0 there and the Triage UI will surface a Session-default later. - 9 browser tests with synthetic click-train PCM cover the split/no- split/all-silent/BPM-detection/threshold-tuning matrix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The per-cam patchbay (color stripe + offset + drift + LED bars) needs to appear in the Triage workflow too. Lift it from JobPage's private helpers into components/sync/SyncPatchPanel.tsx, with optional selectedCamId + onSelectCam props for the interactive variant Triage needs (click row → activate that cam in SyncTuner). JobPage stays read-only by omitting the click props — same look as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…view Phase 3 of the long-form workflow. Combined with what was originally Phase 4 (click-through, BPM-octave-toggle, per-chunk inspector) since the user pointed out splitting interaction features from the layout forces a re-design later. Components (frontend/src/components/triage/): - TriageTimeline: Canvas-rendered RMS waveform + bar-ruler + chunk lane. Solid colors per chunk state (accepted = hot, rejected = ink-2 with strikethrough). Mouse-wheel zoom anchored at cursor, shift-drag pan. Click on the chunk lane focuses; click on the waveform/ruler seeks. Multi-zoom-aware: chunk labels and BPM appear as the chunk widens. - TriageTransportBar: Play/pause + prev/next chunk + Keep/Drop. Five shortcuts registered with the global registry: Space (play/pause), Shift+← / Shift+→ (chunk nav), Enter (keep + auto-advance), Backspace (drop + auto-advance) — DE-keyboard-safe. - DetectionPanel: Threshold + Min-Pause sliders. Slider drag re-runs silence detection on the cached envelope (debounced 50 ms) and persists to IDB (debounced 250 ms). Existing accept/reject decisions preserved across re-runs when boundaries match. - ChunkInspector: Time-range, length, bars, BPM with ÷2 / ×1 / ×2 octave-shift toggle. Inline Keep/Drop buttons. - ChunksList: Vertical scroll list, full-color state stripe, inline Keep/Drop. Primary mobile interaction surface. - CamPreview: Single video element keyed by selectedCamId, seeks to master-time minus that cam's sync offset. - TriageAudioMaster (useTriageAudio): Single hidden audio element driving the master clock + loop enforcement. Dual-element gapless loop pattern from the editor is overkill for chunk curation — upgrade later if needed. State (frontend/src/local/triage/triage-store.ts): - Separate Zustand store from the editor — concepts overlap loosely but the focused-chunk / chunk-list / per-chunk BPM aren't editor primitives. Mirrors the editor's playback + view shape so a future shared audio-master hook can drive both. Page wiring (frontend/src/pages/Triage.tsx): - Loads job → kicks off chunk detection → initFromJob populates store. Returns to triage with cached chunks reuses them rather than redetecting. - Layout: lg: 3-column (cam-preview+sync | timeline+chunks-list | detection+inspector) with sticky bottom transport. < lg: vertical stack (cam → detection+inspector → timeline+list+sync). - Reset on unmount so the PCM Float32Array doesn't pin memory. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…less audio Closes the open items left from Phase 3 v1 — no more "later": Store / persistence: - triage-store: setSessionBpm, nudgeCamSyncOverride, extendChunkBars (snap-to-bar at the chunk's effective BPM), plus an effectiveChunkBpm helper that respects session-override. - useTriagePersist: debounced (250 ms) IDB writeback for chunks, silenceConfig, sessionBpmOverride and per-cam syncOverrideMs. SyncPatchPanel: - Optional onNudgeCam + syncOverrides props. When wired in (Triage does), each row gets a ◀▶ nudge stepper (1 ms default; Alt = 100 ms) and the OFFSET cell shows algorithm + override summed with the override-portion in cobalt below. DetectionPanel: - Session-BPM override input — number field + "auto" reset. When set, all chunks inherit it for their bar-grid math regardless of detected BPM. ChunkInspector: - Bar trim controls — four buttons (extend/shrink each end by one bar at the chunk's effective BPM). Disabled when no BPM. Uses the new extendChunkBars store action which also keeps the loop region in sync when the focused chunk is being trimmed. TriageTimeline: - Per-chunk bar/beat ticks rendered on the ruler strip — uses effectiveChunkBpm + beatsPerBar per chunk. Suppresses ticks that would be too dense to read (< 3 px between beats; < 8 px between bars). - Mouse-drag trim handles on chunk left/right edges — snap to the chunk's bar grid by default; Alt held = free drag (ms-precision). Click is suppressed for the synthetic event after a drag so the drag doesn't accidentally toggle focus. - Pinch-zoom + 1-finger pan on touch (PointerEvent multi-pointer tracking). Pinch is anchored at the centroid; pan tracks the finger 1:1. Wheel-zoom + shift-drag still work for mouse. useTriageAudio: - Replaced single-element fallback with the editor's dual-element ping-pong + WebAudio gain crossfade (8 ms ramp, 50 ms lead). Loop wraps are now sample-accurate gapless — chunk-review playback doesn't click on every iteration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…loading Two issues from the first user test: 1. Triage hung at "Decoding master audio + detecting chunks…" — the per-chunk BPM analysis (one analyzeAudio call per chunk) blocks the main thread for 1-2 seconds per chunk. With 30+ chunks that's tens of seconds of frozen UI. 2. Two loading panels in a row (sync screen, then triage decoding) for work the sync step should already have done. Fix moves chunk detection into the sync pipeline (longform jobs only) and persists the result so Triage opens instantly: - LocalJob.triageEnvelope: new optional Float32Array field (~144 KB per hour). Stored alongside chunks so the waveform renders without re-decoding the multi-GB PCM up front. - runSync: detect-chunks step at pct 97 for longform jobs. Persists chunks + envelope. Direct-mode skips entirely. - Triage page: fast-path when chunks + envelope are cached → init store immediately, render UI. PCM decoded lazily in the background so live silence-slider re-runs work after a moment. - chunk-detect: yield to the event loop every other chunk during the per-chunk BPM loop so the sync-progress UI keeps painting (was the root cause of the perceived hang). - DetectionPanel merge: preserve previously-detected BPM when slider re-runs happen before background PCM decode finishes. - Slow-path inline detection still works as a fallback for jobs synced before this change (so existing stuck jobs unblock on reload). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The auto-detection that runs during sync produced chunks immediately, which made nextRouteForJob skip Triage and land users on the Arrange placeholder before they had reviewed anything. The fix makes `arrangement` (vs `chunks`) the "Triage done" signal: undefined = still in Triage, defined-empty = ready to Arrange, non-empty = ready to Edit. Triage's "Continue → Arrange" button now seeds `arrangement` from the user's accepted chunks (chronological) before navigating. On re-entry only newly-accepted chunks are appended, so manual ordering in Arrange survives a round-trip. Cleans the German placeholder copy on Arrange while we're here — all user-facing strings English. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…n't drop
The new chunk-detection step at pct 97 emitted a stage string that
parseStage didn't know — it fell through to the fallback that maps
master to "pending", so the panel jumped from "ANALYSE / done" back
to "queued" right at the end.
Adds a "detecting" master state with its own console label
("Sync · detecting chunks"), bars-animator label ("CHUNKS"), and
footer hint ("Marking chunks for the Triage step…"). Active-state
checks (registration dot, tape reels) include it alongside decoding
+ analyzing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Captures the full long-form triage workflow plan in the repo (was living in ~/.claude/plans/) plus a Status & Notes section documenting where Phase 3 (Triage) currently sits, the open user-feedback items not yet adressed, and the lessons-learned from this session for the next one to pick up cleanly. Branch renamed: claude/determined-antonelli-67ac91 → feat/long-form-triage-workflow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…oggle Layout: full-bleed timeline at the bottom above transport, top row with Cam preview + Inspector + compact ChunksList, snap-mode plate above timeline. Frees vertical real estate the old ChunksList consumed. Tempo model: BPM is song-global (mode of per-chunk detections — whole- file detection is unreliable on long-form sessions), but each chunk has its own audioStartMs anchor since chunks aren't aligned to each other. Per-chunk octave-shift handles outliers. Reuse: - SnapModeButtons split into store-bound wrapper + SnapModeButtonsView (presentational); Triage uses the View directly with its own snap state - BpmReadout split the same way; ChunkInspector embeds BpmReadoutView for global BPM + time-signature - Trim drags now use editor's snap.snapTime() for consistent feel Bug surface reduced: - Keep/Drop only in TransportBar (Enter/Backspace) — Inspector + List no longer duplicate - Time ruler + Bar ruler in separate strips (no more visual collision) - Loop toggle (default on, L shortcut) so playback can leave a focused chunk Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ve keys in BPM editor Layout — four explicit-height regions stacked vertically so the timeline always gets ~50% of the viewport regardless of upper-rack content: - ControlRow (lg:h-80): three equal-height columns, all use h-full flex flex-col min-h-0 so they self-fill and panels with tall content scroll internally - DeckStrip (h-20): brushed-metal band with the snap cassette plate (left) + Detection sliders + kept-LCD (right). DetectionPanel moved out of the inspector column so the brass plate has room to live. - TimelineFrame (flex-1): full-width, inset shadow for tape-window feel - TransportBar at the bottom unchanged Inspector header now hosts the song-global BpmReadoutView brass plate directly — no separate plate strip eating vertical space. Body compresses (gap-y-0.5 KV grid, octave + trim inline labels) to fit the 320px row without scrolling for the common case. BPM editor adds tiny ÷2 / ×2 hardware keys next to the LCD while in edit mode — fast octave correction without typing. Reset button already there; new keys share the dark cassette-button vocabulary. Snap-bypass modifier corrected from Alt to Shift (matches editor's NLE-standard convention from Timeline.tsx). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nk row from→to Cam preview no longer overflows its column — wrapper uses h-100% + aspectRatio + width:auto so the element scales by height when height is the binding constraint, centered horizontally when narrower than the column. Removes the visual collision with the deck strip below. Cam selection moves into the corner badge as a dropdown (TE-style list overlay on the preview frame). SyncPatchPanel is gone from the Triage page entirely — per-cam sync nudging belongs in the editor where cuts depend on it. Frees Col 1 for a full-height preview. Timeline section is now flex-none h-[220px], with the waveform internally capped at MAX_WAVEFORM_HEIGHT=110. Extra vertical space flows to the ControlRow (flex-1 min-h-[18rem]) so the cam preview breathes on tall monitors. ChunksList rows display start → end times + duration again — there's room for it and the from→to span is more useful than start alone. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Triage page used h-full but App's outer shell is min-h-full (no max constraint), so 'h-full' fell through to content-driven height. Result: ControlRow with flex-1 + min-h-[18rem] expanded as tall as the chunks list demanded, ChunksList never hit its overflow-y-auto, the whole page bled past the viewport. Locking the Triage wrapper to h-screen establishes a definite outer height. ControlRow's flex-1 now resolves to actual available space, the grid row gets a real height, and the inner ul.overflow-y-auto in ChunksList finally clips. Also: timeline frame tightened from 220px to 186px (= rulers + capped waveform + chunk-lane exactly), no more dead paper-hi space inside. Section padding shrunk to py-2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… block ChunkInspector body loses the ÷2/×1/×2 octave row — BPM widget in the inspector header has its own ×2/÷2 keys for global override and per-chunk shifts no longer make sense in a global-tempo model. effectiveChunkBpm() reorders preference so global jobBpm wins over the per-chunk detected fallback. TransportBar restructured to a 3-col grid: clock left rail (10rem), centered button cluster (Prev/Play/Next | Loop | Keep/Drop with dividers), kept-counter right rail (10rem). The right rail's reserved width keeps the centered buttons mathematically balanced AND parks clearance for the floating Footer overlay (impressum/datenschutz) that previously occluded Keep + Drop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TransportClock split into TransportClockView (presentational, props- driven) + a thin store-bound wrapper, same pattern as SnapModeButtons and BpmReadout. Triage now mounts the brass-plate TIM/DUR clock directly via a local TriageClock component that subscribes only to playback.currentTime so the rest of the bar doesn't re-render at 60 Hz. TransportBar layout becomes a 1fr-auto-1fr grid: clock left, centered button cluster middle, kept-counter right rail. The fr-symmetric rails put the cluster in mathematical viewport center regardless of how wide the brass plate gets. Loop button moves to the far right of the cluster (after Keep/Drop). Used least often, parked away from the Play/Keep/Drop hot path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…drag Two related fixes for snap-to-bar in the per-chunk grid: 1. extendChunkBars now snaps the current edge to the chunk's bar grid BEFORE stepping. Previously it just added bars*msPerBar to startMs without quantising, so a chunk that started off-grid stayed off-grid forever no matter how many times you clicked '⟸ in'. Now every click lands on the chunk's own grid (anchored at audioStartMs); the first click also corrects any pre-existing drift. 2. usePerChunkBarTicks projects the FOCUSED chunk's bar grid across the full visible view (not just within the chunk's current bounds). The extra ticks render dimmer (60% height, ~33% alpha hot) so the user sees where the next bar would land while trim-dragging outwards, without confusing them with the chunk's "real" content bars. Other chunks stay clipped to their bounds as before. The trim-drag math itself was already correct — it uses chunk anchor + effective BPM via snap.snapTime() and extrapolates beyond the chunk. What was missing was the visual feedback for the extrapolated positions; the dim extension ticks fix that. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…r markers Visual hierarchy was inverted: the time ruler (MM:SS) was loud and ink-coloured, the bar ruler (the actual musical grid the user navigates on) was a thin pale row. Reorder: - Time ruler shrinks to 16px, ink-3 / pale-stone colours, 8px font, reduced opacity. Reads as a faint absolute reference. - Bar ruler grows to 30px on paper-deep with chrome inset, becomes the PRIMARY surface. Downbeats render at 2px hot, full height; beats at 1px half-height. Each downbeat gets a numbered label (1, 2, 3, ... per chunk, restarting at each chunk's audio-start anchor). Per-chunk audio-start anchor markers: a hot vertical line + small filled "▼1" flag at chunk.audioStartMs, spanning bar ruler through the waveform. Makes "where the chunk's bar 1 begins" instantly readable even when zoomed in or when bars run uniformly through the view. The '▼' triangle is shown only when the per-chunk onset detector actually ran (chunks ≥ 4s); otherwise the flag is just '1' to signal that the anchor is the silence-detection start, not a real downbeat. Extension ticks (focused chunk's grid projected past its current bounds for snap preview) keep their dimmer treatment but now also include faded bar numbers, so the user can count "this is bar 9, not just an unknown tick". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Vertical hot line through every layer + a top-of-ruler flag turned out to be way too prominent. The bar number '1' that already shows at each chunk's first downbeat tells the user where the chunk's grid begins — no extra chrome needed. Removes the AudioStartMarker hook + interface + render block. Bar ruler stays as is (numbered downbeats, primary visual hierarchy). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s filter Timeline ruler now adapts to zoom — picks the smallest power-of-2 stride that keeps labeled bars ≥56 px apart, falls through to minor unlabeled bars (≥6 px) and beats (≥8 px per beat). Three tick tiers visually: - bar-major: 2 px hot, full height, numbered - bar-minor: 1.5 px, ~70 % height - beat: 1 px, ~40 % height Useless render below 0.25 px/bar is suppressed entirely. Playhead now drags. Wrapper-level onMouseDown handles both: - click in chunk-lane on a chunk → focus - click anywhere else → start playhead drag, seek (snapped) on move Trim handles register data-trim-handle so the wrapper handler stays out of their way. Single dragRef drives everything. Snap also applies to seek. The snap context is picked from the chunk the cursor is currently inside (or the focused chunk as fallback); all values read fresh from the store each move so closure-staleness can't cause it to silently degrade. ev.shiftKey or snapMode "off" still bypasses; bpm 0 still degrades to free. Triage page falls back to pickGlobalBpm() over persisted chunks when job.bpm and the analysis cache are both empty — covers the case where the sync pipeline ran but produced nothing detectable. ChunkInspector body drops the "Tempo" KV row — BPM is global, lives on the brass plate in the inspector header. DetectionPanel adds a "Min bars" dropdown (off, ≥1, ≥2, ≥4, ≥8, ≥16) next to the threshold + min-pause sliders. Picking a threshold marks chunks shorter than that as accepted=false; re-detection re-applies the filter so slider tweaks don't leak short blips back as accepted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
With 78 chunks each labeling their own bar 1 at their anchor, the ruler at low zoom was an unreadable wall of '1' '17' '33' tags overlapping each other. Bar markers are a per-chunk-context tool — the user only cares about the grid of whatever they're trimming or scrubbing. Other chunks remain visible as colored blocks in the lane below; that's enough to navigate. usePerChunkBarTicks now early-returns when no chunk is focused, and when focused, ONLY emits the focused chunk's grid (projected across the full view so trim-drag outwards has snap targets, with extension ticks dimmed). Extension flag computation simplified accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When zoomed in far enough that beat ticks have breathing room, also emit half-beat (div8) and quarter-beat (div16) sub-ticks. Mirrors the editor's beat-ruler-ticks thresholds: - showDiv8 fires at pxPerBeat ≥ 32 (room for one tick mid-beat) - showDiv16 fires at pxPerBeat ≥ 64 (room for tick at +1/4 and +3/4) Visual hierarchy stays clean — sub-beats render at 25 % / 15 % height with reduced alpha so they fade away as zoom decreases without fighting the bars. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The chunk lane is a thin strip; users were having to aim precisely to focus a chunk. Make the waveform-area click also focus the chunk under the cursor when it lands inside one. Playhead scrub still happens at the exact click position — focusChunk's seek to the chunk start gets overwritten by the seek() that follows. Time ruler + bar ruler clicks remain seek-only, no chunk selection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…llback Two related changes to the chunk-lane block: 1. Width is no longer min-clamped to 2 px — short chunks now show as truly thin slivers when zoomed out, so the visual matches the actual content. Sub-pixel chunks just disappear, which is the honest answer at that zoom level. 2. The intermediate "●" / "✕" placeholder is gone. Either the full readout fits (≥ 120 px wide) or nothing renders inside the block. Bg color + strikethrough already convey accept/reject state at every size. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
focusRelative now walks the accepted-only chronological list. Both the TransportBar Prev/Next buttons and the Shift+←/Shift+→ shortcuts share this implementation, so both skip rejected chunks. If the currently focused chunk is itself rejected (focused via click then dropped), Prev/Next jump to the nearest accepted neighbor in the requested direction by master-time, rather than getting stuck. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s-LCD design Filter behavior: - setMinChunkBars no longer mutates chunk.accepted. Filter is a pure view layer: chunkPassesFilter() / isChunkEffectivelyAccepted() are predicates the consumers AND with the user's accept flag. - Toggling the filter back to off restores the visual + counts without touching anyone's manual Keep/Drop choice. - Re-detection on slider changes preserves accepted as before; no filter mutation step anymore. Consumers updated: - focusRelative skips effectively-accepted (user-kept AND passes filter), Prev/Next skip filtered chunks - ChunkBlock in the timeline reads effectivelyAccepted (passed in from the parent that knows minChunkBars/jobBpm/beatsPerBar) - ChunksList rows show a small "FILT" badge when the user kept the chunk but the active filter excludes it — distinct from "DROP" - Triage Continue → Arrange seeds only effectively-accepted chunks - DetectionPanel "Kept" counter follows the predicate Match snap mode is dropped from Triage. Editor's Timeline.tsx had match wired to per-clip audio-match candidates which Triage doesn't have; the key was always inert here. SnapModeButtonsView grows a `modes?` prop to filter the button set; Triage passes the bar/beat modes only. Min-bars dropdown gets the TE-LCD treatment: brass bezel + scanline LCD readout (mint when off, amber when filter engaged) + chip-grid HardwarePopover for picking, mirroring the BpmReadout vocabulary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…hed pair KeptCounter was a free-standing label-above-LCD column while the bars filter sat in a brass bezel. They lived next to each other on the deck strip but didn't visually rhyme. Wrap the kept counter in the same bezel + vertical-stencil + LCD layout the filter uses, so the two read as a pair of matched LCD modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Power-of-2 chip grid was a needless restriction — drop it for the same click-to-edit number-input pattern BpmReadout uses. User can now type any positive integer (e.g. 5 bars) directly into the LCD; 0 or empty turns the filter off. Vertical stencil renamed BARS → MIN since the unit lives implicitly in the surrounding deck strip and "MIN" is clearer about what the readout means. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…y routing Three user-visible improvements + one architectural cleanup: 1. **Drag-and-drop polaroids onto the film strip.** Previously the only way to add a chunk was the "+ ADD" button. Now the polaroid is the drag handle: pointer-down + 5 px move-threshold starts the drag, while a click still routes to the preview-loop. A floating ghost thumbnail follows the cursor; the FilmStrip's InsertionCursors highlight the active drop target with a pulsing line and a "▼" chevron so the user knows exactly where the chunk will land. Esc cancels. 2. **History routing respects long-form-job state.** Long-form jobs were a one-way street to the editor once arrangement.length > 0 — you couldn't jump back into Triage or Arrange to re-curate. The JobPage now surfaces all reachable phases as buttons, highlighting the most-recent one as primary so muscle memory still works for the common case. 3. **Removed the cam-color sticker** from the polaroid image well — redundant with the +ADD button color and the cam picker in the cockpit. 4. **Strip rotation now baked in at extraction time** rather than re-applied per consumer. `extractFrameStripWebcodecs` / `extractFrameStripFfmpeg` accept a `rotationDeg` and produce display-oriented tiles; `runSync` passes the cam's intrinsic rotation through. New cam field `framesOrientation: "display"` marks the new strips. Editor's aspect calculation and Arrange's tier-2 slicer both branch on the flag — old jobs (`undefined`) keep the legacy codec-strip + manual-rotation path. New jobs are trivial: slice without rotation, get an upright tile. Eliminates the per-consumer rotation duplication. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…eviews The Arrange viewfinder used ◀cam-X▶ cycle buttons; the user asked for the same corner-badge dropdown that Triage already had. Pulled the picker UI into a props-driven `CamPickerDropdown` component and mounted it from both surfaces — same look + same interaction everywhere. The Arrange preview drops the bottom-bar pill in favour of the corner badge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previously the page rendered as soon as the job loaded and kicked off the IDB thumbnail prefetch in parallel — but the polaroids mounted faster than the prefetch resolved, so each one's first paint hit an empty in-memory cache, showed the developing-dots indicator for one React frame, then transitioned to the image once the async extraction returned. Awaiting the prefetch BEFORE `setJob(j)` keeps the page on its "Loading…" placeholder for an extra ~10–50 ms and eliminates the flicker — every polaroid that mounts now finds its URL in the synchronous `peekChunkThumbnailUrl()` and skips the dots entirely. First-time extractions (no cache yet) still play the develop-in animation as designed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Erledigt + entfernt aus dem Plan: - Bug 1 (rotation): cross-check + sauber via baked-in extraction. - Bug 2 (no preview): tier-3 timeout + dedup-fix gelöst. - Drag-Drop Polaroid → FilmStrip mit visual feedback. - History routing: longform jobs surface alle reachable stages. - Cam-Picker shared zwischen Triage + Arrange. - Strip-Rotation gebaken bei extraction (`framesOrientation: "display"`). Refactored: - "Status & Notes for Next Session" 80-Zeilen-Bug-Dump rausgeworfen und durch ein knappes Briefing ersetzt — der Plan wird oft referenziert, schlank halten. - Lessons-Section auf evergreen items kondensiert (rotation-/cache- Theorien aus der Bug-Phase entfernt; meta-lessons wie "diagnose before fix" + neue Patterns wie probe-promise-dedup behalten). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cockpit: per-chunk mel-spectrogram (WASM), KEY/DENS/BRGT/PEAK auto-tags, 4-stem heuristic bars, click-to-seek with synced playhead. Krumhansl- Schmuckler key detection from a 12-bin chroma profile (new chromaProfile WASM export). Spectral color tag on polaroids + frames, skeuomorphic frame bezel with pulse + tooth chevron, cassette-deck-free standard mutation cluster. Audio walker: currentItemId is now authoritative state, advanced only on explicit actions (setPlaying / seekToItem / crossfade-hop) — fixes the duplicate-loop bug where a chunk repeated in the arrangement trapped playback because time-matching always picked the first hit. UX rules: clicks never change play state; seekToItem(id) is the canonical "user picked this item" action everywhere (frame, minimap, polaroid, prev/next, arrow keys); shortcuts swapped (←/→ = focus, shift+←/→ = move, D = duplicate); minimap click selects + seeks. Thumbnails: tier-2 strip-slice keeps native tile resolution (no upscale-then-recompress), tier-2 skipped for tiles narrower than 100 px display-width so portrait phone clips fall through to tier-3 full-res seek. IDB v6 → v7 wipes the old blocky cache. Storage: IDB v5 → v6 adds chunk-mel-specs store (mel + chroma per chunk, lazy-eager filled by a dedicated worker on Arrange mount). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
UI: - waveform: mip-pyramid + path-based filled curve, smooth at any zoom - chunk-block: 2px hairline handles, hot-orange selection, 3px min-pill for sub-pixel chunks so they stay visible at full zoom-out - inspector: brass bezel cap, EDIT section (split / join / reset), +new chunk button in the no-selection state, autoscroll in chunks list - detection sliders: brass-bezel cradle with phosphor-amber fill, bevelled brass thumb, LCD readouts matching the deck strip vocab - phase-strip arrow phosphor-tinted, last cobalt residues purged UX: - splitChunkAt / joinChunks / insertChunkAtPlayhead / resetChunk store actions cover the cases silence detection can't reach (chunks inside silence, splitting long takes, undoing manual trims) - Chunk schema gains originalStartMs/EndMs/AudioStartMs snapshots so Reset is meaningful; chunk-detect seeds them on every detection pass - shortcuts S / J / Shift+J / N / R registered with help-overlay group "Triage · Edit" Tests: 18 new triage-store unit tests, all 819 unit tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Phase 6+7 of the long-form triage workflow: open the Editor on a
long-form job and the timeline becomes the song (= arrangement) instead
of the raw master audio. Hits Space → audio walker hops between chunks
gapless, time display reads as one continuous song, cuts/FX placed
during playback land on the right chunk.
Architecture decision: surgical conversion-layer instead of the planned
full lanes[].pills[] schema migration. Cuts/FX stay master-time-anchored
in the store (sample-accurate, chunk-anchored, survive arrangement
reorders); only the UI surfaces translate to/from arrangement-time at
their edges. Per-cam pills are derived from clipRange ∩ segments
on every render — no schema change needed.
frontend/src/editor/arrangement-time.ts (NEW)
Pure helpers: masterToArr, arrToMaster, totalArrDuration,
mastersToArrAll (duplicate-aware), sliceByArrSegments (pill split),
segmentIndexAtArr/AtMaster, segmentArrStarts. 19 unit tests.
Timeline.tsx
tToX/xToT route through masterToView/viewToMaster; arrTToX for
pure arr-coordinate work. Per-cam clip pills auto-split via
sliceByArrSegments. Audio waveform redrawn per-segment in arr-mode
(master peaks → arr-pixel projection per slice). Splice marks at
every segment seam. ProgramStrip + FxStripLayer get pre-projected
stripCuts (mastersToArrAll-expanded) and stripFx (slice-split);
callbacks convert arr-time back to master-time. BeatRuler hidden,
trim handles hidden, loop hidden, match markers hidden in arr-mode.
seekFromX takes the canvas-x and binds the audio walker to the
correct segment occurrence (so a click on a duplicate chunk doesn't
snap back to occurrence #0).
TransportClock + TransportBar
Clock reads master-time → masterToArr; duration = totalArrDuration.
Skip-to-in lands on min(seg.in), skip-to-out on max(seg.out)−1/fps.
Arrow-step in arr-mode = ±1 frame in arr-time (master bar grid is
per-chunk per the triage tempo model). Loop button is a no-op +
notice in arr-mode.
useAudioMaster.ts
Authoritative state.currentSegmentIdx fixes the duplicate-chunk
endless-loop: vorher hat der Walker bei jedem Tick "scan-for-first
-master-time-match" gemacht; bei Duplikaten bedeutete das
occurrence-0 forever. Crossfade-arming stamps armed.nextSegmentIdx,
fire advances the index. User-seek either takes the new
seekSegmentIdxHint (forwarded from Timeline clicks) or falls back
to a master-time scan. 2 new walker tests cover the duplicate +
hint paths.
store.ts
seek(t, opts?) gains opts.segmentIdxHint, surfaced as
playback.seekSegmentIdxHint for the audio walker to consume.
clearSeekRequest also clears the hint.
pages/Editor.tsx
On longform load, seek(segments[0].in, {segmentIdxHint:0}) so the
audio walker doesn't trip its in-gap → hard-seek branch on the
first Space press. Drops the always-on window.__lastEditorSegments
debug hooks; replaces with import.meta.env.DEV-gated
window.__editorTestHooks. Test scripts updated to read the gated
hook instead.
scripts/editor-playback-e2e.mjs (NEW)
Headless playback-timing test: seeds a longform job with 4 segments
(incl. a duplicate), opens the editor, presses Space, samples
audio.currentTime over ~3s. Asserts time advances + no master-time
sample falls outside the union of segment ranges (= no drift into
gaps) + Space pauses. Output sample shows master 0.86→2.32 in
seg-0, gapless hop to 5.21 in seg-1. Pre-existing
arrange-e2e-screens.mjs continues to validate the full
Upload→Triage→Arrange→Editor handoff.
840+ unit tests pass; one pre-existing GPU-budget stress test (compositor
p95 < 16ms) is flaky on shared CI/dev GPUs and unrelated to this change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two changes intertwined enough to land together:
1) End-of-arrangement loop-back fix.
Symptom: at the very end of the song, playback briefly looped back
to the start instead of stopping cleanly. Root cause: the audio
walker fake-armed a no-op crossfade in the LAST-segment branch as
a hack to suppress re-arming on the next tick. The arrangement-
crossfade swap block didn't distinguish a real hop from this fake-
arm, so it fired anyway, swapped roles, and kicked the IDLE
element (parked at the previous wrap target = start of the last
segment) onto PROGRAM. With a duplicate chunk in the arrangement,
that idle's master-time matched chunk-0's master range, so
masterToArr → arr-time 0 and the playhead snapped to the song
start. Visible as "loops back to the beginning".
Fix: separate `endPauseTimer` + `endPauseSegmentIdx` state. The
walker schedules a real `setPlaying(false)` timeout at curSeg.out
(no fake-arm, no swap) and lets the active element keep playing
for ~LEAD_TIME before the timeout fires. cancelArmedCrossfade()
also cancels the end-pause so a manual scrub away from the end
doesn't trip a stale pause. Regression-tested against a duplicate-
chunk arrangement: the idle never gets re-played as new active
during the end-pause window.
2) First-class pills (Phase 6 proper).
The earlier "surgical" approach derived per-cam slices from the
arrangement+segments at render time. Slices weren't selectable,
couldn't be moved, and couldn't be trimmed individually — which is
exactly what an NLE needs. This commit promotes pills to a stored
first-class entity.
`editor/arrangement-pills.ts` (new):
- generateArrangementPills(arrangement, chunks, clips) emits one
Pill per (cam × arrangement-item) intersection. Pill ID is
`${camId}::${arrangementItemId}` so user edits round-trip
across editor mounts.
- reconcileArrangementPills() splices stored (user-edited) pills
on top of the freshly generated default; pills whose
arrangement-item disappeared are dropped.
- activeCamAtArr() resolves PROGRAM cam in arr-time space:
last cut whose master→arr maps ≤ arr-time wins (when its cam
has a covering pill); otherwise falls back to the first
covering pill. Also returns the active pill so callers can
read source-time straight from it.
editor/store.ts:
- New state: pills[], selectedPillId.
- New actions: setPills, setSelectedPillId, setPillArrPlacement
(drag-move, preserves duration), setPillLeftEdgeArrStartS +
setPillRightEdgeArrEndS (edge-trim, advance/retreat sourceIn/
sourceOut in lockstep so the cam stays in sync with the pill's
arr-window). Min-window 50ms; placement clamped to arr-time ≥0.
- loadJob now accepts arrangement+chunks+storedPills and runs
reconcileArrangementPills.
- activeCamId() routes through activeCamAtArr in arr-mode (legacy
clipRangeS-based resolver in direct-mode).
editor/components/Timeline.tsx:
- Per-cam-lane drawing reads stored pills (sorted by arrStartS)
in arr-mode instead of recomputing slices on every render.
- drawVideoLane gets per-slice selection so individual pills
highlight (hot-orange bezel + glow) without the whole lane
lighting up.
- New drag types: pill-move (body), pill-trim-in (left edge),
pill-trim-out (right edge). Hit-test is HANDLE_HIT-aware; in
arr-mode pill manipulation bypasses lanesLocked (which is a
direct-mode affordance — pills ARE the editing surface here).
- findPillAt(x, y) returns {pillId, zone} for the body / edge
hit. Empty-lane clicks clear selectedPillId so the
right-side per-pill toolbar (future) can show "no pill".
Render path (local/render/edit.ts):
- MultiCamRenderInput grows a pills?: Pill[] field. When pills
are present alongside non-empty segments, the per-frame loop
walks an arrCursorPerSeg, computes tArr, and calls
activeCamAtArr to pick the cam + active pill. Source-time for
video cams comes from `pill.sourceInS + (tArr - pill.arrStartS)`
— moving or trimming a pill in the editor maps directly into
which source frame the encoder fetches.
- editRenderMulti is dispatched whenever pills.length > 0 too
(was: only when cuts or multi-cam).
Preview path (editor/render/build-descriptor.ts):
- EditorStoreSnapshot grows pills + arrangementSegments fields.
- buildPreviewFrameDescriptor forks: arr-mode → activeCamAtArr +
buildPreviewLayersFromPill (source-time directly from the active
pill); direct-mode → legacy buildPreviewLayers.
- PreviewRuntime's defaultReadSnapshot now mirrors pills +
arrangementSegments so the live preview honours pill edits.
Storage (storage/jobs-db.ts):
- PillRecord persisted on LocalJob.pills. useAutoPersist writes
s.pills on every debounced flush so move/trim survives refresh.
Editor.tsx onSubmit:
- Forwards spec.pills into EditSpecLocal so the worker render gets
the same pill table the preview used.
Tests:
- arrangement-pills.test.ts: 6 cases for generation +
reconciliation (single cam, multiple cams, partial cam-range
overlap, duplicates, missing chunks, stored-pill survival,
orphan stored-pill drop).
- useAudioMaster: new regression test confirms the swap block
never kicks the idle onto PROGRAM at end-of-arrangement.
- 847/847 unit tests pass; lint clean.
Phase 6 from PLAN.md is now actually done — pills are individually
selectable, movable, and trimmable; render + preview honour the user's
pill edits.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…udge/undo
The editor is now uniformly pill-based. Every job — single-take OR
arrangement — renders through `pills[]`; there is no longer a "direct
mode" branch in the rendering, drag, or active-cam pipeline. The legacy
clip-move / video-trim / image-resize drag types and the
`isArrMode`-gated rendering are gone for good.
What changed in shape:
Pill type (editor/types.ts):
- Adds `originalArr*S` + `originalSource*S` snapshots so per-pill
RESET restores the auto-derived default.
Pill generation (editor/arrangement-pills.ts):
- `generatePills(arrangement, chunks, clips)` dispatches:
arrangement non-empty → one pill per (cam × arrangement-item)
arrangement empty → one pill per cam covering its full
master range, id `${camId}::__default__`
Single-take jobs are first-class pill consumers. Pill auto-
generation always emits originals so the new RESET action has
something to roll back to.
- `reconcilePills` keeps user-edited arr/source values across
mounts and refreshes originals to whatever the editor would
generate now (so RESET tracks current state, not a frozen
snapshot of when the pill was first created).
Store (editor/store.ts):
- `loadJob` always runs reconcilePills; no `arrangement.length > 0`
gate.
- `activeCamId` always routes through `activeCamAtArr`. Single-
take jobs have empty `arrangementSegments`, so masterToArr is
identity and the pill+cuts resolver behaves like the legacy
`activeCamAt` did.
- New mutation actions:
resetPill(id) — restore from originals
resetPillsForCam(camId)
nudgePillSourceMs(id, deltaMs) — shift sourceIn/Out
nudgePillArrMs(id, deltaMs) — shift arrStart/End
nudgeCamSourceMs(camId, deltaMs) — track-nudge in lockstep
- Undo stack: `pillHistory` + `pillFuture`. `commitPillEdit()`
snapshots pre-mutation state at the start of every gesture
(drag-start, hotkey-nudge, reset). Continuous drag updates
batch into a single undo step. `undoPillEdit` / `redoPillEdit`
pop/push between the stacks. History capped at 200 steps.
Timeline (editor/components/Timeline.tsx):
- `clip-move`, `video-trim-in`, `video-trim-out`,
`image-resize-start`, `image-resize-end` drag types — DELETED.
Pills are the editing surface; cam-master-anchor edits flow
through SyncTuner / nudge actions, not through dragging the
lane content.
- `findClipResizeEdge` / `drawMatchMarkers` — DELETED.
- `lanesLocked` is back as the single safety toggle: LOCK ON →
every video-lane click scrubs the playhead; LOCK OFF → pill-
edge clicks start a trim drag, body clicks start a move drag.
Empty-lane click always scrubs.
- Pill rendering reads stored `pills[]` directly — no more
master-range slicing on every render tick.
- Drag-start calls `commitPillEdit()` so Cmd+Z reverts the whole
gesture, not one pixel.
Editor.tsx:
- New hotkey block:
R reset selected pill
, / . pill source-nudge ±1 frame (Shift = ±10)
[ / ] cam track-nudge ±1 frame (Shift = ±10)
⌘Z / ⌘⇧Z pill undo / redo
All shortcuts registered through `useRegisterShortcut` so the
`?` overlay picks them up under a "Pills" group.
- `loadJob` opts unconditionally include `arrangement`/`chunks`/
`storedPills` (no more longform-only gate).
Storage (storage/jobs-db.ts):
- PillRecord grows the four `original*` fields. No migration —
LocalJob.pills is freshly emitted by the editor on next save,
and arr-mode jobs already roundtrip pill state so old rows are
compatible (originals will refresh on next reconcile).
Tests:
- Updated arrangement-pills tests for the new originals shape +
single-take path (7 cases).
- New pill-actions test (12 cases): arr placement, edge trim,
reset, source-nudge, cam-track-nudge, undo/redo state machine.
- 860/860 unit tests pass; lint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…e track-drag Three corrections to the previous pill rewrite: 1) Hotkeys removed. The R / , / . / [ / ] / ⌘Z bindings I added are gone — `[` and `]` require AltGr on a German keyboard, , and . shadow normal text navigation, R was overloaded, and ⌘ is a Mac-only modifier. The corresponding `useRegisterShortcut` entries are dropped from the help overlay too. Pill nudging happens through the existing Sync Tuner panel; reset lives on the per-pill section in the OptionsPanel; undo/redo are pure UI buttons in the Timeline header (cross-platform, no keyboard chord involved). 2) Match markers brought back, scoped to MATCH snap-mode. `drawMatchMarkers` is reinstated and called inside the per-cam draw loop whenever the active snap-mode is "match". The selected cam emphasises (= drawn at full brightness); the others render at the normal 55 % so the user can read every track's alignment options at once. Pill-body drag in MATCH mode is now a CAM-TRACK move: a new `cam-track-move` drag-kind snapshots every pill of the cam and shifts them all by the pointer-delta in arr-time. This matches the user's request — "soll alle pills in dem track versetzen" — so a drag against a candidate marker re-times the whole take in lockstep instead of lifting one pill out of formation. 3) Sync Tuner nudges now mirror to pills. The legacy SyncTuner mutates `clip.syncOverrideMs`; with pills authoritative for source-time, that field alone no longer drives playback. `setClipSyncOverride` now also shifts every pill of the cam by the same delta (both live `sourceIn/Out` AND the `originalSource*S` baselines, so per-pill RESET targets the post-anchor position the user just dialled in). The Nudge-Panel buttons + knob therefore behave like a true cam-track shift — the rendered audio/video moves the way the user expects. OptionsPanel grows a "Selected pill" section that shows live arr + source bounds and a RESET button, enabled only when the pill differs from its originals. RESET pushes a history snapshot so undo can reverse it. Timeline header grows UNDO / REDO buttons next to the zoom readout. They use `pillHistory` / `pillFuture` state and disable themselves when the relevant stack is empty. No keyboard shortcut. 860/860 unit tests pass; lint clean. Visual verified via Chrome — MATCH mode shows hot-orange candidate ticks on each cam lane, UNDO/REDO buttons render disabled at start (no edits yet), and the per-pill Reset section renders inside OptionsPanel only when a pill is selected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Long-form triage workflow is shipped — the running plan that drove this branch lives in commit history now. PRs / READMEs are the right places for forward-looking docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…phase, reset UX
Replaces the half-baked pill undo/redo stack with the older Reset
mechanism the user expected: a per-pill floating ↺ button (canvas
overlay on dirty pills) plus the lane-header ↺ that already existed,
extended to detect pill-dirtiness instead of only cam-level state.
The undo/redo store + buttons + test suite are gone.
BeatRuler is mounted unconditionally again — the previous arr-mode
guard (`{!isArrMode && (…)}`) hid the bar grid in long-form jobs.
`effectiveBeatPhaseS` now takes the arrangement segments so beat 1
anchors on the FIRST chunk's `audioStartMs` (chunk-level field
already persisted) instead of `jobMeta.bpm.phase`, which is wrong
when the front of the arrangement is a chunk with leading silence.
`Segment` carries `audioStartMs` + `chunkId` to thread that through.
Same-cam pills no longer overlap: `setPillArrPlacement` /
`setPillLeftEdgeArrStartS` / `setPillRightEdgeArrEndS` clamp on
neighbour bounds in the store, and the body/trim drag handlers add
edge-to-edge snap (~6px threshold) so pills magnetically attach.
Trim-in / trim-out now run through `snapped()` like the body drag,
so grid-snap and MATCH work on the edges too.
SyncTuner branches on selectedPillId — knob + nudge buttons drive
pill.sourceInS via a new setPillSourceOffsetMs setter (and existing
nudgePillSourceMs) when a pill is selected. Header reads
"Sync · Cam X · Chunk N" and the knob label flips to "PILL OFFSET"
in pill-mode; "RESET PILL" replaces "RESET TO ALGO".
Selected-pill highlight is stronger: linewidth 2→3, shadow blur
6→12 with full cam-color, top stripe 3→5px on the selected slice.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…rkers, lock, playhead
Six interaction bugs surfaced during browser verification of the
prior polish pass.
Wheel + pinch zoom-anchor was computed in master-time (`xToT`) but
the canvas axis runs in arr-time when an arrangement is active. The
domain mismatch made the next-frame `viewStart` land outside the
clamped scroll range, pinning the scrollbar to the right edge. Fixed
by anchoring on the view-space time at the cursor instead.
Pill hit-test promoted body- and edge-zones with the same
`HANDLE_HIT` reach, so back-to-back chunks fought over their shared
boundary and the click landed on the wrong neighbour. Reworked into
two passes: (1) strict body hit — whichever pill the cursor pixel
actually sits inside wins, with edge grips tapered on tiny pills so
a 12-px chunk still has a body zone; (2) gap-hit fallback that picks
the nearest edge within `HANDLE_HIT` only when the cursor sits in a
real gap.
`drawVideoLane` was promoting `clipSelected` (= the cam panel-routing
selection) to a lane-wide highlight, lighting up every same-cam pill
when one was selected. Pill selection is now the only highlight unit
on the canvas; the cam-level selection still drives the side-panel.
Lock-on used to suppress pill clicks entirely, leaving the SyncTuner
+ OptionsPanel without a way to target a chunk while LOCK was the
default scrub mode. Selection now always works under LOCK; the drag
setup is the only thing the lock disables.
Match markers + the readout regressed during the earlier multi-pill
refactor: `drawMatchMarkers` was gated behind `snapMode === "match"`
and `ActiveMatchReadout` was passed `camId={null}`. Restored to the
main behaviour — markers always visible, emphasised in MATCH mode,
and the readout follows `selectedClipId`.
Playhead rendered with a raw float `xp` while the BeatRuler's bar
tick used `Math.floor(x)`, so the 1.5-px odd-width stroke smeared
into the next column and read as 1-2 px right of the bar mark.
Snap the playhead x to `floor(x) + 0.5` so the stroke lines up with
the integer-pixel bar tick.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… axis `snapTime()` was being handed a master-time `t` but using an arr-time beatPhase as the grid anchor. The two domains diverge whenever the arrangement re-orders or skips chunks, so snap=1 visibly landed the playhead between bar marks even though the math was internally consistent for each side. Project the master-time into arr-time (`masterToView`), snap there, then project back (`viewToMaster`) — the BeatRuler, the playhead, and the snap target now all live on the same arr-time axis the user sees on screen. Direct-mode is unchanged (the projections are identity when there are no arrangement segments). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…g snap
Five small extractions across the editor surface — no behavioural
change, all 856 unit tests green, tsc clean.
`isPillDirty(p)` (arrangement-pills.ts) — the four-field baseline
comparison used to decide whether a pill needs a reset-button on the
canvas, the lane-header ↺, or an enabled "Reset pill" in the options
panel. Inlined four times before; one definition now.
`mutatePill` / `mutatePillsForCam` / `mutateClip` (store.ts) — the
`array.map(x => x.id === id ? fn(x) : x)` pattern was repeated in
~15 setters across pills + clips. Plus shared `restorePillBaseline`
and `shiftPillSource` for the reset / nudge flows that all walked
the same field-by-field shape.
`PILL_MIN_WINDOW_S` + `clamp(x, lo, hi)` constants in store + Timeline
so the trim/move setters stop hand-rolling `Math.max(lo, Math.min(hi,
x))` chains and the magic 0.05 lives in one place.
`neighbourEdges(pills, myId, myCamId, side)` + `snapToNearest(t,
candidates, threshold)` (Timeline.tsx) — the magnetic-snap logic
that runs during pill-move / pill-trim-in / pill-trim-out. The three
drag handlers were duplicating an O(n) edge sweep with subtly
different filters; now they all share the same primitives and the
filter ("ends" for trim-in, "starts" for trim-out, "all" for body)
is the only difference.
`videoLaneAt(y)` (Timeline.tsx) — single source of truth for "which
video lane is the cursor over". `findClipAt`, `findLaneAt`, and
`findPillAt` all built on the same `for-i / band-y-check` loop;
`findLaneAt` is now an alias.
`drawVideoLane` lost the `clipSelected` param entirely — since the
highlight-chaos fix it was always being passed `false` from the only
call site. Dead surface area gone.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Lets the user zoom deep enough to read sub-beat / ms-level detail on long-form arrangements where the whole song is 7+ minutes wide. At 1024× the visible window collapses to ~0.4 s on a 7-min job, which is the regime where edge-snap to a single bar tick or a sample-level sync nudge actually becomes interactive. `MIN_ZOOM` / `MAX_ZOOM` constants in Timeline replace the inline 64 literals in both wheel-zoom and pinch-zoom; `setZoom` in the store matches the new ceiling. clamp() handles the math. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… handoff Triage flips `chunk.accepted` directly on the chunks list but doesn't reach into the persisted arrangement. A chunk the user accepted in an earlier session, dropped now, would still ride into Arrange (and from there into the editor) as a stale `ArrangementItem` — what the user described as "doubled chunks, including ones I'd dropped". Two reconciliation points so neither path can leak stale items: 1. `continueToArrange()` (Triage.tsx) — was pure-additive: it merged newly-accepted chunks into the existing arrangement but never pruned items pointing at chunks the user had since rejected. Now prunes first, then appends. 2. `Arrange.tsx` mount — the DB might still hold a stale arrangement from before this fix, or from a path that bypasses continueToArrange entirely (deep link, refresh). Filter the loaded arrangement against the live accepted-set on every mount and persist the divergence so we don't re-prune the same items forever. The first-time-seed path is now gated on `!wasPruned` so an arrangement the user has actively curated to empty doesn't get re-seeded with every accepted chunk on the next mount. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…hunk ends Two related fixes that together enforce the user's mental model "step back, change something → everything downstream regenerates." useTriagePersist: a real chunk mutation (split / merge / accept / re-chop) now writes `arrangement: []` and `pills: []` alongside the chunk update. The Arrange page + the Editor re-seed from the new chunk set on their next mount instead of dragging stale arrangement items + pills with bounds that no longer match the chunks they reference. The very first chunks-change after mount is the `initFromJob` hydration and is gated out so opening Triage doesn't itself wipe the existing arrangement. useArrangePersist: same gate, one level down — any genuine arrangement mutation drops the persisted `pills`. The Editor reconciles fresh from the current arrangement, so adding or re-ordering chunks in Arrange shows up cleanly. This replaces the surgical "reconcile stored against fresh" logic that was leaking stale arr-times whenever Triage re-chopped chunks under previously-persisted pills (the "doubled and offset chunks in editor" report). The arr-mode mount-time prune in Arrange.tsx stays as a defence-in-depth — DBs from before this fix may still hold stale items that the new persist path wouldn't have written. chunk-detect: detected chunks now have their `endMs` snapped down to the nearest whole-bar boundary anchored on `audioStartMs` (= the chunk's first detected downbeat). Chunks already start on a downbeat by construction; snapping the end too means the default Triage output is fully bar-aligned and the user can hit "continue" without hand-trimming every chunk to the rhythm. Skipped when bpm is unavailable, when the chunk is shorter than one bar, or when the snap would collapse it below half a bar (defensive). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two related render-failure fixes after the Triage→Arrange→Editor workflow report. The pill-mode video render computed source-time as `pill.sourceInS + (tArr - pill.arrStartS)` and handed it to `CamFrameStream.frameAtOrBefore` unclamped. A pill whose `sourceOutS` (or rounding-error in the arr-mode tArr accumulation) nudged the requested timestamp past the cam's `sourceDurationS` would surface the underlying VideoDecoder error as a context-free "Decoding error" — exactly the failure the user saw on render. Source-time is now clamped to `[0, sourceDurationS - 1/fps]` before the decoder lookup so the last valid frame is always reachable. Both decoder-error paths (single-cam editRender, multi-cam editRenderMulti) now wrap the native error with the breadcrumbs we have at hand: cam id, source / arr / master timestamps, frames- emitted, codec + dims. Same "Decoding error" surface in the UI now points at the actual input (which cam, where in the timeline) instead of swallowing the context whole. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The pill-mode render path (= the long-form arrangement render) ran the encode loop with only `setTimeout(0)` every 8th frame as "backpressure" — that's a microtask yield, not real flow control. The single-cam path has a proper `while (encoder.encodeQueueSize > 16) await sleep(1)` guard; the multi- cam path was missing it entirely. Symptom from the wild: rendering a 3-min cut from a 15-min / 9 GB-source job spiked the browser to ~33 GB RAM on a 16 GB machine and killed the tab. At 4K each VideoFrame is ~12 MB; with no backpressure the per-frame loop pushes raw frames into the WebCodecs encoder faster than the encoder drains them, and the queue depth grows without bound. A few seconds of overflow runs straight into multi-GB territory. Fix: same `encodeQueueSize > 16` gate the single-cam path uses, right after every `pushFrame`. Matches HW encoder pipeline depth (~4 frames) with headroom; the 1 ms sleep yields the event loop so the encoder's output callback fires and frames drain. `useMultiCam` selects this branch whenever pills.length > 0, so this fix applies to every long-form render — even single-cam jobs that go through the pill renderer. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replaces strict linear-forward decode with a sample-table-indexed pull
that auto-seeks to the nearest keyframe ≤ target on backward jumps and
forward jumps > 2s. Eliminates the multi-minute slowdown when pills
land late in a long source — previously the stream had to decode the
entire prefix from sample 0 just to satisfy a target near the end.
- new seekTo(targetUs): finds last isKey sample with cts ≤ targetUs,
flushes/closes/reconfigures the decoder, drops pending frames, resumes
feeding from that keyframe.
- frameAtOrBefore auto-seeks based on lastTargetUs:
- delta < 0: always seek (linear stream cannot serve backward).
- delta > SEEK_FORWARD_BUDGET_US (2s): seek (cheaper than decoding
thousands of unused frames).
- first call past budget vs. t=0: seek instead of decoding from start.
- consumes sampleTable + loadSample(idx) directly; no more samplesIter.
- new fixture video-multi-keyframe.mp4 (6 keyframes @ 1s GOP) + 8
cam-frame-stream.browser.test.ts cases covering monotonic forward
(regression), explicit seekTo, and auto-seek triggers.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Composite + encode now run in a Promise chain off the main per-frame
loop. While the chain processes frame N (await compositeImage + push to
encoder), the main loop pulls frame N+1 (await frameAtOrBefore — decoder
runs ahead inside CamFrameStream). Three stages — decoder, compositor,
encoder — run nebenläufig instead of strictly serial.
- New `outputQueue: Promise<void>` chain (same pattern as the single-cam
editRender), captures source + outTs + isFirstInSeg per iteration.
- VideoFrame ownership: stream-owned frames cloned via
`new VideoFrame(frame, { timestamp })` (cheap reference clone) so the
chain holds a live ref past the next frameAtOrBefore call.
- Backpressure on `encoder.encodeQueueSize > 16` (existing) plus a new
`chainInFlight > 4` guard so queued compositor work doesn't blow RAM
when the GPU is the slow stage.
- pendingError funnel + final `await outputQueue` before encoder.finish.
Cam switching is handled transparently by the GOP-aware seek added in
the previous commit — each cam's CamFrameStream auto-seeks on backward
or large-forward jumps in source-time.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previously the StreamingVideoEncoder accumulated every encoded chunk in a `chunks: EncodedVideoChunkRecord[]` array until finish(); the renderer then iterated that array into the muxer. For a 30-min 4K render at 50 Mbps that's ~11 GB held in RAM mid-render — guaranteed tab crash. Now: - StreamingVideoEncoder accepts an optional `onChunk` callback; when provided, encoded chunks are pushed straight through and NOT retained internally. Backwards-compatible: callers without onChunk get the old batch behavior (chunks array populated by finish()). - editRenderMulti constructs the muxer EARLY (before the frame loop), pushes the pre-encoded audio chunks immediately, and wires the video encoder's onChunk to muxer.addVideoChunkRaw with lazy meta init from the first chunk's description. No more post-render mux loop. - New `encoder.codec` and `encoder.muxerCodecKey` getters so the muxer can be configured up-front without waiting for finish(). End result: video encoder.chunks RAM is now constant in render duration. With Step F (audio streaming) this completes the constant-RAM goal. New browser tests in edit.browser.test.ts exercise editRenderMulti's pill-mode + multi-cam paths end-to-end through the streaming muxer. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
editRenderMulti's audio path no longer: - builds an intermediate trimmed-PCM Float32Array (~700 MB worst-case for 30-min stereo 48k via the old applySegments call), and - accumulates encoded chunks in a chunks-array (~50-200 MB worst case pre-streaming). Both gone. Audio now goes straight: input PCM → segment-walking encoder loop → encoded chunk → muxer, with bounded per-AudioData buffers (8 KB at 1024-frame stereo) regardless of total audio length. - New `streamEncodeAudioWithSegments` in audio-encode.ts: walks segments inline at sample granularity, allocates only per-encoder-frame Float32Arrays, pushes encoded chunks through `onChunk`. Returns metadata only — no chunks list. - editRenderMulti restructured: muxer constructed BEFORE audio encode (audio config is statically known); encoder.onChunk wires straight to muxer.addAudioChunkRaw with description filled from first chunk's metadata. - After audio encode, `audio = null` releases the input PCM reference so the worker doesn't keep ~700 MB live across the video render. Combined with Step E this completes the constant-RAM goal for editRenderMulti: video chain queues + audio per-frame buffer + muxer/encoder state. Total bounded under ~500 MB regardless of source length, output length, or audio length. Note: the legacy `encodeAudioFromPcm` (used by single-cam editRender + quickRender) is kept unchanged with its try-then-fallback behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The worker had a useMultiCam branch that picked between editRender (single-cam) and editRenderMulti based on cams.length / cuts.length / pills.length. Production-wise the multi-cam path is the only one that matters now — every job from triage→arrange→editor carries pills, so the single-cam branch was dead production code. This commit: - Removes the legacy `videoSource` field on EditWorkerInput. No callers outside the worker referenced it; jobs.ts already passes `cams`. - Drops the useMultiCam branch — the worker now always calls editRenderMulti, including for the 1-cam, no-cuts, no-pills case (handled by activeCamAt's fallback to the first cam-with-material). - editRender (single-cam, video-file API) stays in edit.ts for the format-matrix + edit.browser tests, but nothing in the production worker path uses it any more. New browser test exercises the 1-cam-no-pills route end-to-end through editRenderMulti so the worker's now-only path is regression-covered. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
End-to-end check: a 2-cam × 5-pill × 2-segment job renders to a valid MP4 with the right cam on PROGRAM at every output timestamp. Uses solid-red and solid-blue cam fixtures so a single centre-pixel sample of any output frame disambiguates which pill was active. Validates simultaneously: - Container is parseable, has both video + audio tracks. - Video duration = sum(segment lengths) within frame-rate granularity. - A/V durations align (Δ < AAC frame quantization). - Audio frequency matches input tone (880 Hz → 880 zero-crossings/sec). - Pixel-exact cam routing at 4 sample timestamps spanning both segments and 4 different pills, including a backward source-time seek (Pill 1 source 3..4 → Pill 2 source 0..1). Documents an easy-to-misread invariant: segments cut master-time, arr-time runs continuously through the output (consistent with masterToArr). Pills are addressed by arr-time, not master-time, so a pill at arr [2..3) STILL plays even when master [2..3) is segment- trimmed — its content is sourced from the second segment's master window instead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a per-chunk Conform action that re-fits the bar-grid anchor from
the chunk's current audio (via the same first-onset detection initial
detection uses), with an Original button to undo. Plus collateral fixes
to anchor handling around split, plus auto-follow + visual anchor in
the timeline.
What's new
- Conform action (`conformChunk` in triage-store) — runs `analyzeAudio`
on the chunk's PCM slice, takes its `audioStartS` as the bar-grid
anchor, snaps `endMs` to whole bars from that anchor. Trims leading
silence to the first onset when one is detected; never cuts past the
first onset.
- Original button — restores the chunk to its pre-Conform state via
`revertConform`. The pre-conform bounds are stashed in a new
`Chunk.preConformSnapshot` field. Snapshot is cleared on
split/join/extend/reset so the undo target never goes stale.
- Idempotence — re-running Conform on a chunk that already has a
snapshot is a no-op (`unchanged` status). The analyzer's STFT frame
quantization wobbles by ~46 ms on shifted slices, which without the
guard would chip away at the chunk a sliver per click.
- Visible status — inline message under the button shows `✓ conformed
· anchor +N ms, in +N ms, out -N ms` on success (brass), `already in
phase` on no-op, and the actual decode reason on failure (red).
Button is disabled while STFT runs (yields once via setTimeout so
React paints the disabled state before the synchronous work).
Split anchor fix
`splitChunkAt` previously set the right half's `audioStartMs` to
`splitMs` (the click point). With BPM known, both halves now compute
their anchors as bar boundaries of the original grid that lie inside
their own range — splitting a coherent take preserves rhythm in both
halves without re-detection.
UI polish
- Inspector top stats compacted into a single wrapping line (`IN ·
OUT · LEN · BARS · ANCH`) so the EDIT block has room.
- Auto-follow: changing the focused chunk pans the timeline to keep
the chunk visible. Suppressed when the focus change came from a
click on the timeline itself (capture-phase pointer-down ref).
- Brass "1" anchor flag in the bar ruler at `audioStartMs` of the
focused chunk — only visual cue for where the grid is anchored.
Plumbing
- `chunk-bar-grid.ts` — pure helpers (`MIN_CHUNK_MS_FOR_BPM`,
`snapChunkEndToBar`) extracted from `chunk-detect.ts` so the
triage-store can import them without dragging in the WASM
dynamic-import t
8
hat brea
AE6A
ks unit tests.
- `pcmDecoding` + `pcmDecodeError` flags in the store. The cached
Triage path decodes PCM in the background; Conform waits on the
flag instead of bailing with "no audio loaded". Decode failure
surfaces the actual reason instead of the generic message.
- Triage decode promise gates store updates on `jobId === decodeJobId`
rather than the closure `cancelled` flag — `setDetection({ kind:
"ready" })` re-runs the effect mid-decode and would otherwise leave
the late-arriving PCM stranded.
- `analyzeAudioFixedBpm` exported (currently unused by Conform — kept
for potential future use, has its own tests).
- `snapChunkEndToBar` and the conform start-snap apply a tiny FP bias
before `floor`/`ceil` so chunks at non-power-of-two BPMs (180 →
1333.33 ms/bar) don't shed a bar to floating-point round-off.
- `Chunk.audioStartMs` JSDoc clarified — it's a bar-grid phase
anchor, not a literal audio start.
Tests: +43 unit tests across analyze.test.ts, triage-store.test.ts,
triage-auto-follow.test.ts. 887 total green, lint clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…hemeral ops
The persisted `JobStatus` enum (queued → syncing → synced → rendering →
rendered → failed) drifted from the data-driven phase derivation in
`jobs-routing.ts` and produced a concrete bug: navigating from history
into Triage on a `rendered` job hit a `status !== "synced"` gate and
showed "Waiting for sync to complete" forever, even though the sync
result was sitting in IDB.
Architecture:
- `LocalJob` is pure data now — `status`, `progress`, `error`,
`hasOutput`, `outputBytes`, `startedAt`, `finishedAt` are gone. A new
`lastRender?: { completedAt; outputBytes }` field replaces the
hasOutput/outputBytes pair as the persistent "this job has produced
output" signal.
- New in-memory `useOpsStore` (Zustand) carries transient progress for
the running sync/render. Cleared on tab reload by design — there's
nothing to "mark interrupted" anymore.
- Phase derivation stays in `jobs-routing.ts` (data-only). Triage no
longer gates on a lifecycle bit; it simply checks whether the master
cam has a sync result.
- IDB schema bumped 7 → 8 with an in-place upgrade that strips the old
fields off existing rows and synthesizes `lastRender` from
`hasOutput` so prior renders aren't forgotten.
Behavior:
- Render → History → Triage now loads instantly.
- Backward navigation from any phase is unconditional — no status gate
to fail.
- A render that finishes drops its op into a `done: true` terminal
state until the screen unmounts; failure stamps `error` on the op
without touching the job row.
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
This PR brings the long-form session workflow to
main(Triage → Arrange → Editor → Render) plus a final architectural pass that replaces the legacyJobStatuslifecycle with data-driven phases and an in-memory ops store.The headline change vs.
feat/long-form-triage-workflow: the persistedJobStatusenum (queued → syncing → synced → rendering → rendered → failed) drifted from the data-driven phase derivation and produced a concrete bug — navigating from history into Triage on arenderedjob hit astatus !== \"synced\"gate and showed "Waiting for sync to complete" forever, even though the sync result was sitting in IDB.Architecture, post-refactor
LocalJobis pure data.status,progress,error,hasOutput,outputBytes,startedAt,finishedAtare gone. NewlastRender?: { completedAt; outputBytes }replaces the hasOutput/outputBytes pair as the persistent "this job has produced output" pointer.useOpsStore(Zustand) carries transient progress for the running sync/render. Cleared on tab reload by design — there's nothing to "mark interrupted" anymore.jobs-routing.ts(data-only). Triage no longer gates on a lifecycle bit; it checks whether the master cam has a sync result.lastRenderfromhasOutputso prior renders aren't forgotten.What lands besides the refactor
The full feature branch — long-form Triage screen, Arrange, multi-pill editor, parallel render pipeline with streaming muxer, GOP-aware seek, audio-volume bake, FX (vignette/wear/echo/rgb/tape/zoom/uv) with ADSR envelopes, OP-1-style loop transport, brass-plate BPM controls, multi-cam Triage with chunk detection + Conform action, etc. 70 commits over the parallel-workflow arc.
Behavior wins from the final pass
done: trueterminal state until the screen unmounts; failure stampserroron the op without touching the job row.Test plan
lastRenderupdates only on success.hasOutput: truecome through withlastRendersynthesized.pnpm test(897/897 unit tests green locally).🤖 Generated with Claude Code