Skip to content

Conversation

@richiemcilroy
Copy link
Member

@richiemcilroy richiemcilroy commented Jan 14, 2026

  • Add prewarmed overlay windows for faster target selection startup
    • Fix window positioning to respect cursor's current display (external monitor support)
    • Add target mode passthrough to open overlays in a specific mode (display/window/area)
    • Show target selection only on the relevant display instead of all displays
    • Fix camera preview positioning on external displays using logical bounds

Greptile Summary

This PR improves external display handling and target selection performance through three key improvements:

Prewarmed Overlays for Faster Startup

  • Introduces PrewarmedOverlays state manager that creates hidden overlay windows on app startup
  • Overlays are cached for 30 seconds and reused when target selection is triggered
  • Significantly reduces perceived latency when opening target selection UI

Cursor-Aware Display Positioning

  • Window positioning now respects the display containing the cursor using Display::get_containing_cursor()
  • Uses logical_bounds() instead of physical coordinates for proper multi-monitor positioning
  • Main window, camera preview, and overlays now correctly appear on external displays

Target Mode Passthrough

  • Adds target_mode parameter to ShowCapWindow::TargetSelectOverlay and URL parameters
  • New RequestSetTargetMode event allows direct navigation to display/window/area modes
  • Tray menu now opens target selection on the correct display in the requested mode

Screenshot Editor Improvements

  • Fixed image loading to handle both .cap directory structures and direct PNG files
  • Improved camera preview repositioning during area selection using logical bounds from display info

The changes are well-structured and follow existing patterns. The prewarming system properly handles cleanup of stale windows and prevents concurrent prewarming operations.

Confidence Score: 4/5

  • This PR is safe to merge with thorough testing on external displays
  • The changes are well-implemented with proper resource management and follow existing patterns. The prewarming system includes cleanup mechanisms and prevents race conditions. Multi-display logic correctly uses logical bounds. However, the complexity of window positioning across different displays and the new prewarming system warrant testing on actual multi-monitor setups before production deployment
  • Pay close attention to target_select_overlay.rs and windows.rs for multi-monitor positioning logic

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/target_select_overlay.rs Added prewarmed overlay system for faster startup and display-specific targeting
apps/desktop/src-tauri/src/windows.rs Improved window positioning using logical bounds for external display support, added target mode parameter
apps/desktop/src-tauri/src/tray.rs Updated tray menu to use new open_target_picker function with display detection
apps/desktop/src-tauri/src/lib.rs Added new command, event, state management for prewarming overlays and target mode selection
apps/desktop/src/routes/target-select-overlay.tsx Added target mode URL parameter support and camera repositioning logic for area selection

Sequence Diagram

sequenceDiagram
    participant User
    participant Tray
    participant Main
    participant Lib as lib.rs
    participant TSO as target_select_overlay.rs
    participant Windows as windows.rs
    participant Frontend as target-select-overlay.tsx

    Note over Lib: App Startup
    Lib->>TSO: prewarm_target_select_overlays()
    TSO->>TSO: List all displays
    loop For each display
        TSO->>Windows: ShowCapWindow::TargetSelectOverlay
        Windows->>Frontend: Create hidden overlay window
        TSO->>TSO: Store in PrewarmedOverlays cache
    end

    Note over User,Frontend: User Initiates Target Selection
    User->>Tray: Click "Record Display"
    Tray->>Lib: open_target_picker(RecordingTargetMode::Display)
    Lib->>Lib: Display::get_containing_cursor()
    Lib->>Main: Hide main window
    Lib->>TSO: open_target_select_overlays(target_mode, display_id)
    
    alt Prewarmed overlay exists
        TSO->>TSO: Take from PrewarmedOverlays cache
        TSO->>Frontend: window.show() + set_focus()
    else No prewarmed overlay
        TSO->>Windows: ShowCapWindow::TargetSelectOverlay
        Windows->>Windows: Get display logical_bounds()
        Windows->>Frontend: Create overlay on cursor's display
    end

    TSO->>Frontend: Emit RequestSetTargetMode event
    Frontend->>Frontend: Set targetMode from URL param
    Frontend->>Frontend: Update UI for mode (display/window/area)

    Note over User,Frontend: User Makes Selection
    User->>Frontend: Click to select target
    Frontend->>Frontend: Update captureTarget in options
    Frontend->>TSO: closeTargetSelectOverlays()
    TSO->>Frontend: Close overlay windows
    Frontend->>Lib: startRecording() or take_screenshot()
Loading

@richiemcilroy richiemcilroy merged commit c59f1b4 into main Jan 14, 2026
14 of 16 checks passed
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.

2 participants