Perfect! Now let me compile all my findings into a comprehensive report.
DETAILED BREAKDOWN: MediaLightbox Cross-Boundary Imports
Based on my investigation, I've identified all imports from tools/travel-between-images/ in MediaLightbox and traced their dependencies and usage patterns. Here's the complete analysis:
SUMMARY OF CROSS-BOUNDARY IMPORTS
MediaLightbox imports 3 items from tools/travel-between-images/:
| Import | Location | Usage Count | Complexity |
|---|
TrimControlsPanel | VideoTrimEditor/components | 1 file (VideoEditPanel.tsx) | Medium |
useVideoTrimming, useTrimSave | VideoTrimEditor/hooks | 1 file (useLightboxVideoMode.ts) | Medium |
TaskDetailsPanel | tools/travel-between-images/components | 2 files (TaskDetailsPanelWrapper.tsx, InfoPanel.tsx) | Low |
IMPORT 1: TrimControlsPanel
Source: /Users/user_c042661f/Documents/reigh/src/tools/travel-between-images/components/VideoGallery/components/VideoTrimEditor/components/TrimControlsPanel.tsx
Imported by: /Users/user_c042661f/Documents/reigh/src/shared/components/MediaLightbox/components/VideoEditPanel.tsx (line 15-18)
Direct Dependencies of TrimControlsPanel:
@/shared/components/ui/button - shared UI
lucide-react - icons
@/shared/lib/utils - utility functions (cn, formatTime)
./TrimTimelineBar - local tool component (internal dependency)
Key Implementation Details:
- 420 lines - medium complexity
- Core functionality: Frame extraction via canvas, timeline bar drag controls, save progress tracking
- Has hidden video element for frame extraction (technical complexity)
- Uses refs for frame extraction queue management
- Includes throttled update logic for performance
Usage Pattern:
- Only used in
VideoEditPanel.tsx (line 186)
- Imported directly with eslint disable exception comment (line 15-18)
- Renders when
videoEditSubMode === 'trim'
Other Usages in Codebase:
- Only referenced in MediaLightbox - no other cross-tool usage
- Defined in VideoTrimEditor index exports
IMPORT 2: useVideoTrimming & useTrimSave
Source: /Users/user_c042661f/Documents/reigh/src/tools/travel-between-images/components/VideoGallery/components/VideoTrimEditor/hooks/
Imported by: /Users/user_c042661f/Documents/reigh/src/shared/components/MediaLightbox/hooks/useLightboxVideoMode.ts (line 19)
A. useVideoTrimming Hook
File: VideoTrimEditor/hooks/useVideoTrimming.ts (115 lines)
Dependencies:
- React hooks (useState, useCallback, useMemo)
@/shared/types/videoTrim - shared types (TrimState, UseVideoTrimmingReturn)
What It Does:
- Manages trim state: startTrim, endTrim, videoDuration
- Validates trim values with
MIN_TRIMMED_DURATION = 0.5 seconds
- Provides clamped setters that prevent invalid combinations
- Returns calculated trimmedDuration and previewTimes
Usage in MediaLightbox:
- Called in
useLightboxVideoMode (line 147)
- Destructured result passed to VideoEditPanel via props
- No tool-specific logic - pure state management
B. useTrimSave Hook
File: VideoTrimEditor/hooks/useTrimSave.ts (278 lines)
Dependencies:
@tanstack/react-query - for invalidateVariantChange
@/integrations/supabase/client - database calls
sonner - toast notifications
@/shared/lib/errorHandler - error handling
@/shared/utils/videoThumbnailGenerator - thumbnail extraction
@/shared/hooks/useGenerationInvalidation - query invalidation
What It Does (Complex Workflow):
- Calls Edge Function 'trim-video' to convert video to MP4
- Extracts thumbnail client-side from trimmed video
- Fetches source variant params for metadata
- Creates variant record in database
- Updates generation record with new location
- Invalidates variant caches
Why It's Tool-Specific:
- Uses Supabase calls (
generation_variants, generations tables)
- Creates variant records with
variant_type: 'trimmed'
- Interacts with Edge Function specific to trim operation
- Has complex async state management (5 steps, progress tracking)
Usage in MediaLightbox:
- Called in
useLightboxVideoMode (line 180)
- Accepts media, projectId, effectiveVideoUrl, trimState, variant tracking
- Returns save progress/error/success states passed to VideoEditPanel
IMPORT 3: TaskDetailsPanel
Source: /Users/user_c042661f/Documents/reigh/src/tools/travel-between-images/components/TaskDetailsPanel.tsx
Imported by:
TaskDetailsPanelWrapper.tsx (line 3)
- Referenced transitively through InfoPanel
Direct Dependencies of TaskDetailsPanel:
All are shared - NO tool-specific dependencies:
@/shared/components/ui/* - shadcn UI components
@/shared/hooks/use-mobile - responsive hook
@/shared/hooks/useTaskType - task metadata
@/shared/hooks/useResources - public LoRAs
@/shared/components/GenerationDetails - shared component
@/shared/components/LoraSelectorModal - shared modal
lucide-react - icons
Key Implementation Details:
- 303 lines - medium complexity
- Core functionality: Display task parameters, input images, derived sections
- Supports both standalone and embedded modes (
hideHeader prop)
- Shows detailed params (JSON), copy buttons, "Apply Settings" footer
Why It's NOT Tool-Specific:
- Zero imports from tools/ directory
- All dependencies are shared components/hooks
- Could move to shared with zero refactoring needed
- Already has wrapper component (TaskDetailsPanelWrapper) suggesting shared intent
Usage Pattern:
- TaskDetailsPanelWrapper wraps it (adds scroll container, applies hideHeader)
- InfoPanel uses TaskDetailsPanelWrapper (line 239)
- Used in both desktop and mobile layouts
Other Usages in Codebase:
- Defined in travel-between-images tools (odd location)
- Only imported by MediaLightbox wrapper
- No other cross-tool usage
DEPENDENCY ANALYSIS MATRIX
| Component | Tool-Specific Deps | Shared Deps | DB Calls | API Calls | Edge Functions |
|---|
| TrimControlsPanel | TrimTimelineBar | UI, icons, utils | None | None | None |
| useVideoTrimming | None | videoTrim types | None | None | None |
| useTrimSave | None | errorHandler, invalidation | 2 (variants, generations) | 1 (functions.invoke) | trim-video |
| TaskDetailsPanel | None | 6 shared components | None | None | None |
USAGE CONTEXT: Where These Are Used
VideoEditPanel.tsx (379 lines)
- Purpose: Unified video editing panel for trim/replace/regenerate/enhance modes
- Uses TrimControlsPanel for: Trim sub-mode UI (lines 185-205)
- Uses VideoPortionEditor for: Replace portion sub-mode UI (lines 206-259)
- Pattern: Receives all trim-related state/handlers as props from parent
useLightboxVideoMode.ts (304 lines)
- Purpose: Consolidates video-related hooks for MediaLightbox
- Uses useVideoTrimming for: Trim state management (line 147)
- Uses useTrimSave for: Saving trimmed videos (line 180)
- Pattern: Calls hooks internally, returns consolidated interface
TaskDetailsPanelWrapper.tsx (82 lines)
- Purpose: Wrapper for TaskDetailsPanel with standard prop wiring
- Uses TaskDetailsPanel for: Display task details
- Pattern: Thin wrapper - mostly pass-through of props
InfoPanel.tsx (302 lines)
- Purpose: Unified info panel showing task details & variants
- Uses TaskDetailsPanelWrapper for: Rendering task section (line 239)
- Pattern: Calls wrapper component, manages state
MOVEMENT COMPLEXITY ASSESSMENT
EASY TO MOVE (0-1 day each):
1. useVideoTrimming ✓
- Current Location:
src/tools/travel-between-images/.../hooks/useVideoTrimming.ts
- Target:
src/shared/hooks/useVideoTrimming.ts or src/shared/hooks/video/useVideoTrimming.ts
- Complexity: LOW
- Reasons:
- Pure state management hook (no tool-specific logic)
- Only depends on React and shared types (
videoTrim.ts)
- Already canonical types live in shared (
videoTrim.ts)
- Just needs 1 import path change when moved
- Migration Path: Move file, update imports in useLightboxVideoMode.ts
2. TaskDetailsPanel ✓
- Current Location:
src/tools/travel-between-images/components/TaskDetailsPanel.tsx
- Target:
src/shared/components/TaskDetailsPanel.tsx or src/shared/components/GenerationTaskDetails/TaskDetailsPanel.tsx
- Complexity: LOW
- Reasons:
- Zero tool-specific dependencies (all imports are @/shared)
- Could move as-is with no code changes
- Already has wrapper suggesting shared design intent
- Only 2 import sites (both in MediaLightbox)
- Migration Path: Move file + update 2 import paths + update tool re-export
3. TrimTimelineBar ✓
- Current Location:
src/tools/travel-between-images/.../VideoTrimEditor/components/TrimTimelineBar.tsx
- Target:
src/shared/components/VideoTrimEditor/TrimTimelineBar.tsx
- Complexity: LOW
- Reasons:
- Only depends on React and shared utils (cn, formatTime)
- No tool-specific logic
- Re-exported from VideoTrimEditor index
- Only used internally by TrimControlsPanel
- Migration Path: Move file, update VideoTrimEditor index exports
MEDIUM COMPLEXITY (2-3 days):
4. useTrimSave ⚠️
- Current Location:
src/tools/travel-between-images/.../VideoTrimEditor/hooks/useTrimSave.ts
- Target:
src/shared/hooks/useVideoTrimming.ts or extract to dedicated video trim hooks module
- Complexity: MEDIUM
- Reasons:
- Has Supabase database calls (generation_variants, generations)
- Calls Edge Function (trim-video)
- Creates variant records with specific metadata
- But: No cross-tool dependencies, uses only shared APIs (supabase client, query invalidation)
- Decision Point: Does it belong in shared?
- Arguments FOR moving: Used only by shared MediaLightbox, generic API (trim video → save variant)
- Arguments AGAINST: Creates variant records (database-specific), calls dedicated Edge Function
- Recommendation: Move if trim feature is considered generic; keep if tool-specific
- Migration Path: Move file + update 1 import path + potentially extract Edge Function caller to shared utility
5. TrimControlsPanel ⚠️
- Current Location:
src/tools/travel-between-images/.../VideoTrimEditor/components/TrimControlsPanel.tsx
- Target:
src/shared/components/VideoTrimEditor/TrimControlsPanel.tsx
- Complexity: MEDIUM
- Reasons:
- Depends on TrimTimelineBar (sibling component - moves with it)
- Complex state management: Frame extraction queue, throttled updates, canvas refs
- Medium size: 420 lines
- But: All dependencies are shared (UI, icons, utils)
- Decision Point: Is video trim a generic feature?
- Arguments FOR: Used by MediaLightbox (shared), frame extraction is generic
- Arguments AGAINST: Very specific to travel-between-images video workflow
- Recommendation: Move if trim is reusable feature; keep if travel-specific
- Migration Path: Move with TrimTimelineBar + update 1 import path + update VideoTrimEditor exports
RECOMMENDATION: THREE-TIER MIGRATION STRATEGY
TIER 1: Move Immediately (Low Risk)
These have zero tool-specific logic and should be shared:
-
TaskDetailsPanel → Move to src/shared/components/TaskDetailsPanel.tsx
- Effort: 30 minutes
- Update 2 imports + tool re-export
- No code changes needed
-
useVideoTrimming → Move to src/shared/hooks/useVideoTrimming.ts
- Effort: 15 minutes
- Update 1 import
- No code changes needed
-
TrimTimelineBar → Move to src/shared/components/VideoTrimEditor/TrimTimelineBar.tsx
- Effort: 20 minutes
- Update 1 import + index exports
- No code changes needed
Total Effort: ~1 day (minimal refactoring)
Risk: Very Low (no behavioral changes)
TIER 2: Conditional Move (Medium Complexity)
Decide if these are truly "generic video features" or "travel-between-images specific":
-
TrimControlsPanel
- If video trimming is multi-tool feature: Move to shared
- If video trimming is travel-specific: Keep in tool, extract UI logic to shared
- Effort if moving: 1 day (with TrimTimelineBar)
-
useTrimSave
- If variant saving is multi-tool pattern: Move to shared
- If Edge Function is travel-specific: Keep in tool, extract hook template to shared pattern
- Effort if moving: 2 days (database integration, Edge Function handling)
TIER 3: Architectural Consideration
After moving Tier 1+2, evaluate:
- Should VideoTrimEditor be a full shared component module (like VideoPortionEditor)?
- Should there be a
src/shared/components/VideoTrimEditor/ directory parallel to tool structure?
KEY FILES FOR REFERENCE
Direct Import Sites:
/Users/user_c042661f/Documents/reigh/src/shared/components/MediaLightbox/components/VideoEditPanel.tsx (lines 15-18)
/Users/user_c042661f/Documents/reigh/src/shared/components/MediaLightbox/hooks/useLightboxVideoMode.ts (line 19)
/Users/user_c042661f/Documents/reigh/src/shared/components/MediaLightbox/components/TaskDetailsPanelWrapper.tsx (line 3)
Shared Dependencies:
/Users/user_c042661f/Documents/reigh/src/shared/types/videoTrim.ts - Type source of truth
/Users/user_c042661f/Documents/reigh/src/shared/hooks/useVariants.ts - Variant management
/Users/user_c042661f/Documents/reigh/src/shared/components/VideoPortionEditor/ - Similar pattern (already shared)
Tool Structure:
/Users/user_c042661f/Documents/reigh/src/tools/travel-between-images/components/VideoGallery/components/VideoTrimEditor/ - Source of trim functionality
/Users/user_c042661f/Documents/reigh/src/tools/edit-video/components/VideoPortionEditor.tsx - Re-export pattern (deprecated for shared)