You are creating an implementation plan for the following idea.
code
Idea:
Roll back the "first-class shot groups with projection layer" architecture introduced in a previous megaplan. Replace it with a simpler "shot group is a soft tag, cohesion is enforced by edit operations" model. The current projection-based architecture has produced a recurring class of bugs that we cannot fix incrementally — every patch surfaces another bug because the underlying model is wrong. This refactor eliminates the entire bug class structurally.
Why (the structural problem)
The previous "first-class shot groups" megaplan introduced a pinnedShotGroups[i] = { shotId, trackId, start, children: [{clipId, offset, duration}], clipIds, mode, ... } data shape. Cohesion is enforced by re-deriving clip positions from pinnedShotGroups[].children via projectPinnedShotGroups, which runs three times per commit cycle (inside resizeGroupEdge, inside applyEdit, and inside buildDataFromCurrentRegistry via repairConfig).
This is "cohesion by re-projection," which means:
Two parallel data shapes for the same thing. pinnedShotGroups[i].children[j].duration vs clips[k].hold. Any edit that bypasses the projection (a free-clip resize fallback, a stale closure, a missing prop) gets silently reverted because the next projection re-derives from children.
Auto-save fires during drags and drops pointer capture. The save round-trip causes a re-render mid-drag, which can drop pointer capture, which fires a fresh pointerdown on whatever's under the cursor — breaking one user gesture into multiple resize sessions.
The prop chain has 8 hand-offs for startGroupEdgeResize. Any one can drop the prop silently because TypeScript widens object literal types to satisfy the interface even when fields are missing. We just hit one (VideoEditorProvider.tsx was missing the field, surfacing as "snaps back to full shot length").
resizeGroupEdge has wrong semantics — it scales every child of the group proportionally when you drag an outer edge. Users expect: drag the right edge of the last clip → only that clip's duration changes. The current code shrinks every clip in the group.
Three different views of the same data (PinnedShotGroup → ShotGroup → PositionedShotGroup), each with its own filter that can drop the group from view, each with its own slightly different fields.
This entire conversation has been bug → fix → bug → fix for hours. Each fix passes type-check and tests. That's not a quality problem; it's a sign the model is so loose that structural bugs pass all the gates we have. The right answer is to stop patching and rebuild the model.
The new model
Cohesion is a property of edit operations, not data shape.
Assistant
User
Assistant
Using megaplan planning workflow as the relevant skill again. The CLI cannot write in this sandbox, so I’m revising from direct repo inspection and the gate feedback, starting with the flagged ownership and caller paths.
Assistant
The gate is pointing at completeness, not a different root cause. It still agrees the projection layer is the wrong model; the missing pieces are the ownership bridges and the alternate caller paths that still keep projection alive. I’m checking those concrete branches now so the revised plan names the real insertion points instead of hand-waving them.
Assistant
Data
pinnedShotGroups[i] = {
shotId: string;
trackId: string;
clipIds: string[]; // ordered left-to-right by current spatial position
mode?: 'images' | 'video';
videoAssetKey?: string;
imageClipSnapshot?: ...;
}
That's it. No start, no children, no offset, no duration on the group. The clips themselves carry all position/duration data via clips[k].at / clips[k].hold (or from/to/speed). One source of truth: the clips.
Operations
Every user operation that touches a clip in a group is implemented as a direct clip mutation that preserves group cohesion intentionally:
Drag clip body in a group → All clips in the group → Translate every clip in the group by the same delta. Already implemented in useClipDrag via deferred expansion — keep that pattern.
Resize first clip's LEFT edge → First clip only → Change the first clip's at (and hold/source-time accordingly). Group's left edge follows. Other clips unchanged.
Resize last clip's RIGHT edge → Last clip only → Change the last clip's hold/source-time. Group's right edge follows. Other clips unchanged.
Resize an interior boundary (between clip[i] and clip[i+1]) → Two adjacent clips → Trade duration between them: clip[i]'s hold changes, clip[i+1]'s at AND hold change so clip[i+1]'s right edge stays put.
Cross-track drag of a grouped clip → All clips in the group → All clips move to the new track preserving relative offsets. Update pinnedShotGroups[i].trackId.
Pin a new shot group → (creates the group) → Sort the selected clip ids by at ascending and store as clipIds.
Unpin / Deconstruct → (removes the group) → Just removes the entry from pinnedShotGroups. Clips are unchanged.
Delete shot → All clips in the group + the group entry → Delete the clips, remove the pin.
No proportional scaling. Every operation only touches the clips it semantically should.
Rendering
The shot border is a pure function of the clips' current positions:
function computeShotGroupRect(group, clips) {
const groupClips = group.clipIds.map((id) => clipById.get(id)).filter(Boolean);
if (groupClips.length === 0) return null;
groupClips.sort((a, b) => a.at - b.at);
const start = groupClips[0].at;
const end = groupClips.at(-1).at + clipDuration(groupClips.at(-1));
return { start, end };
}
No projection step, no validation pass that drops the group from view. If the clips are non-contiguous for some reason, render a degraded state but never silently lose the group.
Save gating
Block auto-save while a drag or resize session is active. interactionStateRef.current.resize || .drag already exists; gate the save scheduler on it. When the interaction ends, flush any pending save. This eliminates the "drag resets mid-gesture due to save round-trip" symptom.
Migration
Existing user data has the projection-shape pinnedShotGroups[i] = { ..., start, children: [...] }. The refactor must continue to load these correctly:
On load (in repairConfig or equivalent), if a group has start + children, derive the legacy clipIds from children.map((c) => c.clipId) and DROP the start/children fields. The clip positions are already correct in clips[] from the previous projection.
On save, only emit the new shape ({ shotId, trackId, clipIds, mode, ... }).
Add a migration test that loads a projection-shape config and verifies it converts cleanly.
What to delete (or simplify drastically)
These exist to support the projection model and should be removed or radically simplified:
src/tools/video-editor/lib/pinned-group-projection.ts — DELETE most of it. Keep maybe findEnclosingPinnedGroup (a useful lookup) and categorizeSelection. Delete projectPinnedShotGroups, resizeGroupEdge, resizeChildBoundary, replaceGroup, replaceGroupChildren, buildGroupFromChildren, buildGroupFromConfigClips, normalizeChildren, setClipTimelineDuration, moveGroup, getGroupDuration.
src/tools/video-editor/lib/pinned-group-projection.test.ts — rewrite to test whatever helpers remain.
src/tools/video-editor/lib/pinned-group-cohesion.test.ts — rewrite or delete.
src/tools/video-editor/hooks/useClipResize.ts — startGroupEdgeResize becomes "resize the last/first clip directly." resizeChildBoundary becomes "change two adjacent clips' durations." Both call existing applyEdit({ type: 'rows' }) instead of { type: 'pinnedShotGroups' }.
src/tools/video-editor/hooks/useTimelineCommit.ts — the 'pinnedShotGroups' mutation type can be simplified (no projection step), or removed entirely if all group operations now go through 'rows'.
src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx — the 'group-edge' and 'group-child-boundary' resize sessions can collapse into the regular 'clip' session, since they now just edit clip data directly.
src/tools/video-editor/contexts/VideoEditorProvider.tsx — the startGroupEdgeResize prop hand-off goes away.
src/tools/video-editor/hooks/useTimelineState.types.ts and useTimelineState.contexts.ts — drop TimelineShotGroupResize and startGroupEdgeResize from the context types and value.
src/tools/video-editor/hooks/useShotGroups.ts — simplify to just resolve clipIds to live actions and compute color/name. No start, no children, no rowIndex. Just { shotId, shotName, trackId, clipIds, color, mode }.
positionedShotGroups in TimelineCanvas.tsx — becomes a pure function of the live row actions instead of reading from group.start + child.offset.
Save gating implementation
There's an interactionStateRef: { current: { drag: boolean; resize: boolean } } ref already used by useClipDrag and useClipResize. Find where the auto-save is scheduled (probably useTimelinePersistence or the scheduleSave event listener) and gate it: if interactionStateRef.current.drag || interactionStateRef.current.resize, don't fire the save — defer it. Flush the pending save when the interaction ends (in endResize and clearSession).
Add a new edge case: if the user is interacting AND a poll-sync conflict comes in, defer the conflict resolution too (don't reload from server while the user is editing).
Files most likely to change
src/tools/video-editor/lib/pinned-group-projection.ts (delete most of)
src/tools/video-editor/types/index.ts (drop start/children from PinnedShotGroup)
All related tests
Hard requirements
Eliminate the recurring bug class. After this refactor, the following must work end-to-end:
Drag the right edge of the last clip in a shot → only that clip's duration changes; group's right end follows.
Drag the left edge of the first clip in a shot → only that clip's start/duration changes; group's left end follows.
Drag an interior boundary inside a shot → two adjacent clips trade duration; rest of group stays put.
Drag a clip body inside a shot → entire group translates together.
Drag the entire shot group across rows → all clips move to the new row, group's trackId updates.
Auto-save does NOT fire during a drag or resize gesture; it flushes when the gesture ends.
Poll-sync does NOT overwrite the user's in-progress edits.
All shot label menu actions still work.
Per-clip context menu lockdown still works.
Existing data loads correctly. A user with the projection-shape pinnedShotGroups[] in their saved state must continue to see their shots after the refactor. Migration is one-way: load → convert → save in new shape.
Remotion preview unchanged. Remotion reads from clips[]. Since clips are now the source of truth (no projection), the Remotion render is automatically correct.
Type-check passes. npx tsc --noEmit clean.
Tests pass. All 181 video-editor tests must continue to pass, OR be updated with clear justification when behavior intentionally changes. Add new tests covering:
The migration from projection-shape to soft-tag shape.
Each new edit operation.
Save gating during interactions.
Cohesion preservation through a sequence of operations.
Constraints
Scope is the video-editor tool only. No DB schema changes, no edge functions.
Follow CLAUDE.md rules. Prefer Edit over Write. No new docs unless necessary.
Don't bundle unrelated cleanups. Keep the diff focused on the projection rollback.
One pre-existing failing test (data-shot-group-kind="pinned" in TimelineCanvas test) is unrelated and can be left alone.
The diagnostic console.logs added in this conversation should be removed as part of this refactor.
Reuse useClipDrag's deferred expansion pattern as the canonical "operate on a group as a unit" pattern.
Success criteria
The two specific symptoms no longer reproduce.
tsc --noEmit clean.
All video-editor tests pass.
Code line count for shot-group-related files DECREASES net.
The Remotion preview renders the same output for an unchanged timeline.
Loading a saved file with projection-shape pinnedShotGroups[].children produces a correct visual on the timeline.
code
Project directory:
/Users/user_c042661f/Documents/reigh-workspace/reigh-app
No prior clarification artifact exists. Identify ambiguities, ask clarifying questions, and state your assumptions inside the plan output.
Requirements:
- If the engineering brief suggests an approach, use it as your starting hypothesis — but before committing, consider if there's a simpler or more fundamental fix. The brief is well-researched input, not a final answer.
- If the brief is absent, incomplete, or says "skip", inspect the repository yourself before planning.
- Produce a concrete implementation plan in markdown.
- Define observable success criteria as objects with `criterion` (string) and `priority` (`must`, `should`, or `info`):
- `must` — hard gate. The reviewer will block on failure. Use for correctness, functional requirements, and verifiable outcomes (e.g., "all existing tests pass", "API returns 200 for valid input"). Every `must` criterion must have a clear yes/no answer.
- `should` — quality target. The reviewer flags but does not block. Use for subjective goals, numeric guidelines, and best-effort improvements (e.g., "file under ~300 lines", "no deeply nested conditionals", "each function has a single responsibility").
- `info` — documented for humans, reviewer skips. Use for criteria that cannot be verified in this pipeline (e.g., "13 manual smoke tests pass", "stakeholder sign-off obtained").
- Use the `questions` field for ambiguities that would materially change implementation.
- Use the `assumptions` field for defaults you are making so planning can proceed now.
- Prefer cheap validation steps early.
- Keep the plan proportional to the task. A 1-line fix needs a 2-step plan (apply fix + run tests), not a 5-step investigation.
- If user notes answer earlier questions, incorporate them into the draft plan instead of re-asking them.
- Fix the problem fully. Do not limit scope just to avoid breaking existing tests — update the tests too if needed.
- Prefer the simplest, most direct fix. No fallbacks, type conversions, or defensive wrappers without concrete evidence they are needed.
- If the task or issue hints suggest a specific approach, follow it. Only deviate with concrete counter-evidence.
Plan template — simple format (adapt to the actual repo and scope):
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
{"plan":"# Implementation Plan: Roll Back Projection-Based Shot Groups To Soft Tags\n\n## Overview\nRepo inspection confirms the brief's diagnosis. projectPinnedShotGroups is still rewriting clip timing in src/tools/video-editor/lib/timeline-data.ts, src/tools/video-editor/lib/timeline-save-utils.ts, and src/tools/video-editor/hooks/useTimelineCommit.ts; grouped resize/preview behavior still depends on start and children in src/tools/video-editor/hooks/useClipResize.ts and src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx; and the old startGroupEdgeResize prop still crosses the context/provider chain. A smaller patch would keep two positional sources of truth alive, so the simplest structural fix is the rollback described in the brief: make clips[] the only source of timeline position/duration, reduce pinnedShotGroups[] to soft-tag metadata, and gate persistence while interactions are active.\n\n## Phase 1: Canonical Model And Migration\n\n### Step 1: Replace the persisted/runtime group shape with soft tags\nScope: Medium\n1. Update src/tools/video-editor/types/index.ts so PinnedShotGroup only contains shotId, trackId, clipIds, mode, videoAssetKey, and imageClipSnapshot.\n2. Add a single normalization path in src/tools/video-editor/lib/migrate.ts: if a loaded group still has legacy start plus children, derive clipIds from children.map(child => child.clipId), preserve metadata, and drop legacy fields before the config enters editor state.\n3. Remove projection from load/save assembly in src/tools/video-editor/lib/timeline-data.ts and src/tools/video-editor/lib/timeline-save-utils.ts so runtime data is built from migrated clips directly.\n4. Update cloning/repair helpers in src/tools/video-editor/lib/migrate.ts and src/tools/video-editor/lib/timeline-data.ts to stop fabricating start and children.\n5. Prove the migration first with focused coverage in src/tools/video-editor/lib/serialize.test.ts, src/tools/video-editor/lib/timeline-save-utils.test.ts, and migration-adjacent tests before changing UI behavior.\n\n### Step 2: Delete projection-era helpers and keep only lookup utilities\nScope: Medium\n1. Strip src/tools/video-editor/lib/pinned-group-projection.ts down to helpers that still make sense in the soft-tag model, likely findEnclosingPinnedGroup, categorizeSelection, and a small helper for ordering clipIds from live clips.\n2. Delete projection-only helpers such as projectPinnedShotGroups, resizeGroupEdge, resizeChildBoundary, moveGroup, replaceGroupChildren, buildGroupFromChildren, and buildGroupFromConfigClips, then update imports across hooks and tests.\n3. Rewrite src/tools/video-editor/lib/pinned-group-projection.test.ts around the remaining helpers and replace src/tools/video-editor/lib/pinned-group-cohesion.test.ts with soft-tag regression coverage instead of projection invariants.\n\n## Phase 2: Edit Operations Become The Cohesion Layer\n\n### Step 3: Rebuild grouped resize semantics as direct clip mutations\nScope: Large\n1. In src/tools/video-editor/hooks/useClipResize.ts, replace grouped resize commits so they always emit applyEdit({ type: 'rows' }) mutations against live row actions plus source-time metadata patches, never type: 'pinnedShotGroups' for timing changes.\n2. Implement the three required semantics explicitly: first clip left edge changes only that clip; last clip right edge changes only that clip; interior boundary changes only the dragged clip and its adjacent neighbor while keeping the outer boundary fixed.\n3. Reuse the existing free-clip source-time math where possible so timed media keeps current trim behavior instead of introducing a second grouped resize algorithm.\n4. Add focused tests for each operation and a sequence test that proves later edits are not silently reverted.\n\n### Step 4: Keep grouped drag as clip translation, not group projection\nScope: Large\n1. Update src/tools/video-editor/hooks/useClipDrag.ts and src/tools/video-editor/lib/multi-drag-utils.ts so grouped body drags and cross-track drags translate all member clips directly, reusing the current deferred expansion pattern as the canonical implementation.\n2. Change grouped cross-track moves to update only the moved clips plus the group's trackId and stored clipIds order when needed.\n3. Remove projection-specific overlap helpers from src/tools/video-editor/lib/resolve-overlaps.ts and any drag-result builders that still expect group extents.\n4. Extend src/tools/video-editor/hooks/useClipDrag.test.tsx and src/tools/video-editor/lib/multi-drag-utils.test.ts to cover same-row translation and cross-track group moves under the new model.\n\n### Step 5: Simplify group mutation entry points\nScope: Medium\n1. Collapse src/tools/video-editor/hooks/useTimelineCommit.ts so clip-timing edits stay on the rows path and group-only mutations are limited to pin/unpin/mode/track/clipId membership updates.\n2. Update src/tools/video-editor/hooks/usePinnedShotGroups.ts, src/tools/video-editor/hooks/useExternalDrop.ts, src/tools/video-editor/hooks/useSwitchToFinalVideo.ts, and delete paths in clip editing to create or mutate groups by clipIds only.\n3. Ensure pinning sorts selected clip ids by live at, unpinning only removes the group entry, deleting a shot removes grouped clips plus the group entry, and switch-to-video/images keeps imageClipSnapshot behavior without reintroducing group geometry.\n\n## Phase 3: Rendering And Context Simplification\n\n### Step 6: Render shot groups from live clip positions only\nScope: Large\n1. Simplify src/tools/video-editor/hooks/useShotGroups.ts to return display metadata plus live clipIds, without start, children, or projection-derived row state.\n2. In src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx, compute each group rectangle from current row actions for clipIds using earliest start and latest end rather than persisted group geometry.\n3. Remove startGroupEdgeResize from src/tools/video-editor/hooks/useTimelineState.types.ts, src/tools/video-editor/hooks/useTimelineState.contexts.ts, src/tools/video-editor/contexts/VideoEditorProvider.tsx, and src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx; resize handling should stay inside the regular clip session flow.\n4. Preserve degraded rendering when clips are missing or non-contiguous: render from whatever member clips still exist and never drop the group because a validation/projection step filtered it out.\n5. Update src/tools/video-editor/components/TimelineEditor/TimelineCanvas.test.tsx, src/tools/video-editor/components/TimelineEditor/TimelineEditor.test.ts, and src/tools/video-editor/hooks/useShotGroups.test.ts for the new render contract while leaving the unrelated pre-existing TimelineCanvas assertion isolated if it still remains.\n\n## Phase 4: Persistence Gating And Remote Sync Safety\n\n### Step 7: Block save and poll-sync work during active interactions\nScope: Medium\n1. Thread interactionStateRef or an equivalent shared ref into src/tools/video-editor/hooks/useTimelineSave.ts, src/tools/video-editor/hooks/useTimelinePersistence.ts, and src/tools/video-editor/hooks/usePollSync.ts so both save scheduling and poll application can check drag || resize.\n2. Change src/tools/video-editor/hooks/useTimelinePersistence.ts to queue the latest pending save while an interaction is active, skip the 500ms save fire during the gesture, and flush once clearSession or endResize clears the interaction flag.\n3. Change src/tools/video-editor/hooks/usePollSync.ts so incoming poll data and conflict reload/retry paths defer while an interaction is active, then re-evaluate the newest deferred payload after the gesture ends.\n4. Remove temporary sync/debug logging in the touched shot-group and timeline-sync files as part of this rollback.\n5. Add regression tests in src/tools/video-editor/hooks/usePollSync.test.ts plus new persistence tests for deferred save flush and deferred poll/conflict handling.\n\n## Phase 5: Feature Reconciliation And Verification\n\n### Step 8: Reconcile remaining shot-group features and run the safety net\nScope: Medium\n1. Re-test shot label menu actions, per-clip context-menu lockdown, external shot drop, and switch-to-final-video/image flows against the soft-tag model; patch any remaining children or start assumptions.\n2. Run cheap targeted checks first: migration/serialize/save-utils tests, then resize/drag/group tests, then persistence/poll tests.\n3. Finish with npx tsc --noEmit and the full video-editor suite; if the known unrelated TimelineCanvas assertion is still pre-existing, confirm it is the only non-regression failure.\n4. Compare line count and helper surface in the shot-group files to confirm the rollback actually removed projection machinery instead of wrapping it.\n\n## Execution Order\n1. Land the type and migration cleanup first so every later change works against one canonical shape.\n2. Rewrite edit semantics next in useClipResize, drag utilities, and commit flow before touching rendering.\n3. Remove the prop chain and projection-era rendering once runtime behavior is correct.\n4. Finish with save/poll gating, remaining feature reconciliation, and the broad verification sweep.\n\n## Validation Order\n1. Start with migration and serialization tests because they are the cheapest proof that old data still loads and new data saves in one shape.\n2. Run focused resize and drag tests immediately after each operation rewrite to catch semantic regressions before UI integration.\n3. Validate save/poll gating with targeted hook tests before the broader suite.\n4. End with npx tsc --noEmit and the full video-editor test run.","questions":["When usePinnedGroupSync sees the shot's image list change, should it preserve the live timing of surviving clips and only append/remove members, or should it rebuild the full clip sequence for that group from shot order?","Should (shotId, trackId) remain the uniqueness key for a pinned group after the refactor, or can the same shot be pinned multiple times on the same track? This changes cross-track drag and repin behavior.","After deferring poll-sync or conflict reloads during an active drag/resize, should the editor immediately replay the newest deferred remote update when the gesture ends if local edits are clean, or just wait for the next poll/save cycle?"],"success_criteria":[{"criterion":"Loading a config with legacy pinnedShotGroups[].children yields runtime groups in the new soft-tag shape, and saving that same timeline emits no start or children fields.","priority":"must"},{"criterion":"No runtime load/save/commit path re-derives clip timing or track placement from shot-group child geometry; clips[] remains the only source of truth for at and duration.","priority":"must"},{"criterion":"Dragging the right edge of the last clip in a shot changes only that clip's duration and the group's rendered right boundary follows.","priority":"must"},{"criterion":"Dragging the left edge of the first clip in a shot changes only that clip's start/duration and the group's rendered left boundary follows.","priority":"must"},{"criterion":"Dragging an interior boundary inside a shot changes only the two adjacent clips while preserving the rest of the group.","priority":"must"},{"criterion":"Dragging a grouped clip body translates the full group together, and cross-track drag moves all grouped clips to the new track while updating the group's trackId.","priority":"must"},{"criterion":"Auto-save does not execute during an active drag or resize interaction, and the newest pending save flushes after the interaction ends.","priority":"must"},{"criterion":"Poll-sync and conflict reloads do not overwrite local edits during an active drag or resize interaction; deferred remote work is re-evaluated after the interaction ends.","priority":"must"},{"criterion":"Shot label menu actions and per-clip context-menu lockdown still work under the soft-tag model.","priority":"must"},{"criterion":"npx tsc --noEmit passes.","priority":"must"},{"criterion":"The video-editor test suite passes after updating intentional expectations, with no new failures beyond the known unrelated pre-existing TimelineCanvas assertion if it still remains.","priority":"must"},{"criterion":"Net LOC or helper surface across shot-group-specific files decreases after removing projection machinery.","priority":"should"},{"criterion":"An unchanged timeline produces the same clip-level data for Remotion preview before and after the refactor.","priority":"should"},{"criterion":"Manual browser smoke testing confirms the two reported resize/save-reset symptoms no longer reproduce.","priority":"info"}],"assumptions":["The brief's rollback direction is correct: a structural removal of projection is simpler and safer than more incremental fixes because projection is currently wired into load, save, commit, drag, resize, and rendering.","Until clarified, (shotId, trackId) remains the identity for a pinned group, and the refactor should not introduce a new stable group id.","Stored clipIds should remain ordered left-to-right by current live clip position whenever membership changes or a grouped move completes.","If save or poll work is deferred during an interaction, the implementation should keep only the latest pending item and re-evaluate it immediately once the interaction clears.","Unrelated long-lived diagnostics outside the shot-group and timeline-sync paths can stay; only temporary debugging logs added during this bug cycle should be removed as part of the focused rollback."]}
You are revising an implementation plan after critique and gate feedback.
Roll back the "first-class shot groups with projection layer" architecture introduced in a previous megaplan. Replace it with a simpler "shot group is a soft tag, cohesion is enforced by edit operations" model. The current projection-based architecture has produced a recurring class of bugs that we cannot fix incrementally — every patch surfaces another bug because the underlying model is wrong. This refactor eliminates the entire bug class structurally.
Why (the structural problem)
The previous "first-class shot groups" megaplan introduced a pinnedShotGroups[i] = { shotId, trackId, start, children: [{clipId, offset, duration}], clipIds, mode, ... } data shape. Cohesion is enforced by re-deriving clip positions from pinnedShotGroups[].children via projectPinnedShotGroups, which runs three times per commit cycle (inside resizeGroupEdge, inside applyEdit, and inside buildDataFromCurrentRegistry via repairConfig).
This is "cohesion by re-projection," which means:
Two parallel data shapes for the same thing. pinnedShotGroups[i].children[j].duration vs clips[k].hold. Any edit that bypasses the projection (a free-clip resize fallback, a stale closure, a missing prop) gets silently reverted because the next projection re-derives from children.
Auto-save fires during drags and drops pointer capture. The save round-trip causes a re-render mid-drag, which can drop pointer capture, which fires a fresh pointerdown on whatever's under the cursor — breaking one user gesture into multiple resize sessions.
The prop chain has 8 hand-offs for startGroupEdgeResize. Any one can drop the prop silently because TypeScript widens object literal types to satisfy the interface even when fields are missing. We just hit one (VideoEditorProvider.tsx was missing the field, surfacing as "snaps back to full shot length").
resizeGroupEdge has wrong semantics — it scales every child of the group proportionally when you drag an outer edge. Users expect: drag the right edge of the last clip → only that clip's duration changes. The current code shrinks every clip in the group.
Three different views of the same data (PinnedShotGroup → ShotGroup → PositionedShotGroup), each with its own filter that can drop the group from view, each with its own slightly different fields.
This entire conversation has been bug → fix → bug → fix for hours. Each fix passes type-check and tests. That's not a quality problem; it's a sign the model is so loose that structural bugs pass all the gates we have. The right answer is to stop patching and rebuild the model.
The new model
Cohesion is a property of edit operations, not data shape.
Data
pinnedShotGroups[i] = {
shotId: string;
trackId: string;
clipIds: string[]; // ordered left-to-right by current spatial position
mode?: 'images' | 'video';
videoAssetKey?: string;
imageClipSnapshot?: ...;
}
That's it. No start, no children, no offset, no duration on the group. The clips themselves carry all position/duration data via clips[k].at / clips[k].hold (or from/to/speed). One source of truth: the clips.
Operations
Every user operation that touches a clip in a group is implemented as a direct clip mutation that preserves group cohesion intentionally:
Drag clip body in a group → All clips in the group → Translate every clip in the group by the same delta. Already implemented in useClipDrag via deferred expansion — keep that pattern.
Resize first clip's LEFT edge → First clip only → Change the first clip's at (and hold/source-time accordingly). Group's left edge follows. Other clips unchanged.
Resize last clip's RIGHT edge → Last clip only → Change the last clip's hold/source-time. Group's right edge follows. Other clips unchanged.
Resize an interior boundary (between clip[i] and clip[i+1]) → Two adjacent clips → Trade duration between them: clip[i]'s hold changes, clip[i+1]'s at AND hold change so clip[i+1]'s right edge stays put.
Cross-track drag of a grouped clip → All clips in the group → All clips move to the new track preserving relative offsets. Update pinnedShotGroups[i].trackId.
Pin a new shot group → (creates the group) → Sort the selected clip ids by at ascending and store as clipIds.
Unpin / Deconstruct → (removes the group) → Just removes the entry from pinnedShotGroups. Clips are unchanged.
Delete shot → All clips in the group + the group entry → Delete the clips, remove the pin.
No proportional scaling. Every operation only touches the clips it semantically should.
Rendering
The shot border is a pure function of the clips' current positions:
function computeShotGroupRect(group, clips) {
const groupClips = group.clipIds.map((id) => clipById.get(id)).filter(Boolean);
if (groupClips.length === 0) return null;
groupClips.sort((a, b) => a.at - b.at);
const start = groupClips[0].at;
const end = groupClips.at(-1).at + clipDuration(groupClips.at(-1));
return { start, end };
}
No projection step, no validation pass that drops the group from view. If the clips are non-contiguous for some reason, render a degraded state but never silently lose the group.
Save gating
Block auto-save while a drag or resize session is active. interactionStateRef.current.resize || .drag already exists; gate the save scheduler on it. When the interaction ends, flush any pending save. This eliminates the "drag resets mid-gesture due to save round-trip" symptom.
Migration
Existing user data has the projection-shape pinnedShotGroups[i] = { ..., start, children: [...] }. The refactor must continue to load these correctly:
On load (in repairConfig or equivalent), if a group has start + children, derive the legacy clipIds from children.map((c) => c.clipId) and DROP the start/children fields. The clip positions are already correct in clips[] from the previous projection.
On save, only emit the new shape ({ shotId, trackId, clipIds, mode, ... }).
Add a migration test that loads a projection-shape config and verifies it converts cleanly.
What to delete (or simplify drastically)
These exist to support the projection model and should be removed or radically simplified:
src/tools/video-editor/lib/pinned-group-projection.ts — DELETE most of it. Keep maybe findEnclosingPinnedGroup (a useful lookup) and categorizeSelection. Delete projectPinnedShotGroups, resizeGroupEdge, resizeChildBoundary, replaceGroup, replaceGroupChildren, buildGroupFromChildren, buildGroupFromConfigClips, normalizeChildren, setClipTimelineDuration, moveGroup, getGroupDuration.
src/tools/video-editor/lib/pinned-group-projection.test.ts — rewrite to test whatever helpers remain.
src/tools/video-editor/lib/pinned-group-cohesion.test.ts — rewrite or delete.
src/tools/video-editor/hooks/useClipResize.ts — startGroupEdgeResize becomes "resize the last/first clip directly." resizeChildBoundary becomes "change two adjacent clips' durations." Both call existing applyEdit({ type: 'rows' }) instead of { type: 'pinnedShotGroups' }.
src/tools/video-editor/hooks/useTimelineCommit.ts — the 'pinnedShotGroups' mutation type can be simplified (no projection step), or removed entirely if all group operations now go through 'rows'.
src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx — the 'group-edge' and 'group-child-boundary' resize sessions can collapse into the regular 'clip' session, since they now just edit clip data directly.
src/tools/video-editor/contexts/VideoEditorProvider.tsx — the startGroupEdgeResize prop hand-off goes away.
src/tools/video-editor/hooks/useTimelineState.types.ts and useTimelineState.contexts.ts — drop TimelineShotGroupResize and startGroupEdgeResize from the context types and value.
src/tools/video-editor/hooks/useShotGroups.ts — simplify to just resolve clipIds to live actions and compute color/name. No start, no children, no rowIndex. Just { shotId, shotName, trackId, clipIds, color, mode }.
positionedShotGroups in TimelineCanvas.tsx — becomes a pure function of the live row actions instead of reading from group.start + child.offset.
Save gating implementation
There's an interactionStateRef: { current: { drag: boolean; resize: boolean } } ref already used by useClipDrag and useClipResize. Find where the auto-save is scheduled (probably useTimelinePersistence or the scheduleSave event listener) and gate it: if interactionStateRef.current.drag || interactionStateRef.current.resize, don't fire the save — defer it. Flush the pending save when the interaction ends (in endResize and clearSession).
Add a new edge case: if the user is interacting AND a poll-sync conflict comes in, defer the conflict resolution too (don't reload from server while the user is editing).
Files most likely to change
src/tools/video-editor/lib/pinned-group-projection.ts (delete most of)
src/tools/video-editor/types/index.ts (drop start/children from PinnedShotGroup)
All related tests
Hard requirements
Eliminate the recurring bug class. After this refactor, the following must work end-to-end:
Drag the right edge of the last clip in a shot → only that clip's duration changes; group's right end follows.
Drag the left edge of the first clip in a shot → only that clip's start/duration changes; group's left end follows.
Drag an interior boundary inside a shot → two adjacent clips trade duration; rest of group stays put.
Drag a clip body inside a shot → entire group translates together.
Drag the entire shot group across rows → all clips move to the new row, group's trackId updates.
Auto-save does NOT fire during a drag or resize gesture; it flushes when the gesture ends.
Poll-sync does NOT overwrite the user's in-progress edits.
All shot label menu actions still work.
Per-clip context menu lockdown still works.
Existing data loads correctly. A user with the projection-shape pinnedShotGroups[] in their saved state must continue to see their shots after the refactor. Migration is one-way: load → convert → save in new shape.
Remotion preview unchanged. Remotion reads from clips[]. Since clips are now the source of truth (no projection), the Remotion render is automatically correct.
Type-check passes. npx tsc --noEmit clean.
Tests pass. All 181 video-editor tests must continue to pass, OR be updated with clear justification when behavior intentionally changes. Add new tests covering:
The migration from projection-shape to soft-tag shape.
Each new edit operation.
Save gating during interactions.
Cohesion preservation through a sequence of operations.
Constraints
Scope is the video-editor tool only. No DB schema changes, no edge functions.
Follow CLAUDE.md rules. Prefer Edit over Write. No new docs unless necessary.
Don't bundle unrelated cleanups. Keep the diff focused on the projection rollback.
One pre-existing failing test (data-shot-group-kind="pinned" in TimelineCanvas test) is unrelated and can be left alone.
The diagnostic console.logs added in this conversation should be removed as part of this refactor.
Reuse useClipDrag's deferred expansion pattern as the canonical "operate on a group as a unit" pattern.
Success criteria
The two specific symptoms no longer reproduce.
tsc --noEmit clean.
All video-editor tests pass.
Code line count for shot-group-related files DECREASES net.
The Remotion preview renders the same output for an unchanged timeline.
Loading a saved file with projection-shape pinnedShotGroups[].children produces a correct visual on the timeline.
code
Current plan (markdown):
# Implementation Plan: Roll Back Projection-Based Shot Groups To Soft Tags
Overview
Repo inspection confirms the brief's diagnosis. projectPinnedShotGroups is still rewriting clip timing in src/tools/video-editor/lib/timeline-data.ts, src/tools/video-editor/lib/timeline-save-utils.ts, and src/tools/video-editor/hooks/useTimelineCommit.ts; grouped resize/preview behavior still depends on start and children in src/tools/video-editor/hooks/useClipResize.ts and src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx; and the old startGroupEdgeResize prop still crosses the context/provider chain. A smaller patch would keep two positional sources of truth alive, so the simplest structural fix is the rollback described in the brief: make clips[] the only source of timeline position/duration, reduce pinnedShotGroups[] to soft-tag metadata, and gate persistence while interactions are active.
Phase 1: Canonical Model And Migration
Step 1: Replace the persisted/runtime group shape with soft tags
Scope: Medium
Update src/tools/video-editor/types/index.ts so PinnedShotGroup only contains shotId, trackId, clipIds, mode, videoAssetKey, and imageClipSnapshot.
Add a single normalization path in src/tools/video-editor/lib/migrate.ts: if a loaded group still has legacy start plus children, derive clipIds from children.map(child => child.clipId), preserve metadata, and drop legacy fields before the config enters editor state.
Remove projection from load/save assembly in src/tools/video-editor/lib/timeline-data.ts and src/tools/video-editor/lib/timeline-save-utils.ts so runtime data is built from migrated clips directly.
Update cloning/repair helpers in src/tools/video-editor/lib/migrate.ts and src/tools/video-editor/lib/timeline-data.ts to stop fabricating start and children.
Prove the migration first with focused coverage in src/tools/video-editor/lib/serialize.test.ts, src/tools/video-editor/lib/timeline-save-utils.test.ts, and migration-adjacent tests before changing UI behavior.
Step 2: Delete projection-era helpers and keep only lookup utilities
Scope: Medium
Strip src/tools/video-editor/lib/pinned-group-projection.ts down to helpers that still make sense in the soft-tag model, likely findEnclosingPinnedGroup, categorizeSelection, and a small helper for ordering clipIds from live clips.
Delete projection-only helpers such as projectPinnedShotGroups, resizeGroupEdge, resizeChildBoundary, moveGroup, replaceGroupChildren, buildGroupFromChildren, and buildGroupFromConfigClips, then update imports across hooks and tests.
Rewrite src/tools/video-editor/lib/pinned-group-projection.test.ts around the remaining helpers and replace src/tools/video-editor/lib/pinned-group-cohesion.test.ts with soft-tag regression coverage instead of projection invariants.
Phase 2: Edit Operations Become The Cohesion Layer
Step 3: Rebuild grouped resize semantics as direct clip mutations
Scope: Large
In src/tools/video-editor/hooks/useClipResize.ts, replace grouped resize commits so they always emit applyEdit({ type: 'rows' }) mutations against live row actions plus source-time metadata patches, never type: 'pinnedShotGroups' for timing changes.
Implement the three required semantics explicitly: first clip left edge changes only that clip; last clip right edge changes only that clip; interior boundary changes only the dragged clip and its adjacent neighbor while keeping the outer boundary fixed.
Reuse the existing free-clip source-time math where possible so timed media keeps current trim behavior instead of introducing a second grouped resize algorithm.
Add focused tests for each operation and a sequence test that proves later edits are not silently reverted.
Step 4: Keep grouped drag as clip translation, not group projection
Scope: Large
Update src/tools/video-editor/hooks/useClipDrag.ts and src/tools/video-editor/lib/multi-drag-utils.ts so grouped body drags and cross-track drags translate all member clips directly, reusing the current deferred expansion pattern as the canonical implementation.
Change grouped cross-track moves to update only the moved clips plus the group's trackId and stored clipIds order when needed.
Remove projection-specific overlap helpers from src/tools/video-editor/lib/resolve-overlaps.ts and any drag-result builders that still expect group extents.
Extend src/tools/video-editor/hooks/useClipDrag.test.tsx and src/tools/video-editor/lib/multi-drag-utils.test.ts to cover same-row translation and cross-track group moves under the new model.
Step 5: Simplify group mutation entry points
Scope: Medium
Collapse src/tools/video-editor/hooks/useTimelineCommit.ts so clip-timing edits stay on the rows path and group-only mutations are limited to pin/unpin/mode/track/clipId membership updates.
Update src/tools/video-editor/hooks/usePinnedShotGroups.ts, src/tools/video-editor/hooks/useExternalDrop.ts, src/tools/video-editor/hooks/useSwitchToFinalVideo.ts, and delete paths in clip editing to create or mutate groups by clipIds only.
Ensure pinning sorts selected clip ids by live at, unpinning only removes the group entry, deleting a shot removes grouped clips plus the group entry, and switch-to-video/images keeps imageClipSnapshot behavior without reintroducing group geometry.
Phase 3: Rendering And Context Simplification
Step 6: Render shot groups from live clip positions only
Scope: Large
Simplify src/tools/video-editor/hooks/useShotGroups.ts to return display metadata plus live clipIds, without start, children, or projection-derived row state.
In src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx, compute each group rectangle from current row actions for clipIds using earliest start and latest end rather than persisted group geometry.
Remove startGroupEdgeResize from src/tools/video-editor/hooks/useTimelineState.types.ts, src/tools/video-editor/hooks/useTimelineState.contexts.ts, src/tools/video-editor/contexts/VideoEditorProvider.tsx, and src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx; resize handling should stay inside the regular clip session flow.
Preserve degraded rendering when clips are missing or non-contiguous: render from whatever member clips still exist and never drop the group because a validation/projection step filtered it out.
Update src/tools/video-editor/components/TimelineEditor/TimelineCanvas.test.tsx, src/tools/video-editor/components/TimelineEditor/TimelineEditor.test.ts, and src/tools/video-editor/hooks/useShotGroups.test.ts for the new render contract while leaving the unrelated pre-existing TimelineCanvas assertion isolated if it still remains.
Phase 4: Persistence Gating And Remote Sync Safety
Step 7: Block save and poll-sync work during active interactions
Scope: Medium
Thread interactionStateRef or an equivalent shared ref into src/tools/video-editor/hooks/useTimelineSave.ts, src/tools/video-editor/hooks/useTimelinePersistence.ts, and src/tools/video-editor/hooks/usePollSync.ts so both save scheduling and poll application can check drag || resize.
Change src/tools/video-editor/hooks/useTimelinePersistence.ts to queue the latest pending save while an interaction is active, skip the 500ms save fire during the gesture, and flush once clearSession or endResize clears the interaction flag.
Change src/tools/video-editor/hooks/usePollSync.ts so incoming poll data and conflict reload/retry paths defer while an interaction is active, then re-evaluate the newest deferred payload after the gesture ends.
Remove temporary sync/debug logging in the touched shot-group and timeline-sync files as part of this rollback.
Add regression tests in src/tools/video-editor/hooks/usePollSync.test.ts plus new persistence tests for deferred save flush and deferred poll/conflict handling.
Phase 5: Feature Reconciliation And Verification
Step 8: Reconcile remaining shot-group features and run the safety net
Scope: Medium
Re-test shot label menu actions, per-clip context-menu lockdown, external shot drop, and switch-to-final-video/image flows against the soft-tag model; patch any remaining children or start assumptions.
Run cheap targeted checks first: migration/serialize/save-utils tests, then resize/drag/group tests, then persistence/poll tests.
Finish with npx tsc --noEmit and the full video-editor suite; if the known unrelated TimelineCanvas assertion is still pre-existing, confirm it is the only non-regression failure.
Compare line count and helper surface in the shot-group files to confirm the rollback actually removed projection machinery instead of wrapping it.
Execution Order
Land the type and migration cleanup first so every later change works against one canonical shape.
Rewrite edit semantics next in useClipResize, drag utilities, and commit flow before touching rendering.
Remove the prop chain and projection-era rendering once runtime behavior is correct.
Finish with save/poll gating, remaining feature reconciliation, and the broad verification sweep.
Validation Order
Start with migration and serialization tests because they are the cheapest proof that old data still loads and new data saves in one shape.
Run focused resize and drag tests immediately after each operation rewrite to catch semantic regressions before UI integration.
Validate save/poll gating with targeted hook tests before the broader suite.
End with npx tsc --noEmit and the full video-editor test run.
code
Current plan metadata:
{
"version": 1,
"timestamp": "2026-04-08T11:43:05Z",
"hash": "sha256:d412c00ed6f5467a775ea9cadb0fa0d49df7d6220fcf4cd84faf420df54a9fd2",
"questions": [
"When usePinnedGroupSync sees the shot's image list change, should it preserve the live timing of surviving clips and only append/remove members, or should it rebuild the full clip sequence for that group from shot order?",
"Should (shotId, trackId) remain the uniqueness key for a pinned group after the refactor, or can the same shot be pinned multiple times on the same track? This changes cross-track drag and repin behavior.",
"After deferring poll-sync or conflict reloads during an active drag/resize, should the editor immediately replay the newest deferred remote update when the gesture ends if local edits are clean, or just wait for the next poll/save cycle?"
],
"success_criteria": [
{
"criterion": "Loading a config with legacy pinnedShotGroups[].children yields runtime groups in the new soft-tag shape, and saving that same timeline emits no start or children fields.",
"priority": "must"
},
{
"criterion": "No runtime load/save/commit path re-derives clip timing or track placement from shot-group child geometry; clips[] remains the only source of truth for at and duration.",
"priority": "must"
},
{
"criterion": "Dragging the right edge of the last clip in a shot changes only that clip's duration and the group's rendered right boundary follows.",
"priority": "must"
},
{
"criterion": "Dragging the left edge of the first clip in a shot changes only that clip's start/duration and the group's rendered left boundary follows.",
"priority": "must"
},
{
"criterion": "Dragging an interior boundary inside a shot changes only the two adjacent clips while preserving the rest of the group.",
"priority": "must"
},
{
"criterion": "Dragging a grouped clip body translates the full group together, and cross-track drag moves all grouped clips to the new track while updating the group's trackId.",
"priority": "must"
},
{
"criterion": "Auto-save does not execute during an active drag or resize interaction, and the newest pending save flushes after the interaction ends.",
"priority": "must"
},
{
"criterion": "Poll-sync and conflict reloads do not overwrite local edits during an active drag or resize interaction; deferred remote work is re-evaluated after the interaction ends.",
"priority": "must"
},
{
"criterion": "Shot label menu actions and per-clip context-menu lockdown still work under the soft-tag model.",
"priority": "must"
},
{
"criterion": "npx tsc --noEmit passes.",
"priority": "must"
},
{
"criterion": "The video-editor test suite passes after updating intentional expectations, with no new failures beyond the known unrelated pre-existing TimelineCanvas assertion if it still remains.",
"priority": "must"
},
{
"criterion": "Net LOC or helper surface across shot-group-specific files decreases after removing projection machinery.",
"priority": "should"
},
{
"criterion": "An unchanged timeline produces the same clip-level data for Remotion preview before and after the refactor.",
"priority": "should"
},
{
"criterion": "Manual browser smoke testing confirms the two reported resize/save-reset symptoms no longer reproduce.",
"priority": "info"
}
],
"assumptions": [
"The brief's rollback direction is correct: a structural removal of projection is simpler and safer than more incremental fixes because projection is currently wired into load, save, commit, drag, resize, and rendering.",
"Until clarified, remains the identity for a pinned group, and the refactor should not introduce a new stable group id.",
"Stored should remain ordered left-to-right by current live clip position whenever membership changes or a grouped move completes.",
"If save or poll work is deferred during an interaction, the implementation should keep only the latest pending item and re-evaluate it immediately once the interaction clears.",
"Unrelated long-lived diagnostics outside the shot-group and timeline-sync paths can stay; only temporary debugging logs added during this bug cycle should be removed as part of the focused rollback."
],
"structure_warnings": []
}
code
Gate summary:
{
"passed": false,
"criteria_check": {
"count": 14,
"items": [
{
"criterion": "Loading a config with legacy pinnedShotGroups[].children yields runtime groups in the new soft-tag shape, and saving that same timeline emits no start or children fields.",
"priority": "must"
},
{
"criterion": "No runtime load/save/commit path re-derives clip timing or track placement from shot-group child geometry; clips[] remains the only source of truth for at and duration.",
"priority": "must"
},
{
"criterion": "Dragging the right edge of the last clip in a shot changes only that clip's duration and the group's rendered right boundary follows.",
"priority": "must"
},
{
"criterion": "Dragging the left edge of the first clip in a shot changes only that clip's start/duration and the group's rendered left boundary follows.",
"priority": "must"
},
{
"criterion": "Dragging an interior boundary inside a shot changes only the two adjacent clips while preserving the rest of the group.",
"priority": "must"
},
{
"criterion": "Dragging a grouped clip body translates the full group together, and cross-track drag moves all grouped clips to the new track while updating the group's trackId.",
"priority": "must"
},
{
"criterion": "Auto-save does not execute during an active drag or resize interaction, and the newest pending save flushes after the interaction ends.",
"priority": "must"
},
{
"criterion": "Poll-sync and conflict reloads do not overwrite local edits during an active drag or resize interaction; deferred remote work is re-evaluated after the interaction ends.",
"priority": "must"
},
{
"criterion": "Shot label menu actions and per-clip context-menu lockdown still work under the soft-tag model.",
"priority": "must"
},
{
"criterion": "npx tsc --noEmit passes.",
"priority": "must"
},
{
"criterion": "The video-editor test suite passes after updating intentional expectations, with no new failures beyond the known unrelated pre-existing TimelineCanvas assertion if it still remains.",
"priority": "must"
},
{
"criterion": "Net LOC or helper surface across shot-group-specific files decreases after removing projection machinery.",
"priority": "should"
},
{
"criterion": "An unchanged timeline produces the same clip-level data for Remotion preview before and after the refactor.",
"priority": "should"
},
{
"criterion": "Manual browser smoke testing confirms the two reported resize/save-reset symptoms no longer reproduce.",
"priority": "info"
}
]
},
"preflight_results": {
"project_dir_exists": true,
"project_dir_writable": true,
"success_criteria_present": true,
"claude_available": true,
"codex_available": true
},
"unresolved_flags": [
{
"id": "DEBT-129",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: the save/poll interaction guard still omits the useTimelineState.ts-level plumbing needed to create a shared interaction ref before useTimelineSave() runs.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": " is created in , but the existing is local to . The plan's named files for save gating do not include that ownership bridge.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "DEBT-109",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: grouped cross-track move paths still route through and , but that file is not named in the rollback plan.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Grouped moves are still handled in , , and , all of which depend on and projection-era pinned-group state.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "issue_hints-1",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked , , and ; grouped cross-track moves, keyboard move-selected actions, and create-track-and-move still route through and or , but this file is not in the plan's likely-change list, so the approved cross-row group-move requirement is only partially covered.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked , , and ; grouped cross-track moves, keyboard move-selected actions, and create-track-and-move still route through and or , but this file is not in the plan's likely-change list, so the approved cross-row group-move requirement is only partially covered.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "issue_hints-2",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked ; auto-sync currently preserves , reuses surviving clip durations when possible, shifts trailing actions by the delta, and reschedules itself while interactions are active. The plan metadata still leaves the preserve-vs-rebuild sync behavior open, but in this repository that choice affects existing layout semantics and should be resolved in the plan rather than deferred to implementation.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked ; auto-sync currently preserves , reuses surviving clip durations when possible, shifts trailing actions by the delta, and reschedules itself while interactions are active. The plan metadata still leaves the preserve-vs-rebuild sync behavior open, but in this repository that choice affects existing layout semantics and should be resolved in the plan rather than deferred to implementation.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "correctness-1",
"concern": "Are the proposed changes technically correct?: Checked , , and ; the current session carries adjacent clip ids, paired preview overrides, and boundary clamps that the plain session does not. The plan's statement that group-edge and child-boundary sessions can collapse into the regular clip session is under-specified and would be incorrect unless the new clip session is expanded to keep that two-clip context.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked , , and ; the current session carries adjacent clip ids, paired preview overrides, and boundary clamps that the plain session does not. The plan's statement that group-edge and child-boundary sessions can collapse into the regular clip session is under-specified and would be incorrect unless the new clip session is expanded to keep that two-clip context.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "correctness-2",
"concern": "Are the proposed changes technically correct?: Checked and ; grouped drags onto a new track currently commit through a resolved-config path, not just or . The plan mentions simplifying , but it does not explicitly say how soft-tag metadata is rebuilt on that branch, so one live grouped-drag path remains technically under-specified.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked and ; grouped drags onto a new track currently commit through a resolved-config path, not just or . The plan mentions simplifying , but it does not explicitly say how soft-tag metadata is rebuilt on that branch, so one live grouped-drag path remains technically under-specified.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "scope-1",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , and ; the projection model is not isolated to resize and rendering, because grouped movement logic also derives duration and extents from and , and some of those paths never pass through . The underlying problem is broader than the plan's named drag hooks unless is brought into scope too.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked , , and ; the projection model is not isolated to resize and rendering, because grouped movement logic also derives duration and extents from and , and some of those paths never pass through . The underlying problem is broader than the plan's named drag hooks unless is brought into scope too.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "scope-2",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , , , and ; these suites directly assert , , or behavior. The plan says 'all related tests', but the concrete test surface is broader than the files it names.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked , , , , and ; these suites directly assert , , or behavior. The plan says 'all related tests', but the concrete test surface is broader than the files it names.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "all_locations-1",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked and ; is instantiated in , while the current is local to . The plan says to thread that ref into persistence and poll hooks, but the file list omits and any provider/context plumbing needed to create a shared ref before renders.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked and ; is instantiated in , while the current is local to . The plan says to thread that ref into persistence and poll hooks, but the file list omits and any provider/context plumbing needed to create a shared ref before renders.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "all_locations-2",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked , , and ; and still normalize groups to include and , and the validation test explicitly expects that expanded shape. The plan names , but the supporting validation surface is not called out and will fail unless it is updated in the same change.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked , , and ; and still normalize groups to include and , and the validation test explicitly expects that expanded shape. The plan names , but the supporting validation surface is not called out and will fail unless it is updated in the same change.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "callers-1",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the grouped-move branches in ; single-clip cross-track drags call , same-track grouped drags emit , and grouped drags onto a new track emit with . The plan discusses generally, but it does not explicitly cover all three caller shapes, especially the new-track config branch.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked the grouped-move branches in ; single-clip cross-track drags call , same-track grouped drags emit , and grouped drags onto a new track emit with . The plan discusses generally, but it does not explicitly cover all three caller shapes, especially the new-track config branch.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "callers-2",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked , , and ; is called by drag, keyboard track moves, and batch move-selected operations, and when the clip belongs to a pinned group it immediately routes through . Because that caller fan-out already exists, leaving out of the plan would leave multiple entry points on the old model.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked , , and ; is called by drag, keyboard track moves, and batch move-selected operations, and when the clip belongs to a pinned group it immediately routes through . Because that caller fan-out already exists, leaving out of the plan would leave multiple entry points on the old model.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "callers-3",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked and ; callers that mutate groups today pass full geometry-bearing payloads (, , ), not just . The plan's wording about keeping a few lookup helpers understates how many call sites need signature changes once becomes a soft tag.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked and ; callers that mutate groups today pass full geometry-bearing payloads (, , ), not just . The plan's wording about keeping a few lookup helpers understates how many call sites need signature changes once becomes a soft tag.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
}
],
"recommendation": "ITERATE",
"rationale": "Iteration 1 with 13 open significant flags and a weighted score of 22.0. Several flags identify concrete execution blockers that would cause the rollback to fail or leave parallel projection paths alive: (1) still routes grouped cross-track moves, keyboard move-selected, and create-track-and-move through and /, but is not in the plan's file list \u2014 this alone leaves the old model wired in for every non-drag cross-row group motion; (2) / in still normalize groups back into + and explicitly asserts that shape, so the migration would silently re-expand the shape on every save; (3) the owner lives in but is instantiated in \u2014 save gating cannot work without adding that ownership bridge, which the plan omits; (4) the plan says and sessions "collapse into the regular clip session," but the child-boundary session carries paired adjacent-clip context and clamps that the plain clip session does not, so this collapse is under-specified; (5) grouped drag onto a new track still commits via / , and the plan does not say how soft-tag metadata is rebuilt on that branch; (6) auto-sync preserve-vs-rebuild semantics are explicitly left open in plan metadata despite affecting existing layout behavior; (7) the concrete test surface (render-bounds validation, useTimelineTrackManagement, useExternalDrop, useClipEditing, useClipDrag suites) is broader than the plan's named test files. These gaps overlap three escalated debt subsystems (all_locations, correctness, callers) with the same pinned-group refactor lineage, so a point-patch iteration is still the right move \u2014 the plan needs to add , , the missing tests, / scope, the child-boundary session spec, the new-track drag branch spec, and a committed sync policy before execution.",
"signals_assessment": "Iteration 1 baseline: weighted score 22.0 with no trajectory yet, 13 blocking flags open, 0 resolved. Preflight is clean (project dir writable, both agents available, success criteria present). Recurring-debt overlap is heavy: the flags land inside the four largest escalated subsystems (correctness, all_locations, issue_hints, callers), all of which trace back to the pinned-shot-groups lineage \u2014 this is a sign the plan still under-scopes the rollback rather than that the loop is stuck. No recurring critiques yet because this is iteration 1, so ITERATE is preferred over ESCALATE.",
"warnings": [
"Plan must add src/tools/video-editor/hooks/useTimelineTrackManagement.ts to scope \u2014 it currently routes grouped cross-track moves through moveGroup() and pinnedShotGroupsOverride.",
"Plan must add src/tools/video-editor/hooks/useTimelineState.ts and any context plumbing needed to share interactionStateRef with useTimelineSave/useTimelinePersistence/usePollSync.",
"Plan must explicitly include rowsToConfig() and clonePinnedShotGroups() in timeline-data.ts in the shape-strip pass, plus update render-bounds.validation.test.ts expectations.",
"Plan must specify how child-boundary resize preserves paired adjacent-clip context and clamps when collapsed into the clip session.",
"Plan must specify how grouped drag onto a new track (buildConfigFromDragResult / type:'config' branch) rebuilds soft-tag metadata atomically.",
"Plan must commit to a preserve-vs-rebuild policy for usePinnedShotGroups auto-sync rather than leaving it open.",
"Plan must enumerate the broader test surface: render-bounds.validation.test.ts, useTimelineTrackManagement.test.ts, useExternalDrop.test.tsx, useClipEditing.test.ts, useClipDrag.test.tsx."
],
"settled_decisions": [
{
"id": "model-rollback",
"decision": "Roll back projection-based pinned shot groups to soft-tag model where clips[] is the single source of truth for position/duration and pinnedShotGroups[] only carries shotId/trackId/clipIds/mode metadata.",
"rationale": "User brief and plan agree this is a structural fix for a recurring bug class; projection is already wired through load/save/commit/drag/resize/render so a point patch cannot eliminate the class."
},
{
"id": "group-identity",
"decision": "(shotId, trackId) remains the pinned-group identity; no new stable group id is introduced in this refactor.",
"rationale": "Plan assumption listed and aligns with existing lookup sites; avoids scope creep."
},
{
"id": "save-poll-gating",
"decision": "Auto-save and poll-sync/conflict-reload defer while interactionStateRef.drag||resize is true, keep only the newest pending payload, and re-evaluate it when the interaction clears.",
"rationale": "Eliminates drag-reset bug class; aligns with brief's hard requirement."
}
],
"override_forced": false,
"orchestrator_guidance": "First iteration; follow gate recommendation: ITERATE. Verify unresolved flags against the plan and project code before accepting.",
"robustness": "standard",
"signals": {
"iteration": 1,
"idea": "Roll back the "first-class shot groups with projection layer" architecture introduced in a previous megaplan. Replace it with a simpler "shot group is a soft tag, cohesion is enforced by edit operations" model. The current projection-based architecture has produced a recurring class of bugs that we cannot fix incrementally \u2014 every patch surfaces another bug because the underlying model is wrong. This refactor eliminates the entire bug class structurally.\n\n## Why (the structural problem)\n\nThe previous "first-class shot groups" megaplan introduced a pinnedShotGroups[i] = { shotId, trackId, start, children: [{clipId, offset, duration}], clipIds, mode, ... } data shape. Cohesion is enforced by re-deriving clip positions from pinnedShotGroups[].children via projectPinnedShotGroups, which runs three times per commit cycle (inside resizeGroupEdge, inside applyEdit, and inside buildDataFromCurrentRegistry via repairConfig).\n\nThis is "cohesion by re-projection," which means:\n\n1. Two parallel data shapes for the same thing. pinnedShotGroups[i].children[j].duration vs clips[k].hold. Any edit that bypasses the projection (a free-clip resize fallback, a stale closure, a missing prop) gets silently reverted because the next projection re-derives from children.\n\n2. Auto-save fires during drags and drops pointer capture. The save round-trip causes a re-render mid-drag, which can drop pointer capture, which fires a fresh pointerdown on whatever's under the cursor \u2014 breaking one user gesture into multiple resize sessions.\n\n3. The prop chain has 8 hand-offs for startGroupEdgeResize. Any one can drop the prop silently because TypeScript widens object literal types to satisfy the interface even when fields are missing. We just hit one (VideoEditorProvider.tsx was missing the field, surfacing as "snaps back to full shot length").\n\n4. resizeGroupEdge has wrong semantics \u2014 it scales every child of the group proportionally when you drag an outer edge. Users expect: drag the right edge of the last clip \u2192 only that clip's duration changes. The current code shrinks every clip in the group.\n\n5. Three different views of the same data (PinnedShotGroup \u2192 ShotGroup \u2192 PositionedShotGroup), each with its own filter that can drop the group from view, each with its own slightly different fields.\n\nThis entire conversation has been bug \u2192 fix \u2192 bug \u2192 fix for hours. Each fix passes type-check and tests. That's not a quality problem; it's a sign the model is so loose that structural bugs pass all the gates we have. The right answer is to stop patching and rebuild the model.\n\n## The new model\n\nCohesion is a property of edit operations, not data shape.\n\n### Data\npinnedShotGroups[i] = {\n shotId: string;\n trackId: string;\n clipIds: string[]; // ordered left-to-right by current spatial position\n mode?: 'images' | 'video';\n videoAssetKey?: string;\n imageClipSnapshot?: ...;\n}\n\nThat's it. No start, no children, no offset, no duration on the group. The clips themselves carry all position/duration data via clips[k].at / clips[k].hold (or from/to/speed). One source of truth: the clips.\n\n### Operations\n\nEvery user operation that touches a clip in a group is implemented as a direct clip mutation that preserves group cohesion intentionally:\n\n- Drag clip body in a group \u2192 All clips in the group \u2192 Translate every clip in the group by the same delta. Already implemented in useClipDrag via deferred expansion \u2014 keep that pattern.\n- Resize first clip's LEFT edge \u2192 First clip only \u2192 Change the first clip's at (and hold/source-time accordingly). Group's left edge follows. Other clips unchanged.\n- Resize last clip's RIGHT edge \u2192 Last clip only \u2192 Change the last clip's hold/source-time. Group's right edge follows. Other clips unchanged.\n- Resize an interior boundary (between clip[i] and clip[i+1]) \u2192 Two adjacent clips \u2192 Trade duration between them: clip[i]'s hold changes, clip[i+1]'s at AND hold change so clip[i+1]'s right edge stays put.\n- Cross-track drag of a grouped clip \u2192 All clips in the group \u2192 All clips move to the new track preserving relative offsets. Update pinnedShotGroups[i].trackId.\n- Pin a new shot group \u2192 (creates the group) \u2192 Sort the selected clip ids by at ascending and store as clipIds.\n- Unpin / Deconstruct \u2192 (removes the group) \u2192 Just removes the entry from pinnedShotGroups. Clips are unchanged.\n- Delete shot \u2192 All clips in the group + the group entry \u2192 Delete the clips, remove the pin.\n\nNo proportional scaling. Every operation only touches the clips it semantically should.\n\n### Rendering\n\nThe shot border is a pure function of the clips' current positions:\n\nfunction computeShotGroupRect(group, clips) {\n const groupClips = group.clipIds.map((id) => clipById.get(id)).filter(Boolean);\n if (groupClips.length === 0) return null;\n groupClips.sort((a, b) => a.at - b.at);\n const start = groupClips[0].at;\n const end = groupClips.at(-1).at + clipDuration(groupClips.at(-1));\n return { start, end };\n}\n\nNo projection step, no validation pass that drops the group from view. If the clips are non-contiguous for some reason, render a degraded state but never silently lose the group.\n\n### Save gating\n\nBlock auto-save while a drag or resize session is active. interactionStateRef.current.resize || .drag already exists; gate the save scheduler on it. When the interaction ends, flush any pending save. This eliminates the "drag resets mid-gesture due to save round-trip" symptom.\n\n### Migration\n\nExisting user data has the projection-shape pinnedShotGroups[i] = { ..., start, children: [...] }. The refactor must continue to load these correctly:\n\n- On load (in repairConfig or equivalent), if a group has start + children, derive the legacy clipIds from children.map((c) => c.clipId) and DROP the start/children fields. The clip positions are already correct in clips[] from the previous projection.\n- On save, only emit the new shape ({ shotId, trackId, clipIds, mode, ... }).\n- Add a migration test that loads a projection-shape config and verifies it converts cleanly.\n\n## What to delete (or simplify drastically)\n\nThese exist to support the projection model and should be removed or radically simplified:\n\n- src/tools/video-editor/lib/pinned-group-projection.ts \u2014 DELETE most of it. Keep maybe findEnclosingPinnedGroup (a useful lookup) and categorizeSelection. Delete projectPinnedShotGroups, resizeGroupEdge, resizeChildBoundary, replaceGroup, replaceGroupChildren, buildGroupFromChildren, buildGroupFromConfigClips, normalizeChildren, setClipTimelineDuration, moveGroup, getGroupDuration.\n- src/tools/video-editor/lib/pinned-group-projection.test.ts \u2014 rewrite to test whatever helpers remain.\n- src/tools/video-editor/lib/pinned-group-cohesion.test.ts \u2014 rewrite or delete.\n- src/tools/video-editor/hooks/useClipResize.ts \u2014 startGroupEdgeResize becomes "resize the last/first clip directly." resizeChildBoundary becomes "change two adjacent clips' durations." Both call existing applyEdit({ type: 'rows' }) instead of { type: 'pinnedShotGroups' }.\n- src/tools/video-editor/hooks/useTimelineCommit.ts \u2014 the 'pinnedShotGroups' mutation type can be simplified (no projection step), or removed entirely if all group operations now go through 'rows'.\n- src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx \u2014 the 'group-edge' and 'group-child-boundary' resize sessions can collapse into the regular 'clip' session, since they now just edit clip data directly.\n- src/tools/video-editor/contexts/VideoEditorProvider.tsx \u2014 the startGroupEdgeResize prop hand-off goes away.\n- src/tools/video-editor/hooks/useTimelineState.types.ts and useTimelineState.contexts.ts \u2014 drop TimelineShotGroupResize and startGroupEdgeResize from the context types and value.\n- src/tools/video-editor/hooks/useShotGroups.ts \u2014 simplify to just resolve clipIds to live actions and compute color/name. No start, no children, no rowIndex. Just { shotId, shotName, trackId, clipIds, color, mode }.\n- positionedShotGroups in TimelineCanvas.tsx \u2014 becomes a pure function of the live row actions instead of reading from group.start + child.offset.\n\n## Save gating implementation\n\nThere's an interactionStateRef: { current: { drag: boolean; resize: boolean } } ref already used by useClipDrag and useClipResize. Find where the auto-save is scheduled (probably useTimelinePersistence or the scheduleSave event listener) and gate it: if interactionStateRef.current.drag || interactionStateRef.current.resize, don't fire the save \u2014 defer it. Flush the pending save when the interaction ends (in endResize and clearSession).\n\nAdd a new edge case: if the user is interacting AND a poll-sync conflict comes in, defer the conflict resolution too (don't reload from server while the user is editing).\n\n## Files most likely to change\n\n- src/tools/video-editor/lib/pinned-group-projection.ts (delete most of)\n- src/tools/video-editor/lib/pinned-group-projection.test.ts (rewrite)\n- src/tools/video-editor/lib/pinned-group-cohesion.test.ts (rewrite or delete)\n- src/tools/video-editor/lib/migrate.ts (legacy load: convert children-shape to soft tags)\n- src/tools/video-editor/lib/timeline-save-utils.ts (no more projection in buildDataFromCurrentRegistry)\n- src/tools/video-editor/lib/multi-drag-utils.ts (PlannedGroupMove may simplify or stay)\n- src/tools/video-editor/lib/resolve-overlaps.ts (may not need findBestGroupStart with GroupExtent anymore)\n- src/tools/video-editor/hooks/useShotGroups.ts (simplify)\n- src/tools/video-editor/hooks/usePinnedShotGroups.ts (simplify pin/unpin/sync)\n- src/tools/video-editor/hooks/useClipResize.ts (group operations become clip mutations)\n- src/tools/video-editor/hooks/useClipDrag.ts (deferred expansion remains, group sync removed)\n- src/tools/video-editor/hooks/useTimelineCommit.ts (drop or simplify pinnedShotGroups mutation type)\n- src/tools/video-editor/hooks/useTimelineState.ts (instantiation site)\n- src/tools/video-editor/hooks/useTimelineState.types.ts (drop TimelineShotGroupResize)\n- src/tools/video-editor/hooks/useTimelineState.contexts.ts (drop the prop from the context value)\n- src/tools/video-editor/contexts/VideoEditorProvider.tsx (drop the prop from editorOps)\n- src/tools/video-editor/hooks/useTimelinePersistence.ts (gate save on interactionStateRef)\n- src/tools/video-editor/hooks/usePollSync.ts (defer conflict resolution during interactions)\n- src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx (collapse resize session types, rewrite positionedShotGroups, remove onShotGroupEdgeResize prop)\n- src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx (drop startGroupEdgeResize destructure)\n- src/tools/video-editor/types/index.ts (drop start/children from PinnedShotGroup)\n- All related tests\n\n## Hard requirements\n\n1. Eliminate the recurring bug class. After this refactor, the following must work end-to-end:\n - Drag the right edge of the last clip in a shot \u2192 only that clip's duration changes; group's right end follows.\n - Drag the left edge of the first clip in a shot \u2192 only that clip's start/duration changes; group's left end follows.\n - Drag an interior boundary inside a shot \u2192 two adjacent clips trade duration; rest of group stays put.\n - Drag a clip body inside a shot \u2192 entire group translates together.\n - Drag the entire shot group across rows \u2192 all clips move to the new row, group's trackId updates.\n - Auto-save does NOT fire during a drag or resize gesture; it flushes when the gesture ends.\n - Poll-sync does NOT overwrite the user's in-progress edits.\n - All shot label menu actions still work.\n - Per-clip context menu lockdown still works.\n\n2. Existing data loads correctly. A user with the projection-shape pinnedShotGroups[] in their saved state must continue to see their shots after the refactor. Migration is one-way: load \u2192 convert \u2192 save in new shape.\n\n3. Remotion preview unchanged. Remotion reads from clips[]. Since clips are now the source of truth (no projection), the Remotion render is automatically correct.\n\n4. Type-check passes. npx tsc --noEmit clean.\n\n5. Tests pass. All 181 video-editor tests must continue to pass, OR be updated with clear justification when behavior intentionally changes. Add new tests covering:\n - The migration from projection-shape to soft-tag shape.\n - Each new edit operation.\n - Save gating during interactions.\n - Cohesion preservation through a sequence of operations.\n\n## Constraints\n\n- Scope is the video-editor tool only. No DB schema changes, no edge functions.\n- Follow CLAUDE.md rules. Prefer Edit over Write. No new docs unless necessary.\n- Don't bundle unrelated cleanups. Keep the diff focused on the projection rollback.\n- One pre-existing failing test (data-shot-group-kind="pinned" in TimelineCanvas test) is unrelated and can be left alone.\n- The diagnostic console.logs added in this conversation should be removed as part of this refactor.\n- Reuse useClipDrag's deferred expansion pattern as the canonical "operate on a group as a unit" pattern.\n\n## Success criteria\n\n1. The two specific symptoms no longer reproduce.\n2. tsc --noEmit clean.\n3. All video-editor tests pass.\n4. Code line count for shot-group-related files DECREASES net.\n5. The Remotion preview renders the same output for an unchanged timeline.\n6. Loading a saved file with projection-shape pinnedShotGroups[].children produces a correct visual on the timeline.",
"significant_flags": 13,
"unresolved_flags": [
{
"id": "DEBT-129",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: the save/poll interaction guard still omits the -level plumbing needed to create a shared interaction ref before runs.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "DEBT-109",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: grouped cross-track move paths still route through and , but that file is not named in the rollback plan.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "issue_hints-1",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked , , and ; grouped cross-track moves, keyboard move-selected actions, and create-track-and-move still route through and or , but this file is not in the plan's likely-change list, so the approved cross-row group-move requirement is only partially covered.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "issue_hints-2",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked ; auto-sync currently preserves , reuses surviving clip durations when possible, shifts trailing actions by the delta, and reschedules itself while interactions are active. The plan metadata still leaves the preserve-vs-rebuild sync behavior open, but in this repository that choice affects existing layout semantics and should be resolved in the plan rather than deferred to implementation.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "correctness-1",
"concern": "Are the proposed changes technically correct?: Checked , , and ; the current session carries adjacent clip ids, paired preview overrides, and boundary clamps that the plain session does not. The plan's statement that group-edge and child-boundary sessions can collapse into the regular clip session is under-specified and would be incorrect unless the new clip session is expanded to keep that two-clip context.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "correctness-2",
"concern": "Are the proposed changes technically correct?: Checked and ; grouped drags onto a new track currently commit through a resolved-config path, not just or . The plan mentions simplifying , but it does not explicitly say how soft-tag metadata is rebuilt on that branch, so one live grouped-drag path remains technically under-specified.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "scope-1",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , and ; the projection model is not isolated to resize and rendering, because grouped movement logic also derives duration and extents from and , and some of those paths never pass through . The underlying problem is broader than the plan's named drag hooks unless is brought into scope too.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "scope-2",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , , , and ; these suites directly assert , , or behavior. The plan says 'all related tests', but the concrete test surface is broader than the files it names.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "all_locations-1",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked and ; is instantiated in , while the current is local to . The plan says to thread that ref into persistence and poll hooks, but the file list omits and any provider/context plumbing needed to create a shared ref before renders.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "all_locations-2",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked , , and ; and still normalize groups to include and , and the validation test explicitly expects that expanded shape. The plan names , but the supporting validation surface is not called out and will fail unless it is updated in the same change.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "callers-1",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the grouped-move branches in ; single-clip cross-track drags call , same-track grouped drags emit , and grouped drags onto a new track emit with . The plan discusses generally, but it does not explicitly cover all three caller shapes, especially the new-track config branch.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "callers-2",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked , , and ; is called by drag, keyboard track moves, and batch move-selected operations, and when the clip belongs to a pinned group it immediately routes through . Because that caller fan-out already exists, leaving out of the plan would leave multiple entry points on the old model.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "callers-3",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked and ; callers that mutate groups today pass full geometry-bearing payloads (, , ), not just . The plan's wording about keeping a few lookup helpers understates how many call sites need signature changes once becomes a soft tag.",
"category": "correctness",
"severity": "significant",
"status": "open"
}
],
"resolved_flags": [],
"weighted_score": 22.0,
"weighted_history": [],
"plan_delta_from_previous": null,
"recurring_critiques": [],
"scope_creep_flags": [],
"loop_summary": "Iteration 1. Weighted score trajectory: 22.0. Plan deltas: n/a. Recurring critiques: 0. Resolved flags: 0. Open significant flags: 13.",
"debt_overlaps": [],
"escalated_debt_subsystems": []
},
"flag_resolutions": [],
"resolved_flag_ids": [],
"resolution_summary": ""
}
code
Open significant flags:
[
{
"id": "DEBT-129",
"severity": "significant",
"status": "open",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: the save/poll interaction guard still omits the useTimelineState.ts-level plumbing needed to create a shared interaction ref before useTimelineSave() runs.",
"evidence": "useTimelineSave() is created in src/tools/video-editor/hooks/useTimelineState.ts:38-44, but the existing interactionStateRef is local to src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx:191-204. The plan's named files for save gating do not include that ownership bridge."
},
{
"id": "DEBT-109",
"severity": "significant",
"status": "open",
"concern": "Does the change touch all locations and supporting infrastructure: Recurring debt: grouped cross-track move paths still route through useTimelineTrackManagement.moveClipToRow() and createTrackAndMoveClip(), but that file is not named in the rollback plan.",
"evidence": "Grouped moves are still handled in src/tools/video-editor/hooks/useTimelineTrackManagement.ts:88-115, src/tools/video-editor/hooks/useTimelineTrackManagement.ts:183-213, and src/tools/video-editor/hooks/useTimelineTrackManagement.ts:289-427, all of which depend on moveGroup() and projection-era pinned-group state."
},
{
"id": "issue_hints-1",
"severity": "significant",
"status": "open",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked src/tools/video-editor/hooks/useTimelineTrackManagement.ts:88-115, src/tools/video-editor/hooks/useTimelineTrackManagement.ts:183-213, and src/tools/video-editor/hooks/useTimelineTrackManagement.ts:289-427; grouped cross-track moves, keyboard move-selected actions, and create-track-and-move still route through moveGroup() and type: 'pinnedShotGroups' or pinnedShotGroupsOverride, but this file is not in the plan's likely-change list, so the approved cross-row group-move requirement is only partially covered.",
"evidence": "Checked src/tools/video-editor/hooks/useTimelineTrackManagement.ts:88-115, src/tools/video-editor/hooks/useTimelineTrackManagement.ts:183-213, and src/tools/video-editor/hooks/useTimelineTrackManagement.ts:289-427; grouped cross-track moves, keyboard move-selected actions, and create-track-and-move still route through moveGroup() and type: 'pinnedShotGroups' or pinnedShotGroupsOverride, but this file is not in the plan's likely-change list, so the approved cross-row group-move requirement is only partially covered."
},
{
"id": "issue_hints-2",
"severity": "significant",
"status": "open",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked ; auto-sync currently preserves , reuses surviving clip durations when possible, shifts trailing actions by the delta, and reschedules itself while interactions are active. The plan metadata still leaves the preserve-vs-rebuild sync behavior open, but in this repository that choice affects existing layout semantics and should be resolved in the plan rather than deferred to implementation.",
"evidence": "Checked ; auto-sync currently preserves , reuses surviving clip durations when possible, shifts trailing actions by the delta, and reschedules itself while interactions are active. The plan metadata still leaves the preserve-vs-rebuild sync behavior open, but in this repository that choice affects existing layout semantics and should be resolved in the plan rather than deferred to implementation."
},
{
"id": "correctness-1",
"severity": "significant",
"status": "open",
"concern": "Are the proposed changes technically correct?: Checked , , and ; the current session carries adjacent clip ids, paired preview overrides, and boundary clamps that the plain session does not. The plan's statement that group-edge and child-boundary sessions can collapse into the regular clip session is under-specified and would be incorrect unless the new clip session is expanded to keep that two-clip context.",
"evidence": "Checked , , and ; the current session carries adjacent clip ids, paired preview overrides, and boundary clamps that the plain session does not. The plan's statement that group-edge and child-boundary sessions can collapse into the regular clip session is under-specified and would be incorrect unless the new clip session is expanded to keep that two-clip context."
},
{
"id": "correctness-2",
"severity": "significant",
"status": "open",
"concern": "Are the proposed changes technically correct?: Checked and ; grouped drags onto a new track currently commit through a resolved-config path, not just or . The plan mentions simplifying , but it does not explicitly say how soft-tag metadata is rebuilt on that branch, so one live grouped-drag path remains technically under-specified.",
"evidence": "Checked and ; grouped drags onto a new track currently commit through a resolved-config path, not just or . The plan mentions simplifying , but it does not explicitly say how soft-tag metadata is rebuilt on that branch, so one live grouped-drag path remains technically under-specified."
},
{
"id": "scope-1",
"severity": "significant",
"status": "open",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , and ; the projection model is not isolated to resize and rendering, because grouped movement logic also derives duration and extents from and , and some of those paths never pass through . The underlying problem is broader than the plan's named drag hooks unless is brought into scope too.",
"evidence": "Checked , , and ; the projection model is not isolated to resize and rendering, because grouped movement logic also derives duration and extents from and , and some of those paths never pass through . The underlying problem is broader than the plan's named drag hooks unless is brought into scope too."
},
{
"id": "scope-2",
"severity": "significant",
"status": "open",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked , , , , and ; these suites directly assert , , or behavior. The plan says 'all related tests', but the concrete test surface is broader than the files it names.",
"evidence": "Checked , , , , and ; these suites directly assert , , or behavior. The plan says 'all related tests', but the concrete test surface is broader than the files it names."
},
{
"id": "all_locations-1",
"severity": "significant",
"status": "open",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked and ; is instantiated in , while the current is local to . The plan says to thread that ref into persistence and poll hooks, but the file list omits and any provider/context plumbing needed to create a shared ref before renders.",
"evidence": "Checked and ; is instantiated in , while the current is local to . The plan says to thread that ref into persistence and poll hooks, but the file list omits and any provider/context plumbing needed to create a shared ref before renders."
},
{
"id": "all_locations-2",
"severity": "significant",
"status": "open",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked , , and ; and still normalize groups to include and , and the validation test explicitly expects that expanded shape. The plan names , but the supporting validation surface is not called out and will fail unless it is updated in the same change.",
"evidence": "Checked , , and ; and still normalize groups to include and , and the validation test explicitly expects that expanded shape. The plan names , but the supporting validation surface is not called out and will fail unless it is updated in the same change."
},
{
"id": "callers-1",
"severity": "significant",
"status": "open",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the grouped-move branches in ; single-clip cross-track drags call , same-track grouped drags emit , and grouped drags onto a new track emit with . The plan discusses generally, but it does not explicitly cover all three caller shapes, especially the new-track config branch.",
"evidence": "Checked the grouped-move branches in ; single-clip cross-track drags call , same-track grouped drags emit , and grouped drags onto a new track emit with . The plan discusses generally, but it does not explicitly cover all three caller shapes, especially the new-track config branch."
},
{
"id": "callers-2",
"severity": "significant",
"status": "open",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked , , and ; is called by drag, keyboard track moves, and batch move-selected operations, and when the clip belongs to a pinned group it immediately routes through . Because that caller fan-out already exists, leaving out of the plan would leave multiple entry points on the old model.",
"evidence": "Checked , , and ; is called by drag, keyboard track moves, and batch move-selected operations, and when the clip belongs to a pinned group it immediately routes through . Because that caller fan-out already exists, leaving out of the plan would leave multiple entry points on the old model."
},
{
"id": "callers-3",
"severity": "significant",
"status": "open",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked and ; callers that mutate groups today pass full geometry-bearing payloads (, , ), not just . The plan's wording about keeping a few lookup helpers understates how many call sites need signature changes once becomes a soft tag.",
"evidence": "Checked and ; callers that mutate groups today pass full geometry-bearing payloads (, , ), not just . The plan's wording about keeping a few lookup helpers understates how many call sites need signature changes once becomes a soft tag."
}
]
code
Requirements:
- Before addressing individual flags, check: does any flag suggest the plan is targeting the wrong code or the wrong root cause? If so, consider whether the plan needs a new approach rather than adjustments. Explain your reasoning.
- Update the plan to address the significant issues.
- Keep the plan readable and executable.
- Return flags_addressed with the exact flag IDs you addressed.
- Preserve or improve success criteria quality. Each criterion must have a `priority` of `must`, `should`, or `info`. Promote or demote priorities if critique feedback reveals a criterion was over- or under-weighted.
- Verify that the plan remains aligned with the user's original intent, not just internal plan quality.
- Remove unjustified scope growth. If critique raised scope creep, narrow the plan back to the original idea unless the broader work is strictly required.
- Maintain the structural template: H1 title, ## Overview, phase sections with numbered step sections, ## Execution Order or ## Validation Order.
Plan template — simple format (adapt to the actual repo and scope):
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
{"plan":"# Implementation Plan: Structural Rollback Of Projection-Based Shot Groups\n\n## Overview\nThe gate feedback does not suggest a different root cause. It confirms the same root cause is still correct: the projection layer is wrong, but the first draft under-scoped how many caller paths and support layers still depend on group.start and group.children. The revision keeps the same rollback strategy and expands scope only where that old model is still live: useTimelineState.ts for shared interaction ownership, useTimelineTrackManagement.ts for non-drag group moves, timeline-data.ts for save-time shape re-expansion, the new-track drag/config branch, and the broader test surface that asserts the legacy shape.\n\nThis remains a video-editor-only refactor. No DB or edge-function work. The goal is still structural removal of projection, not a broader cleanup. Policy choices that were previously left open are now settled in the plan so implementation is executable:\n1. (shotId, trackId) remains the group identity.\n2. Auto-sync in usePinnedShotGroups.ts preserves the current live layout of surviving clips, appends new clips at the group's current live end using the current average duration fallback, removes missing clips, and shifts trailing actions by the net duration delta.\n3. Deferred save/poll/conflict handling keeps only the newest pending payload and re-evaluates it immediately when the interaction clears.\n\n## Phase 1: Foundation - Shared Interaction State, Types, Migration\n\n### Step 1: Create a shared interaction state before save/poll hooks run\nScope: Medium\n1. Move ownership of interactionStateRef from src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx into src/tools/video-editor/hooks/useTimelineState.ts so it exists before useTimelineSave() is instantiated.\n2. Thread that shared ref through src/tools/video-editor/hooks/useTimelineSave.ts, src/tools/video-editor/hooks/useTimelinePersistence.ts, and src/tools/video-editor/hooks/usePollSync.ts, then pass it down to TimelineEditor and TimelineCanvas for drag/resize lifecycle updates.\n3. Keep useClipDrag.ts and TimelineCanvas.tsx as the only places that flip drag and resize, but make persistence and poll-sync read the same ref instead of a component-local copy.\n4. Add focused coverage for the ownership bridge so the save/poll gating is proven at the hook level rather than implied by UI wiring.\n\n### Step 2: Replace the group shape and stop re-expanding it during save\nScope: Large\n1. Update src/tools/video-editor/types/index.ts so PinnedShotGroup only contains shotId, trackId, clipIds, mode, videoAssetKey, and imageClipSnapshot.\n2. Update src/tools/video-editor/lib/migrate.ts so repairConfig() converts legacy start plus children groups into soft tags on load by deriving clipIds from children and dropping legacy fields.\n3. Update src/tools/video-editor/lib/timeline-data.ts to remove legacy-shape cloning in clonePinnedShotGroups() and to make rowsToConfig() preserve soft-tag groups instead of fabricating start: 0 and children: [].\n4. Remove projection from src/tools/video-editor/lib/timeline-data.ts and src/tools/video-editor/lib/timeline-save-utils.ts so neither runtime assembly nor save-time rebuild re-derives clips from group geometry.\n5. Keep src/tools/video-editor/lib/serialize.ts and its tests aligned with the one-way migration rule: load old shape, save new shape only.\n6. Update src/tools/video-editor/lib/render-bounds.validation.test.ts and any validation surface that still expects the expanded legacy shape.\n\n## Phase 2: Shrink The Helper Layer And Rebuild Group Mutations\n\n### Step 3: Delete projection helpers and rewrite geometry-bearing callers\nScope: Large\n1. Strip src/tools/video-editor/lib/pinned-group-projection.ts down to only helpers that still make sense in the soft-tag model, such as findEnclosingPinnedGroup, categorizeSelection, and a small ordering helper for live clipIds.\n2. Remove projectPinnedShotGroups, moveGroup, resizeGroupEdge, resizeChildBoundary, replaceGroupChildren, buildGroupFromChildren, buildGroupFromConfigClips, and related normalization code.\n3. Update src/tools/video-editor/hooks/usePinnedShotGroups.ts, src/tools/video-editor/hooks/useSwitchToFinalVideo.ts, and src/tools/video-editor/hooks/useExternalDrop.ts so all group writes are soft-tag writes, not geometry-bearing payloads.\n4. Rebuild usePinnedGroupSync() around the settled preserve-layout policy: derive current group bounds from live actions, preserve reusable clip durations and order, append new generated clips at the live end, remove missing clip ids, shift trailing actions by the net delta, and keep deferral during active interactions.\n5. Rewrite src/tools/video-editor/lib/pinned-group-projection.test.ts, replace src/tools/video-editor/lib/pinned-group-cohesion.test.ts, and update src/tools/video-editor/lib/serialize.test.ts to match the new helper and save contract.\n\n## Phase 3: Edit Operations Become The Cohesion Layer\n\n### Step 4: Rebuild grouped resize semantics without projection\nScope: Large\n1. In src/tools/video-editor/hooks/useClipResize.ts, replace grouped resize commits so timing edits always go through applyEdit({ type: 'rows' }) with direct clip mutations and source-time metadata patches.\n2. Implement the three required semantics explicitly: first clip left edge edits only that clip, last clip right edge edits only that clip, and interior boundary edits only the dragged clip plus its adjacent neighbor while keeping the outer boundary fixed.\n3. Reuse the existing free-clip trim math for visual and audio media so grouped resizes do not invent a second source-time algorithm.\n4. Remove startGroupEdgeResize from the runtime contract, but do not oversimplify the canvas session model: keep enough session context in TimelineCanvas.tsx to track adjacent clip ids, paired preview overrides, and clamp bounds for interior boundaries.\n5. Add focused tests for each resize semantic and a multi-step cohesion regression that proves later edits are not reverted.\n\n### Step 5: Cover every grouped move caller, including keyboard and new-track paths\nScope: Large\n1. Bring src/tools/video-editor/hooks/useTimelineTrackManagement.ts fully into scope alongside src/tools/video-editor/hooks/useClipDrag.ts and src/tools/video-editor/lib/multi-drag-utils.ts so grouped movement logic is fixed in drag, keyboard move-selected, batch move-selected, moveClipToRow(), and createTrackAndMoveClip().\n2. Replace all uses of moveGroup() and projection-era group extents with direct translation of member actions plus soft-tag updates to trackId and ordered clipIds.\n3. Explicitly handle all three live grouped-drag caller shapes in useClipDrag.ts: same-track grouped drag, grouped drag to an existing row, and grouped drag to a newly created row.\n4. Refactor buildAugmentedData(), applyMultiDragMoves(), and buildConfigFromDragResult() so the new-track branch returns an atomic result that includes moved rows, meta updates, clip order, and next soft-tag groups; when type: 'config' is still needed to add a track, it must carry rebuilt soft-tag metadata in the same commit rather than falling back to projection.\n5. Update overlap handling only where it is still needed for clip placement, and remove any remaining dependency on group.start or group.children from multi-drag utilities.\n\n### Step 6: Simplify the commit path so groups are metadata, not geometry\nScope: Medium\n1. Collapse src/tools/video-editor/hooks/useTimelineCommit.ts so the pinnedShotGroups mutation path no longer projects or repairs clip timing.\n2. Keep clip-timing edits on the rows path; reserve direct group mutations for pin, unpin, mode changes, track-id updates, and clip-id membership/order changes only.\n3. Update clip-editing callers that still assert type: 'pinnedShotGroups' behavior so they now assert soft-tag metadata changes or pinnedShotGroupsOverride on row/config edits, as appropriate.\n\n## Phase 4: Rendering And Context Simplification\n\n### Step 7: Render shot groups from live row actions and remove the prop chain\nScope: Medium\n1. Simplify src/tools/video-editor/hooks/useShotGroups.ts so it resolves display data from live clipIds and track ids only; no start, children, or projection-derived row geometry.\n2. In src/tools/video-editor/components/TimelineEditor/TimelineCanvas.tsx, compute positioned shot groups from the current row actions using earliest live start and latest live end, with degraded rendering if some clip ids are missing.\n3. Remove TimelineShotGroupResize and startGroupEdgeResize from src/tools/video-editor/hooks/useTimelineState.types.ts, src/tools/video-editor/hooks/useTimelineState.contexts.ts, src/tools/video-editor/contexts/VideoEditorProvider.tsx, and src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx.\n4. Keep the UI behavior the brief cares about: shot borders never disappear because of a projection/filter pass, shot label menu actions still work, and per-clip context-menu lockdown still works.\n\n## Phase 5: Prove The Rollback Across The Full Test Surface\n\n### Step 8: Update the broader regression surface and run validation in layers\nScope: Medium\n1. Update the explicitly affected suites, not just the helper tests: src/tools/video-editor/lib/render-bounds.validation.test.ts, src/tools/video-editor/hooks/useTimelineTrackManagement.test.ts, src/tools/video-editor/hooks/useExternalDrop.test.tsx, src/tools/video-editor/hooks/useClipEditing.test.ts, src/tools/video-editor/hooks/useClipDrag.test.tsx, src/tools/video-editor/hooks/useShotGroups.test.ts, src/tools/video-editor/components/TimelineEditor/TimelineCanvas.test.tsx, src/tools/video-editor/lib/timeline-save-utils.test.ts, src/tools/video-editor/lib/serialize.test.ts, and the rewritten pinned-group tests.\n2. Add new coverage for legacy migration, each edit semantic, save gating during interaction, deferred poll/conflict handling, and cohesion through a sequence of drag/resize/switch/delete operations.\n3. Run cheap validation first: migration and serialization tests, then resize and drag tests, then track-management and persistence tests, then npx tsc --noEmit, then the full video-editor suite.\n4. Confirm the only tolerated remaining red is the known unrelated pre-existing TimelineCanvas assertion if it still exists unchanged.\n5. Compare line count and helper surface in the shot-group files to verify the rollback actually removed machinery rather than wrapping it.\n\n## Execution Order\n1. Land the shared interaction-state bridge and the shape/migration changes first so save gating and soft-tag serialization have a stable foundation.\n2. Delete projection helpers and update all geometry-bearing callers before touching render polish.\n3. Rewrite grouped resize and grouped movement entry points together so no alternate caller path keeps the old model alive.\n4. Remove the prop chain and projection-era render fields after behavior is correct.\n5. Finish with the broader regression sweep and final typecheck/suite run.\n\n## Validation Order\n1. Start with migration and serialization tests because they prove legacy load plus new-shape save immediately.\n2. Run focused resize, drag, and track-management tests right after each operation rewrite so the semantics are locked before UI cleanup.\n3. Validate save/poll gating at the hook level before relying on browser behavior.\n4. End with npx tsc --noEmit and the full video-editor suite.","questions":[],"success_criteria":[{"criterion":"Loading a config with legacy pinnedShotGroups[].children yields runtime groups in the new soft-tag shape, and saving that same timeline emits no start or children fields.","priority":"must"},{"criterion":"rowsToConfig(), clonePinnedShotGroups(), and all load/save/commit paths preserve the soft-tag shape instead of re-expanding legacy geometry.","priority":"must"},{"criterion":"Dragging the right edge of the last clip in a shot changes only that clip's duration and the group's rendered right boundary follows.","priority":"must"},{"criterion":"Dragging the left edge of the first clip in a shot changes only that clip's start or duration and the group's rendered left boundary follows.","priority":"must"},{"criterion":"Dragging an interior boundary inside a shot changes only the two adjacent clips while preserving the rest of the group.","priority":"must"},{"criterion":"Grouped moves work through every live caller path: drag to same row, drag to another existing row, drag to a new row, keyboard move-selected, and track-management move helpers all update clips plus the group's trackId without projection-era helpers.","priority":"must"},{"criterion":"Auto-save does not execute during an active drag or resize interaction, and the newest pending save flushes after the interaction ends.","priority":"must"},{"criterion":"Poll-sync and conflict reloads do not overwrite local edits during an active drag or resize interaction; deferred remote work is re-evaluated after the interaction ends.","priority":"must"},{"criterion":"Shot label menu actions and per-clip context-menu lockdown still work under the soft-tag model.","priority":"must"},{"criterion":"For an unchanged timeline, the clip-level data consumed by Remotion preview is unchanged before and after the rollback.","priority":"must"},{"criterion":"npx tsc --noEmit passes.","priority":"must"},{"criterion":"The video-editor test suite passes after updating intentional expectations, with no new failures beyond the known unrelated pre-existing TimelineCanvas assertion if it still remains.","priority":"must"},{"criterion":"Net LOC or helper surface across shot-group-specific files decreases after removing projection machinery.","priority":"should"},{"criterion":"Manual browser smoke testing confirms the two reported resize and save-reset symptoms no longer reproduce.","priority":"info"}],"assumptions":["The projection layer remains the correct root cause to remove; the critique identified missing caller paths and ownership bridges, not a better alternative architecture.","(shotId, trackId) remains the identity for a pinned group, and this refactor does not introduce a new stable group id.","usePinnedGroupSync() should preserve the current live layout of surviving clips, append new clips at the group's current live end using the current average-duration fallback, remove missing clips, and shift trailing actions by the net delta.","If save or poll work is deferred during an interaction, the implementation should keep only the latest pending item and re-evaluate it immediately once the interaction clears.","Scope expansion is limited to direct callers and support layers that would otherwise keep projection alive: useTimelineState.ts, useTimelineTrackManagement.ts, timeline-data.ts, the new-track drag/config branch, and the affected regression tests."],"flags_addressed":["DEBT-129","DEBT-109","issue_hints-1","issue_hints-2","correctness-1","correctness-2","scope-1","scope-2","all_locations-1","all_locations-2","callers-1","callers-2","callers-3"]}
“You are creating an implementation plan for the following idea. Idea: Roll back the….” Conversation with gpt-5.4, from the Peter O’Mallet DataClaw Conversations dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m80eq4scyv6y1jwn1mgpeefs