Skip to content

Conversation

@joepduin
Copy link

@joepduin joepduin commented Oct 25, 2025

Description

  • Add horizontal/vertical flip flags to media elements and persist them in the timeline store/history.
  • Expose mirroring controls in the properties panel and let a single toggle apply to all selected clips.
  • Update the renderer (preview + blur backgrounds) to honor mirror state so the preview reflects the applied flip.
  • Harden preview panel async calls (error logging) touched while integrating mirroring.

Fixes: n/a

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Manual UI check: launched bun run dev, opened the editor, selected multiple media clips, toggled both flip buttons and confirmed preview updates for every selected clip.
  • Formatting/lint pass: bunx biome format --write . (root), bun run lint (apps/web)

Test Configuration:

  • Node version: v22.17.0
  • Browser: Brave v1.83.120
  • Operating System: Ubuntu v24.04.2 LTS

Screenshots (if applicable)

Transform UI:
transform

Before:
before

After:
after

Video:
https://github.com/user-attachments/assets/fd80223f-dedb-4635-bed4-829d4f388ea4

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have added screenshots if UI has been changed
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

The selection-aware toggle ensures mirror state stays consistent when editing multiple clips at once while keeping undo/redo history intact.

Summary by CodeRabbit

  • New Features
    • Added horizontal and vertical flip controls for media elements in the properties panel.
    • Timeline thumbnails and previews reflect media flips (mirrored thumbnails and playback).
    • Flip state is preserved in caching and persists during playback and timeline updates.
  • Chores
    • Exposed media properties so flip controls work across the properties panel and timeline.

@vercel
Copy link

vercel bot commented Oct 25, 2025

@joepduin is attempting to deploy a commit to the OpenCut OSS Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link

netlify bot commented Oct 25, 2025

👷 Deploy request for appcut pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6781df5

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2025

Walkthrough

Adds media flip support: UI controls now pass a trackId to MediaProperties (and media flip controls re-export MediaProperties), a toggleMediaFlip store action updates element.transform, canvas drawing uses a drawWithFlip helper, types include MediaTransform, and frame-cache/timeline rendering account for flips.

Changes

Cohort / File(s) Summary
UI Controls
apps/web/src/components/editor/properties-panel/media-properties.tsx, apps/web/src/components/editor/properties-panel/index.tsx, apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
MediaProperties now accepts trackId (via MediaPropertiesProps) and element; properties panel passes trackId for media elements. media-flip-controls.tsx re-exports MediaProperties. UI renders flip buttons that call toggleMediaFlip(trackId, element.id, axis).
State Management
apps/web/src/stores/timeline-store.ts
Added public action toggleMediaFlip(trackId, elementId, axis) which validates media type, pushes history, toggles flipHorizontal/flipVertical on the target element's transform, clears transform if no flips remain, and saves tracks.
Type Definitions
apps/web/src/types/timeline.ts
Introduced MediaTransform interface with optional flipHorizontal and flipVertical; added optional transform?: MediaTransform to MediaElement.
Timeline Element Rendering
apps/web/src/components/editor/timeline/timeline-element.tsx
Reads element.transform to compute flipHorizontal/flipVertical, sets previewTransform and adjusts backgroundPosition to reflect flips for timeline thumbnails.
Canvas Drawing
apps/web/src/lib/timeline-renderer.ts
Added drawWithFlip helper to apply centered horizontal/vertical flips via canvas transforms; wrapped media draw paths (background blur, video frames, images) with drawWithFlip and tightened media type guards.
Frame Caching
apps/web/src/hooks/use-frame-cache.ts
activeElements entries can include transform; transform flags are incorporated into the timeline hash so cached frames invalidate when flip state changes.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as MediaProperties
    participant Store as TimelineStore
    participant Cache as Frame Cache
    participant Renderer as Canvas Renderer

    User->>UI: Click flip (horizontal/vertical)
    UI->>Store: toggleMediaFlip(trackId, elementId, axis)
    activate Store
    Store->>Store: validate media, pushHistory(), toggle transform
    Store->>Store: updateTracksAndSave()
    deactivate Store

    Store->>Cache: update timeline hash (includes transform)
    activate Cache
    Cache->>Renderer: request re-render
    deactivate Cache

    activate Renderer
    Renderer->>Renderer: drawWithFlip(element, transform)
    Renderer->>Renderer: apply canvas transforms, ctx.drawImage()
    deactivate Renderer
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas requiring attention:
    • drawWithFlip math and correct save/restore canvas state in timeline-renderer.ts
    • Type guards and casts to MediaElement for background blur and media draw paths
    • Correctness of toggleMediaFlip (history push, track/element targeting, persistence)
    • Timeline hash changes in use-frame-cache.ts to ensure proper invalidation
    • UI prop flow: trackId propagation and re-export in media-flip-controls.tsx

Poem

🐇 I hopped to the canvas, a flip in my paws,

mirrored frames dancing without any flaws,
horizontal wiggles and vertical spins,
tracks now remember the flips they are in,
— a rabbit's small cheer for the code that wins.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "feat: add media flip controls" directly corresponds to the primary objective of the changeset, which is to introduce horizontal and vertical flip functionality for media elements with accompanying UI controls in the properties panel. The title uses the conventional commit format, is concise and unambiguous, and clearly communicates the core feature being added without unnecessary noise or vague terminology.
Description Check ✅ Passed The PR description comprehensively follows the provided template with all major sections completed: a detailed description summarizing the changes and motivations, the type of change clearly identified as a new feature, thorough testing documentation with specific steps and configuration details, multiple screenshots and a demo video showing the feature in action, and a fully completed checklist. The additional context explains the implementation approach regarding selection-aware toggles and undo/redo preservation, providing meaningful context for reviewers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/web/src/hooks/use-frame-cache.ts (1)

52-55: Consider referencing the MediaTransform type for consistency.

The inline transform type definition here could reference the MediaTransform type from @/types/timeline to maintain consistency and reduce duplication.

Apply this diff to reference the existing type:

+import type { MediaTransform } from "@/types/timeline";

 interface CachedFrame {
   imageData: ImageData;
   timelineHash: string;
   timestamp: number;
 }

And update the inline type:

       const activeElements: Array<{
         id: string;
         type: string;
         startTime: number;
         duration: number;
         trimStart: number;
         trimEnd: number;
         mediaId?: string;
-        transform?: {
-          flipHorizontal: boolean;
-          flipVertical: boolean;
-        };
+        transform?: Required<MediaTransform>;

Note: Using Required<MediaTransform> makes the booleans non-optional, matching the current behavior where both flags are always present in the cache hash.

apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx (1)

4-9: Remove unused imports.

Lines 6 and 7 import PropertyItem and PropertyItemLabel, but these are not used in the component.

Apply this diff to remove the unused imports:

 import {
   PropertyGroup,
-  PropertyItem,
-  PropertyItemLabel,
   PropertyItemValue,
 } from "./property-item";
apps/web/src/components/editor/properties-panel/media-properties.tsx (1)

4-9: Remove unused imports.

Lines 6 and 7 import PropertyItem and PropertyItemLabel, but these are not used in the component.

Apply this diff to remove the unused imports:

 import {
   PropertyGroup,
-  PropertyItem,
-  PropertyItemLabel,
   PropertyItemValue,
 } from "./property-item";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bee7aba and 22f8565.

📒 Files selected for processing (8)
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx (1 hunks)
  • apps/web/src/components/editor/properties-panel/index.tsx (1 hunks)
  • apps/web/src/components/editor/properties-panel/media-properties.tsx (1 hunks)
  • apps/web/src/components/editor/timeline/timeline-element.tsx (2 hunks)
  • apps/web/src/hooks/use-frame-cache.ts (2 hunks)
  • apps/web/src/lib/timeline-renderer.ts (8 hunks)
  • apps/web/src/stores/timeline-store.ts (2 hunks)
  • apps/web/src/types/timeline.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use TypeScript namespaces.
Don't use non-null assertions with the ! postfix operator.
Don't use parameter properties in class constructors.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use either T[] or Array<T> consistently.
Initialize each enum member value explicitly.
Use export type for types.
Use import type for types.
Make sure all enum members are literal values.
Don't use TypeScript const enum.
Don't declare empty interfaces.
Don't let variables evolve into any type through reassignments.
Don't use the any type.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use implicit any type on variable declarations.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use the TypeScript directive @ts-ignore.
Use consistent accessibility modifiers on class properties and methods.
Use function types instead of object types with call signatures.
Don't use void type outside of generic or return types.

**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Use either T[] or Array consistently
Don't use the any type

Files:

  • apps/web/src/types/timeline.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/index.tsx
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/components/editor/timeline/timeline-element.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{js,jsx,ts,tsx}: Don't use the return value of React.render.
Don't use consecutive spaces in regular expression literals.
Don't use the arguments object.
Don't use primitive type aliases or misleading types.
Don't use the comma operator.
Don't write functions that exceed a given Cognitive Complexity score.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names that aren't base 10 or use underscore separators.
Remove redundant terms from logical expressions.
Use while loops instead of...

Files:

  • apps/web/src/types/timeline.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/index.tsx
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/components/editor/timeline/timeline-element.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{ts,tsx,js,jsx}: Don't use the comma operator
Use for...of statements instead of Array.forEach
Don't initialize variables to undefined
Use .flatMap() instead of map().flat() when possible
Don't assign a value to itself
Avoid unused imports and variables
Don't use await inside loops
Don't hardcode sensitive data like API keys and tokens
Don't use the delete operator
Don't use global eval()
Use String.slice() instead of String.substr() and String.substring()
Don't use else blocks when the if block breaks early
Put default function parameters and optional function parameters last
Use new when throwing an error
Use String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight()

Files:

  • apps/web/src/types/timeline.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/index.tsx
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/components/editor/timeline/timeline-element.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{jsx,tsx}: Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Don't use distracting elements like <marquee> or <blink>.
Only use the scope prop on <th> elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Use semantic elements instead of role attributes in JSX.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with...

Files:

  • apps/web/src/components/editor/properties-panel/index.tsx
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/components/editor/timeline/timeline-element.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{tsx,jsx}: Always include a title element for icons unless there's text beside the icon
Always include a type attribute for button elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Don't import React itself
Don't define React components inside other components
Don't use both children and dangerouslySetInnerHTML on the same element
Don't insert comments as text nodes
Use <>...</> instead of ...

Files:

  • apps/web/src/components/editor/properties-panel/index.tsx
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/components/editor/timeline/timeline-element.tsx
🧠 Learnings (1)
📚 Learning: 2025-08-09T09:03:49.797Z
Learnt from: CR
PR: OpenCut-app/OpenCut#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-09T09:03:49.797Z
Learning: Applies to **/*.{jsx,tsx} : Include caption tracks for audio and video elements.

Applied to files:

  • apps/web/src/components/editor/properties-panel/index.tsx
🧬 Code graph analysis (4)
apps/web/src/components/editor/properties-panel/index.tsx (1)
apps/web/src/components/editor/properties-panel/media-properties.tsx (1)
  • MediaProperties (16-45)
apps/web/src/components/editor/properties-panel/media-properties.tsx (1)
apps/web/src/types/timeline.ts (1)
  • MediaElement (23-28)
apps/web/src/lib/timeline-renderer.ts (1)
apps/web/src/types/timeline.ts (2)
  • MediaTransform (17-20)
  • MediaElement (23-28)
apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx (3)
apps/web/src/types/timeline.ts (1)
  • MediaElement (23-28)
apps/web/src/components/editor/properties-panel/media-properties.tsx (1)
  • MediaProperties (16-45)
apps/web/src/stores/timeline-store.ts (1)
  • useTimelineStore (258-1912)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
apps/web/src/hooks/use-frame-cache.ts (2)

190-201: Remove console usage; avoid leaking hashes and noisy logs.

Console logging is disallowed per project guidelines and may expose state. Drop the logs or route to your structured logger behind a debug flag.

Apply this diff:

       const currentHash = getTimelineHash(
         time,
         tracks,
         mediaFiles,
         activeProject,
         sceneId
       );
-      console.log(cached.timelineHash === currentHash);
       if (cached.timelineHash !== currentHash) {
-        // Cache is stale, remove it
-        console.log(
-          "Cache miss - hash mismatch:",
-          JSON.stringify({
-            cachedHash: cached.timelineHash.slice(0, 100),
-            currentHash: currentHash.slice(0, 100),
-          })
-        );
+        // Cache is stale, remove it
         frameCacheRef.current.delete(frameKey);
         return null;
       }

And:

-          } catch (error) {
-            console.warn(`Pre-render failed for time ${time}:`, error);
-          }
+          } catch {
+            // Ignore pre-render failures; foreground render will retry
+          }

As per coding guidelines.

Also applies to: 339-341


22-28: Avoid any on the shared cache; type the global.

Replace the globalThis as any pattern with a typed global augmentation. This removes any and keeps HMR-safety.

Apply this diff:

-// Shared singleton cache across hook instances (HMR-safe)
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-const __frameCacheGlobal: any = globalThis as any;
-const __sharedFrameCache: Map<number, CachedFrame> =
-  __frameCacheGlobal.__sharedFrameCache ?? new Map<number, CachedFrame>();
-__frameCacheGlobal.__sharedFrameCache = __sharedFrameCache;
+// Shared singleton cache across hook instances (HMR-safe)
+declare global {
+  // eslint-disable-next-line no-var
+  var __sharedFrameCache: Map<number, CachedFrame> | undefined;
+}
+const __sharedFrameCache: Map<number, CachedFrame> =
+  globalThis.__sharedFrameCache ?? new Map<number, CachedFrame>();
+globalThis.__sharedFrameCache = __sharedFrameCache;

As per coding guidelines.

apps/web/src/lib/timeline-renderer.ts (1)

259-289: Avoid reloading images every frame; reuse the cached element.

Creating a new Image and awaiting load on every frame is a severe performance hit. Reuse getImageElement (already implemented above).

Apply this diff:

-        const img = new Image();
-        await new Promise<void>((resolve, reject) => {
-          img.onload = () => resolve();
-          img.onerror = () => reject(new Error("Image load failed"));
-          img.src = mediaItem.url || URL.createObjectURL(mediaItem.file);
-        });
+        const img = await getImageElement(mediaItem);
🧹 Nitpick comments (4)
apps/web/src/hooks/use-frame-cache.ts (2)

272-281: Guard requestIdleCallback for SSR and browsers lacking it.

Provide a safe fallback to setTimeout to avoid ReferenceErrors during SSR or older engines.

Apply this diff:

-      // Pre-render during idle time
-      for (const time of toSchedule) {
-        requestIdleCallback(async () => {
+      // Pre-render during idle time
+      const schedule = (fn: () => void) => {
+        const ric = (globalThis as unknown as { requestIdleCallback?: (cb: () => void) => number }).requestIdleCallback;
+        return typeof ric === "function" ? ric(fn) : setTimeout(fn, 0);
+      };
+      for (const time of toSchedule) {
+        schedule(async () => {
           try {
             const imageData = await renderFunction(time);
             cacheFrame(
               time,
               imageData,
               tracks,
               mediaFiles,
               activeProject,
               sceneId
             );
           } catch {
             // Ignore pre-render failures; foreground render will retry
           }
-        });
+        });
       }

Also applies to: 327-343


2-9: Use import type for type-only imports.

These imports are types only; switch to import type to avoid unnecessary runtime bindings.

Apply this diff:

-import {
-  TimelineTrack,
-  TimelineElement,
-  MediaElement,
-  TextElement,
-} from "@/types/timeline";
-import { MediaFile } from "@/types/media";
-import { TProject } from "@/types/project";
+import type {
+  TimelineTrack,
+  TimelineElement,
+  MediaElement,
+  TextElement,
+} from "@/types/timeline";
+import type { MediaFile } from "@/types/media";
+import type { TProject } from "@/types/project";

As per coding guidelines.

apps/web/src/stores/timeline-store.ts (1)

879-932: Element-level flip toggle logic is solid; consider a selection-aware variant.

The per-element toggle correctly creates/removes transform and preserves booleans. To match the PR goal of “single toggle applies to all selected clips,” add a bulk action mirroring toggleSelectedHidden/Muted, or confirm the UI loops over selectedElements.

Proposed addition:

 interface TimelineStore {
   ...
+  toggleSelectedFlip: (
+    axis: "horizontal" | "vertical",
+    trackId?: string,
+    elementId?: string
+  ) => void;
 }

And implementation (near other selection-aware actions):

+    toggleSelectedFlip: (axis, trackId?, elementId?) => {
+      const { selectedElements, _tracks } = get();
+      const targets =
+        trackId && elementId
+          ? [{ trackId, elementId }]
+          : selectedElements.length > 0
+            ? selectedElements
+            : [];
+      if (targets.length === 0) return;
+      get().pushHistory();
+      updateTracksAndSave(
+        _tracks.map((track) => ({
+          ...track,
+          elements: track.elements.map((el) => {
+            const shouldUpdate = targets.some(
+              ({ trackId: tId, elementId: eId }) =>
+                tId === track.id && eId === el.id
+            );
+            if (!shouldUpdate || el.type !== "media") return el;
+            const curr = el.transform || {};
+            const key = axis === "horizontal" ? "flipHorizontal" : "flipVertical";
+            const toggled = !curr[key as keyof typeof curr];
+            const next = {
+              flipHorizontal: key === "flipHorizontal" ? toggled : !!curr.flipHorizontal,
+              flipVertical: key === "flipVertical" ? toggled : !!curr.flipVertical,
+            };
+            const hasAny = next.flipHorizontal || next.flipVertical;
+            return { ...el, transform: hasAny ? next : undefined };
+          }),
+        }))
+      );
+    },

If the UI already iterates over selection, please confirm. Based on PR objectives.

apps/web/src/components/editor/properties-panel/media-properties.tsx (1)

16-45: Wire-up looks good; add a11y states and explicit button type.

Expose toggle state via aria-pressed and set type="button" to avoid accidental form submits in nested forms.

Apply this diff:

         <PropertyItemValue>
           <div className="flex gap-2">
             <Button
               variant={flipHorizontal ? "default" : "outline"}
               size="sm"
+              type="button"
+              aria-pressed={flipHorizontal}
               onClick={() => toggleMediaFlip(trackId, element.id, "horizontal")}
             >
               Flip Horizontal
             </Button>
             <Button
               variant={flipVertical ? "default" : "outline"}
               size="sm"
+              type="button"
+              aria-pressed={flipVertical}
               onClick={() => toggleMediaFlip(trackId, element.id, "vertical")}
             >
               Flip Vertical
             </Button>
           </div>
         </PropertyItemValue>

As per coding guidelines.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22f8565 and 6781df5.

📒 Files selected for processing (7)
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx (1 hunks)
  • apps/web/src/components/editor/properties-panel/media-properties.tsx (1 hunks)
  • apps/web/src/components/editor/timeline/timeline-element.tsx (2 hunks)
  • apps/web/src/hooks/use-frame-cache.ts (2 hunks)
  • apps/web/src/lib/timeline-renderer.ts (8 hunks)
  • apps/web/src/stores/timeline-store.ts (2 hunks)
  • apps/web/src/types/timeline.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/src/components/editor/properties-panel/flip/media-flip-controls.tsx
  • apps/web/src/types/timeline.ts
  • apps/web/src/components/editor/timeline/timeline-element.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use TypeScript namespaces.
Don't use non-null assertions with the ! postfix operator.
Don't use parameter properties in class constructors.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use either T[] or Array<T> consistently.
Initialize each enum member value explicitly.
Use export type for types.
Use import type for types.
Make sure all enum members are literal values.
Don't use TypeScript const enum.
Don't declare empty interfaces.
Don't let variables evolve into any type through reassignments.
Don't use the any type.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use implicit any type on variable declarations.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use the TypeScript directive @ts-ignore.
Use consistent accessibility modifiers on class properties and methods.
Use function types instead of object types with call signatures.
Don't use void type outside of generic or return types.

**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Use either T[] or Array consistently
Don't use the any type

Files:

  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{js,jsx,ts,tsx}: Don't use the return value of React.render.
Don't use consecutive spaces in regular expression literals.
Don't use the arguments object.
Don't use primitive type aliases or misleading types.
Don't use the comma operator.
Don't write functions that exceed a given Cognitive Complexity score.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names that aren't base 10 or use underscore separators.
Remove redundant terms from logical expressions.
Use while loops instead of...

Files:

  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{ts,tsx,js,jsx}: Don't use the comma operator
Use for...of statements instead of Array.forEach
Don't initialize variables to undefined
Use .flatMap() instead of map().flat() when possible
Don't assign a value to itself
Avoid unused imports and variables
Don't use await inside loops
Don't hardcode sensitive data like API keys and tokens
Don't use the delete operator
Don't use global eval()
Use String.slice() instead of String.substr() and String.substring()
Don't use else blocks when the if block breaks early
Put default function parameters and optional function parameters last
Use new when throwing an error
Use String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight()

Files:

  • apps/web/src/lib/timeline-renderer.ts
  • apps/web/src/hooks/use-frame-cache.ts
  • apps/web/src/stores/timeline-store.ts
  • apps/web/src/components/editor/properties-panel/media-properties.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{jsx,tsx}: Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Don't use distracting elements like <marquee> or <blink>.
Only use the scope prop on <th> elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Use semantic elements instead of role attributes in JSX.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with...

Files:

  • apps/web/src/components/editor/properties-panel/media-properties.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{tsx,jsx}: Always include a title element for icons unless there's text beside the icon
Always include a type attribute for button elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Don't import React itself
Don't define React components inside other components
Don't use both children and dangerouslySetInnerHTML on the same element
Don't insert comments as text nodes
Use <>...</> instead of ...

Files:

  • apps/web/src/components/editor/properties-panel/media-properties.tsx
🧬 Code graph analysis (2)
apps/web/src/lib/timeline-renderer.ts (1)
apps/web/src/types/timeline.ts (2)
  • MediaTransform (18-21)
  • MediaElement (24-29)
apps/web/src/components/editor/properties-panel/media-properties.tsx (2)
apps/web/src/types/timeline.ts (1)
  • MediaElement (24-29)
apps/web/src/components/editor/properties-panel/property-item.tsx (2)
  • PropertyGroup (63-86)
  • PropertyItemValue (45-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review
🔇 Additional comments (5)
apps/web/src/hooks/use-frame-cache.ts (1)

52-56: Good call: include flip transform in the cache key.

Hashing flipHorizontal/flipVertical ensures cache invalidates on mirror changes. This aligns the cache with rendering.

Also applies to: 92-97

apps/web/src/lib/timeline-renderer.ts (3)

26-53: drawWithFlip is correct and self-contained.

Center-based translate/scale/restore is clean and side-effect-safe. Good reuse point.


141-148: Background blur respects flip.

Applying drawWithFlip to the blur cover keeps background consistent with foreground mirroring. LGTM.

Also applies to: 169-177, 200-208


219-220: Video rendering path uses flip correctly.

The transform is applied around the draw rect; no additional changes needed.

Also applies to: 242-250

apps/web/src/stores/timeline-store.ts (1)

130-134: Public API surface addition is consistent.

The toggleMediaFlip signature matches other actions and is discoverable on the store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant