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 +++++++++++++++++++++++ apps/web/src/components/editor/preview-panel.tsx | 44 ---------- 2 files changed, 107 insertions(+), 44 deletions(-) create mode 100644 apps/web/src/components/development-debug.tsx (limited to 'apps/web/src/components') 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 +
+
+ )} +
+
+ ); +} diff --git a/apps/web/src/components/editor/preview-panel.tsx b/apps/web/src/components/editor/preview-panel.tsx index 5ee57487..b68e5aa6 100644 --- a/apps/web/src/components/editor/preview-panel.tsx +++ b/apps/web/src/components/editor/preview-panel.tsx @@ -12,9 +12,6 @@ import { Button } from "@/components/ui/button"; import { Play, Pause, Volume2, VolumeX } from "lucide-react"; import { useState, useRef, useEffect } from "react"; -// Debug flag - set to false to hide active clips info -const SHOW_DEBUG_INFO = process.env.NODE_ENV === "development"; - interface ActiveClip { clip: TimelineClip; track: TimelineTrack; @@ -27,7 +24,6 @@ export function PreviewPanel() { const { isPlaying, toggle, currentTime, muted, toggleMute, volume } = usePlaybackStore(); const [canvasSize, setCanvasSize] = useState({ width: 1920, height: 1080 }); - const [showDebug, setShowDebug] = useState(SHOW_DEBUG_INFO); const previewRef = useRef(null); const containerRef = useRef(null); const [previewDimensions, setPreviewDimensions] = useState({ @@ -197,18 +193,6 @@ export function PreviewPanel() { ))} - {/* Debug Toggle - Only show in development */} - {SHOW_DEBUG_INFO && ( - - )} -