From 2f3a148dd4808a69619758b8640110b1aa859217 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 25 Jun 2025 23:22:59 +0200 Subject: refactor: move debug component to separate component and place absolutely --- apps/web/src/components/development-debug.tsx | 107 ++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 apps/web/src/components/development-debug.tsx (limited to 'apps/web/src/components/development-debug.tsx') diff --git a/apps/web/src/components/development-debug.tsx b/apps/web/src/components/development-debug.tsx new file mode 100644 index 00000000..aef69999 --- /dev/null +++ b/apps/web/src/components/development-debug.tsx @@ -0,0 +1,107 @@ +"use client"; + +import { + useTimelineStore, + type TimelineClip, + type TimelineTrack, +} from "@/stores/timeline-store"; +import { useMediaStore, type MediaItem } from "@/stores/media-store"; +import { usePlaybackStore } from "@/stores/playback-store"; +import { Button } from "@/components/ui/button"; +import { useState } from "react"; + +// Only show in development +const SHOW_DEBUG_INFO = process.env.NODE_ENV === "development"; + +interface ActiveClip { + clip: TimelineClip; + track: TimelineTrack; + mediaItem: MediaItem | null; +} + +export function DevelopmentDebug() { + const { tracks } = useTimelineStore(); + const { mediaItems } = useMediaStore(); + const { currentTime } = usePlaybackStore(); + const [showDebug, setShowDebug] = useState(false); + + // Don't render anything in production + if (!SHOW_DEBUG_INFO) return null; + + // Get active clips at current time + const getActiveClips = (): ActiveClip[] => { + const activeClips: ActiveClip[] = []; + + tracks.forEach((track) => { + track.clips.forEach((clip) => { + const clipStart = clip.startTime; + const clipEnd = + clip.startTime + (clip.duration - clip.trimStart - clip.trimEnd); + + if (currentTime >= clipStart && currentTime < clipEnd) { + const mediaItem = + clip.mediaId === "test" + ? null // Test clips don't have a real media item + : mediaItems.find((item) => item.id === clip.mediaId) || null; + + activeClips.push({ clip, track, mediaItem }); + } + }); + }); + + return activeClips; + }; + + const activeClips = getActiveClips(); + + return ( +
+
+ {/* Toggle Button */} + + + {/* Debug Info Panel */} + {showDebug && ( +
+
+ Active Clips ({activeClips.length}) +
+
+ {activeClips.map((clipData, index) => ( +
+ + {index + 1} + +
+
{clipData.clip.name}
+
+ {clipData.mediaItem?.type || "test"} +
+
+
+ ))} + {activeClips.length === 0 && ( +
+ No active clips +
+ )} +
+
+ Time: {currentTime.toFixed(2)}s +
+
+ )} +
+
+ ); +} -- cgit v1.3.1