8000 feat(longform): non-destructive stage transitions with diff-aware propagation + confirm dialogs by johannboehme · Pull Request #46 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

feat(longform): non-destructive stage transitions with diff-aware propagation + confirm dialogs - #46

Merged
johannboehme merged 1 commit into
mainfrom
claude/blissful-booth-051a4f
May 10, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/blissful-booth-051a4f

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

  • Replaces the longform workflow's "wipe arrangement+pills on any chunk dirty" pattern with ID-aware diff propagation: a Triage edit prunes only the arrangement items whose chunk vanished, and the Editor's existing reconcilePills handles pill geometry refresh on its own. User-edited cuts/FX/pills survive Triage tweaks instead of disappearing silently.
  • Adds ConfirmDialog gates in the spots where genuinely destructive transitions remain (reject in-use chunk, split with arrangement usage, merge of isolated chunks, delete arrangement item with editor edits, remove cam with cuts).
  • Fixes a quiet bug in DetectionPanel where slider re-detection generated fresh chunk IDs and could empty the arrangement; chunk IDs now round-trip across re-detection.

Why

Pre-change, navigating back from the Editor to Triage and tweaking a single chunk silently destroyed the entire arrangement and every editor edit. The Editor already had a robust ID-stable reconcilePills merge — it was just being short-circuited by an upstream wipe. The fix is to let the merge do its job and only ask the user before truly destructive operations (everything else propagates silently).

Action matrix (all confirmed by user during planning)

Triage

Action In arrangement? Behavior
Add chunk n/a Silent — appears in Polaroid pool, not auto-inserted
Trim chunk (start/end/audioStart) yes/no Silent — pills reconcile geometry
Reject chunk no Silent
Reject chunk yes Confirm with item/cut/FX counts
Re-Accept (previously rejected) n/a Silent — pool only, no auto-restore to old positions
Split chunk no Silent
Split chunk yes 3-way pick: Replace A / Replace B / Both A→B / Cancel
Merge chunks (always adjacent) yes Silent — collapse adjacent pairs
Merge chunks (isolated occurrences) yes Confirm: Replace all / Cancel merge entirely
silenceConfig slider irrelevant Silent — IDs preserved across re-detection

Sync

Action Editor edits? Behavior
syncOverrideMs nudge / Re-Sync irrelevant Silent — chunks live in master-time
Cam remove no Silent
Cam remove yes (cuts/userEdited pills) Confirm with counts

Arrange

Action Editor edits? Behavior
Reorder irrelevant Silent
Insert from pool n/a Silent
Duplicate irrelevant Silent — pills/cuts/FX cloned with timeline-shifted ranges
Delete item no Silent
Delete item yes Confirm with counts

Implementation notes

New pure helpers (all unit-tested)

  • frontend/src/local/edits-impact.ts — counters: countEditsAffectedByChunkRemoval / ByItemRemoval / ByCamRemoval, plus isAlwaysAdjacentInArrangement.
  • frontend/src/local/triage/diff-arrangement.ts — propagateTriageChangesToArrangement(prevChunks, nextChunks, arrangement). Removes items whose chunk is gone or rejected; preserves identity when nothing changed (so the persist-hook fingerprint stays cheap).
  • frontend/src/local/triage/triage-arrangement-ops.ts — applySplitToArrangement(...) and applyMergeToArrangement(...). Pure transforms invoked after the Triage store mutation lands.

Imperative dialog API

  • frontend/src/lib/confirm.ts — confirmDestructive / chooseSplitReplacement / confirmMergeReplaceAll push requests onto a tiny zustand store; await the Promise.
  • frontend/src/components/ConfirmDialogHost.tsx — single-mount modal renderer. Esc cancels; Enter confirms (destructive flavour only). Backdrop click cancels.

Guarded action wrappers

  • frontend/src/local/triage/triage-guarded-actions.ts — rejectFocusedGuarded, splitFocusedGuarded, joinFocusedGuarded. Wired into TriageTransportBar (keyboard shortcuts + Drop button) and ChunkInspector (Split / Join prev / Join next).
  • frontend/src/local/arrange/arrange-guarded-actions.ts — removeItemGuarded (counts-aware confirm + IDB pruning), duplicateItemWithEdits (clones pills/cuts/FX onto the new item with timeline-shifted ranges).

Minimal call-site changes

  • useTriagePersist.ts — wipe replaced with propagateTriageChangesToArrangement. No more pills: [].
  • useArrangePersist.ts — pills: [] wipe removed entirely.
  • DetectionPanel.tsx — re-detection merge now keeps prev.id (no 8000 t just prev.accepted) so a small slider tweak doesn't quietly empty the arrangement.
  • LaneHeader.tsx — drops window.confirm; the count-aware confirm now lives in Editor.tsx's onDeleteClip so it can read pills/cuts/fx.

Verification

  • npx tsc -b ✓
  • npx vitest run --project=unit → 1010/1010 pass (26 new tests across edits-impact, diff-arrangement, triage-arrangement-ops).
  • Dev server boots clean.

Test plan

  • Happy-path silent propagation: Sync → Triage (accept chunks) → Arrange (reorder + duplicate) → Editor (cuts + FX). Back to Triage, reject an unused chunk → no dialog. Cuts and FX unchanged.
  • Reject in-use: reject a chunk that appears 2× in arrangement → dialog with counts. Cancel keeps everything; Confirm prunes items + their pills/cuts/FX.
  • Trim propagation: trim a chunk's range in Triage → Editor pill arrEndS reflects new geometry; userEdited pills keep their sourceOut edits.
  • Split with usage: split a chunk that's in the arrangement → SplitDialog appears. Test all 3 modes individually (A only, B only, Both A→B).
  • Merge adjacent → silent: two chunks always adjacent → no dialog, items collapse to one.
  • Merge isolated → MergeDialog: two chunks not adjacent → dialog → Cancel aborts the entire merge (chunks A and B unchanged).
  • Re-Accept ≠ Auto-Restore: reject (with confirm) then re-accept → chunk back in Polaroid pool only, NOT back in FilmStrip.
  • Duplicate copies edits: duplicate an item with cuts/FX → new item gets cuts/FX clones at shifted timeline positions.
  • Cam removal silent if untouched: cam without cuts/FX → no dialog. With cuts → dialog with counts.
  • Re-Sync silent: tweak syncOverrideMs / re-run sync → no dialog; pills shift automatically.
  • Slider re-detect: small threshold tweak that produces matching chunk geometry → arrangement unchanged (id-preservation working).

🤖 Generated with Claude Code

…pagation + confirm dialogs

Replaces the "wipe arrangement+pills on any chunk dirty" pattern with
ID-aware diff propagation: a Triage edit prunes only the arrangement
items whose chunk vanished, and the Editor's existing reconcilePills
handles pill geometry refresh on its own. User-edited cuts/FX/pills
survive Triage tweaks instead of disappearing silently.

Confirm dialogs gate the genuinely destructive transitions:
- Reject chunk in arrangement: confirm with item/cut/FX counts
- Split chunk in arrangement: 3-way pick (Replace A / B / Both A→B)
- Merge chunks isolated in arrangement: replace-all or cancel merge
- Delete arrangement item with editor edits: confirm with counts
- Remove cam with cuts/userEdited pills: confirm with counts

Adjacent-merge collapses silently. Duplicate copies pills/cuts/FX onto
the clone with shifted timeline ranges. DetectionPanel now preserves
chunk ids on slider re-detect so an arrangement is no longer quietly
emptied by a small threshold tweak.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@johannboehme
johannboehme merged commit df3d5c7 into main May 10, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/blissful-booth-051a4f branch May 10, 2026 11:54
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.

1 participant

0