Skip to content

Conversation

@oscartbeaumont
Copy link
Contributor

@oscartbeaumont oscartbeaumont commented Aug 12, 2025

  • Enable new recording flow in dev by default
  • Fix issue with screen information being the hovered screen instead of the current screen
  • Fix corrdinate logic for window hover one external monitors
  • Display names are still not friendly enough on Windows
  • Reduce windows features on cap-displays
  • Is the Windows z-index implementation good enough?
  • Implement the new UI flow
  • Area select is showing up on each monitor. It should only be on a single one.
  • When I open up the app, it auto selects the last option? e.g. if I used the area picker last time, if I reopen the app, it'll open with the area view.
  • Fix area selection not actually capturing on external monitors
  • macOS monitor and window bounds calculation are wrong. This was introduced when I did the Windows multimonitor work.
  • Windows hovering on application window seems to be buggy
    • It's detecting Webview 2 a lot which I think is our overlay so we might need to review that logic.

Summary by CodeRabbit

  • New Features
    • Target selection overlay now displays detailed screen information, including name, physical size, and refresh rate when selecting a display.
    • Settings > Experimental: “New recording flow” toggle is now visible for all users, allowing easier discovery and control of the feature.
    • Enhanced display info retrieval enables richer, more accurate details in the overlay during screen selection.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Updates default for enable_new_recording_flow to be debug-dependent, exposes a new Tauri command to fetch display information, refactors target select overlay types by removing embedded screen data, introduces a new DisplayInformation type/function, and updates frontend to fetch and render display info asynchronously with corresponding type changes.

Changes

Cohort / File(s) Summary
Recording flow default and UI toggle
apps/desktop/src-tauri/src/general_settings.rs, apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx
Default enable_new_recording_flow now uses cfg!(debug_assertions); experimental toggle rendered unconditionally.
Target select overlay backend API changes
apps/desktop/src-tauri/src/target_select_overlay.rs, apps/desktop/src-tauri/src/lib.rs
Removed screen from TargetUnderCursor; renamed ScreenUnderCursor → DisplayInformation; added display_information(display_id) API; adjusted close_target_select_overlays signature; exposed display_information via specta in lib.rs.
Frontend integration for display info and types
apps/desktop/src/utils/tauri.ts, apps/desktop/src/routes/target-select-overlay.tsx
Added commands.displayInformation and DisplayInformation type; removed ScreenUnderCursor and screen from TargetUnderCursor; overlay now fetches display info via createQuery and renders from DisplayInformation.

Sequence Diagram(s)

sequenceDiagram
  participant UI as TargetSelectOverlay (frontend)
  participant Utils as utils.commands
  participant Tauri as Tauri bridge
  participant Backend as target_select_overlay::display_information
  participant Displays as cap_displays::Display

  UI->>Utils: displayInformation(displayId)
  Utils->>Tauri: invoke("display_information", { displayId })
  Tauri->>Backend: display_information(display_id)
  Backend->>Displays: Display::from_id(display_id)
  Displays-->>Backend: Display
  Backend-->>Tauri: DisplayInformation { name, physical_size, refresh_rate }
  Tauri-->>Utils: DisplayInformation
  Utils-->>UI: DisplayInformation
  UI->>UI: Render overlay with display details
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • New recording flow #831: Introduces the same target_select_overlay renames and command, and adjusts the recording flow default; directly connected to these API and behavior changes.

Suggested labels

codex

Suggested reviewers

  • Brendonovich

Poem

A rabbit peeks at screens so bright,
New flows hop on in debug light.
I fetch a name, a size, a rate—
Through Tauri burrows, don’t be late!
With overlays trimmed, I dance with glee,
Display info’s fetched for you and me. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch new-recording-flow2

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🔭 Outside diff range comments (1)
apps/desktop/src-tauri/src/target_select_overlay.rs (1)

107-115: Critical: close_target_select_overlays no longer cleans up background tasks and the global Escape shortcut

This change drops WindowFocusManager state, so:

  • The cursor-tracking task set in open_target_select_overlays is never aborted.
  • Per-overlay focus tasks spawned via WindowFocusManager::spawn are never aborted.
  • The global Escape shortcut may remain registered.

This will leak tasks, keep unnecessary work running, and may leave the Escape shortcut stolen from other apps.

Apply this diff to restore cleanup (aborting tasks and unregistering the shortcut) while closing the overlay windows:

-#[specta::specta]
-#[tauri::command]
-pub async fn close_target_select_overlays(app: AppHandle) -> Result<(), String> {
+#[specta::specta]
+#[tauri::command]
+pub async fn close_target_select_overlays(
+    app: AppHandle,
+    state: tauri::State<'_, WindowFocusManager>,
+) -> Result<(), String> {
     for (id, window) in app.webview_windows() {
         if let Ok(CapWindowId::TargetSelectOverlay { .. }) = CapWindowId::from_str(&id) {
             let _ = window.close();
         }
     }

+    // Abort per-overlay focus tasks and clear the map
+    let handles = {
+        let mut tasks = state.tasks.lock().unwrap_or_else(PoisonError::into_inner);
+        tasks.drain().map(|(_, h)| h).collect::<Vec<_>>()
+    };
+    for h in handles {
+        let _ = h.abort();
+    }
+
+    // Abort the cursor tracking task
+    if let Some(task) = state
+        .task
+        .lock()
+        .unwrap_or_else(PoisonError::into_inner)
+        .take()
+    {
+        task.abort();
+    }
+
+    // Unregister the global Escape shortcut
+    app.global_shortcut()
+        .unregister("Escape")
+        .map_err(|err| {
+            error!("Error unregistering global keyboard shortcut for Escape: {err}")
+        })
+        .ok();
+
     Ok(())
 }

If the intent is to avoid the state parameter, add an internal cleanup API (e.g., WindowFocusManager::destroy_all(&AppHandle)) and call it here.

🧹 Nitpick comments (3)
apps/desktop/src/routes/target-select-overlay.tsx (1)

46-60: Consider adding proper error handling for display information query.

The current implementation logs errors to the console but doesn't provide user feedback when the display information fetch fails. Consider showing an error state or fallback UI.

const displayInformation = createQuery(() => ({
  queryKey: ["displayId", params.displayId],
  queryFn: async () => {
    if (!params.displayId) return null;
    try {
      const info = await commands.displayInformation(params.displayId);
      return info;
    } catch (error) {
      console.error("Failed to fetch screen information:", error);
+     // Consider showing a toast notification or error message to the user
      return null;
    }
  },
  enabled:
    params.displayId !== undefined && rawOptions.targetMode === "screen",
}));

Additionally, you might want to handle the loading state for a better user experience:

<Show when={displayInformation.data} keyed fallback={
  <Show when={displayInformation.isLoading}>
    <div class="w-screen h-screen flex items-center justify-center">
      <span>Loading display information...</span>
    </div>
  </Show>
}>
apps/desktop/src-tauri/src/target_select_overlay.rs (2)

38-42: Prefer numeric refresh_rate; format in the UI instead of returning String

Returning refresh_rate as a String reduces type fidelity (e.g., cannot easily compare or format without parsing). Consider keeping it as f64 and formatting “XX Hz” in the UI.

Apply this diff in this block:

 pub struct DisplayInformation {
     name: String,
     physical_size: PhysicalSize,
-    refresh_rate: String,
+    refresh_rate: f64,
 }

And adjust the constructor accordingly (see suggestion in Lines 117-133).


117-133: Follow-up if you switch refresh_rate to f64

If you adopt the earlier suggestion to use f64, update construction accordingly.

Apply this diff in this block:

-    let physical_size = display.physical_size();
-    let refresh_rate = display.refresh_rate().to_string();
+    let physical_size = display.physical_size();
+    let refresh_rate = display.refresh_rate();
@@
-        physical_size,
-        refresh_rate,
+        physical_size,
+        refresh_rate,

And update the frontend TS type accordingly:

// apps/desktop/src/utils/tauri.ts
export type DisplayInformation = {
  name: string
  physical_size: PhysicalSize
  refresh_rate: number // was string
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 038e153 and eff61ee.

📒 Files selected for processing (6)
  • apps/desktop/src-tauri/src/general_settings.rs (1 hunks)
  • apps/desktop/src-tauri/src/lib.rs (1 hunks)
  • apps/desktop/src-tauri/src/target_select_overlay.rs (4 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (1 hunks)
  • apps/desktop/src/routes/target-select-overlay.tsx (3 hunks)
  • apps/desktop/src/utils/tauri.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (2)
apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx (1)
  • ToggleSetting (24-40)
apps/desktop/src/routes/(window-chrome)/settings/general.tsx (8)
  • value (183-185)
  • value (200-202)
  • value (211-213)
  • value (241-243)
  • value (255-257)
  • value (270-272)
  • value (289-291)
  • value (308-310)
apps/desktop/src-tauri/src/lib.rs (1)
apps/desktop/src-tauri/src/target_select_overlay.rs (1)
  • display_information (119-133)
apps/desktop/src-tauri/src/target_select_overlay.rs (4)
apps/desktop/src/utils/tauri.ts (2)
  • DisplayId (360-360)
  • DisplayInformation (361-361)
crates/displays/src/platform/win.rs (5)
  • format (429-431)
  • format (497-499)
  • from_id (110-113)
  • physical_size (167-201)
  • refresh_rate (203-228)
crates/displays/src/lib.rs (3)
  • from_id (27-29)
  • physical_size (39-41)
  • refresh_rate (43-45)
crates/displays/src/platform/macos.rs (3)
  • from_id (38-41)
  • physical_size (73-91)
  • refresh_rate (93-104)
⏰ 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). (2)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
🔇 Additional comments (10)
apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (1)

84-98: LGTM! The feature toggle is now always visible.

The removal of the import.meta.env.DEV conditional check makes the "New recording flow" toggle available in all environments, which aligns with the default behavior change in the backend where enable_new_recording_flow defaults to true in debug builds.

apps/desktop/src-tauri/src/general_settings.rs (1)

107-109: Good change to enable feature in development by default.

Using cfg!(debug_assertions) ensures the new recording flow is enabled automatically in debug builds while remaining disabled in release builds. This provides a better developer experience without affecting production users.

apps/desktop/src-tauri/src/lib.rs (1)

1959-1959: LGTM! New command properly exposed.

The target_select_overlay::display_information command is correctly added to the specta command list, making it available to the frontend.

apps/desktop/src/routes/target-select-overlay.tsx (2)

100-119: Good refactoring to use asynchronous display information fetch.

The change from using targetUnderCursor.screen to fetching display information via a dedicated query improves the architecture by separating concerns and reducing the payload size of the TargetUnderCursor event.


103-103: Static data-over="true" in screen mode is intentional
The hardcoded attribute on line 103 ensures the screen overlay is always highlighted when in screen-target mode. Dynamic toggling is already applied in window mode (line 131), so no changes are needed here.

Likely an incorrect or invalid review comment.

apps/desktop/src/utils/tauri.ts (2)

260-262: LGTM! New command and type definitions are properly implemented.

The displayInformation command and DisplayInformation type are correctly added, matching the backend implementation.


361-361: Good architectural improvement: Removing screen data from TargetUnderCursor.

The removal of the screen field from TargetUnderCursor and the introduction of a separate DisplayInformation type improves the separation of concerns. This change:

  1. Reduces the payload size of the frequently emitted TargetUnderCursor event
  2. Allows display information to be fetched on-demand when needed
  3. Makes the data flow more explicit and easier to reason about

Also applies to: 428-428

apps/desktop/src-tauri/src/target_select_overlay.rs (3)

12-14: Importing Display is correct and necessary for new display_information API

The added import of Display (alongside DisplayId, WindowId, and PhysicalSize) aligns with the new usage in display_information().


38-42: AI summary inconsistency: DisplayInformation still derives Serialize/Type/Clone

The AI summary claims DisplayInformation “no longer derives Serialize, Type, or Clone,” but the code derives all three. Please confirm which is intended and update the summary or code accordingly.


117-133: New display_information command: API and error handling look correct

Parsing DisplayId, resolving Display::from_id, and returning DisplayInformation are all sound. Error strings are concise and appropriate.

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