Skip to content

Conversation

@p-delorme
Copy link
Contributor

@p-delorme p-delorme commented Nov 27, 2025

Allows users to configure Cap's behavior after closing the settings window.

The default behavior is to reopen the main recording window, but users can now choose to do nothing.

This setting is added to the general settings store and exposed in the settings UI.

Summary by CodeRabbit

  • New Features
    • Added a new settings option to control window behavior after closing the Settings window. Users can now choose between "Do Nothing" or "Open Recording Window" as their preferred post-settings action.

✏️ Tip: You can customize this high-level summary in your review settings.

Allows users to configure Cap's behavior after closing the settings window.

The default behavior is to reopen the main recording window, but users can now choose to do nothing.

This setting is added to the general settings store and exposed in the settings UI.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

This PR introduces a new user-configurable setting PostSettingsCloseBehaviour that controls window behavior after closing the settings window. The setting is defined in the Rust backend, persisted in general settings, and exposed through the TypeScript frontend with a UI selector to choose between "Do Nothing" or "Open Recording Window" (default).

Changes

Cohort / File(s) Summary
Backend: Rust Settings Definition
apps/desktop/src-tauri/src/general_settings.rs
Added new PostSettingsCloseBehaviour enum with DoNothing and OpenRecordingWindow (default) variants; added corresponding field to GeneralSettingsStore with serde support.
Backend: Window Management Logic
apps/desktop/src-tauri/src/lib.rs
Added conditional logic to check PostSettingsCloseBehaviour when closing settings window; gates window reopening and main window display based on setting value.
Frontend: Type Definitions
apps/desktop/src/utils/tauri.ts
Added TypeScript type alias PostSettingsCloseBehaviour = "doNothing" | "openRecordingWindow"; extended GeneralSettingsStore type with optional postSettingsCloseBehaviour field.
Frontend: UI Component
apps/desktop/src/routes/(window-chrome)/settings/general.tsx
Added new SelectSettingItem UI element allowing users to configure post-settings-close behavior with options "Do Nothing" and "Open Recording Window"; wired to update settings via handleChange.

Sequence Diagram

sequenceDiagram
    actor User
    participant Settings as Settings Window
    participant Backend as Tauri Backend
    participant Storage as Settings Storage
    
    User->>Settings: Closes settings window
    Settings->>Backend: Trigger close event
    Backend->>Storage: Read PostSettingsCloseBehaviour
    alt should_open_main = true
        Backend->>Backend: Show main/recording window
    else
        Backend->>Backend: Do nothing
    end
    Settings-->>User: Window closes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Window logic flow: Verify the conditional logic in lib.rs correctly evaluates PostSettingsCloseBehaviour and consistently gates both window display and platform-specific reopening behavior.
  • Type synchronization: Ensure Rust enum variants, TypeScript type aliases, and serialization/deserialization align across all four files.
  • UI binding: Confirm the settings form correctly persists the new option and that default behavior matches the enum default.

Possibly related PRs

Poem

🐰 When settings close, dear users choose,

A window to show or gently lose,

Recording waits, or peace remains—

One toggle rule, one preference reigns! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: a new configurable setting for post-settings-close behavior is being added across the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (1)
apps/desktop/src/routes/(window-chrome)/settings/general.tsx (1)

37-40: UI wiring for “After Closing Settings Window” matches backend types and preserves old default

Importing PostSettingsCloseBehaviour, extending SelectSettingItem’s generic union, and adding the new SelectSettingItem instance all look correct:

  • The option values "doNothing" / "openRecordingWindow" align with the TS union and the Rust enum’s camelCase serialization.
  • value={settings.postSettingsCloseBehaviour ?? "openRecordingWindow"} keeps the previous default behavior for users without this field yet, matching the Rust Default.
  • onChange routes through handleChange("postSettingsCloseBehaviour", value), so the setting is persisted in the same way as the other behavior flags.

If you want the frontend defaults to be fully explicit, you could optionally add postSettingsCloseBehaviour: "openRecordingWindow" to createDefaultGeneralSettings, but that’s not required for correctness given the current fallback logic.

Also applies to: 359-365, 563-577

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a292974 and ea87e7b.

📒 Files selected for processing (4)
  • apps/desktop/src-tauri/src/general_settings.rs (3 hunks)
  • apps/desktop/src-tauri/src/lib.rs (3 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx (3 hunks)
  • apps/desktop/src/utils/tauri.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/desktop/src-tauri/src/lib.rs (2)
apps/desktop/src/utils/tauri.ts (1)
  • PostSettingsCloseBehaviour (446-446)
apps/desktop/src-tauri/src/general_settings.rs (1)
  • get (219-230)
apps/desktop/src/routes/(window-chrome)/settings/general.tsx (1)
apps/desktop/src/utils/tauri.ts (1)
  • PostSettingsCloseBehaviour (446-446)
⏰ 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). (1)
  • GitHub Check: Clippy (aarch64-apple-darwin, macos-latest)
🔇 Additional comments (3)
apps/desktop/src/utils/tauri.ts (1)

407-407: PostSettingsCloseBehaviour TS bindings look correct and in sync with Rust

The new PostSettingsCloseBehaviour union and optional postSettingsCloseBehaviour field on GeneralSettingsStore line up with the Rust enum (camelCase variants) and the settings UI usage; nothing further needed here, especially given this file is generated.

Also applies to: 445-447

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

56-56: Settings close behavior correctly gated on new PostSettingsCloseBehaviour setting

Importing PostSettingsCloseBehaviour and using:

  • GeneralSettingsStore::get(&app).ok().flatten().unwrap_or_default() to read settings, and
  • should_open_main based on PostSettingsCloseBehaviour::OpenRecordingWindow

keeps the legacy default (“open recording window”) while letting “do nothing” short‑circuit the existing logic that re‑shows Main/Camera/TargetSelectOverlay and, on Windows, calls reopen_main_window when no editor is open. The error‑tolerant get + unwrap_or_default path is also reasonable here, since failures fall back to the prior default behavior.

One thing to double‑check from a UX perspective (not a correctness issue): with DoNothing selected, TargetSelectOverlay and Camera windows will also no longer be shown when Settings closes because they’re behind the same should_open_main gate. If the intent was to only stop reopening the main recording window while still restoring overlays/camera, you might want a more specific condition there; otherwise this implementation matches the “do nothing after closing settings” semantics consistently.

Also applies to: 2686-2695, 2696-2707, 2712-2713

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

34-40: PostSettingsCloseBehaviour enum and GeneralSettingsStore defaults are consistent and backward‑safe

The new PostSettingsCloseBehaviour enum, its #[serde(rename_all = "camelCase")] serialization (doNothing / openRecordingWindow), and the #[serde(default)] field on GeneralSettingsStore with Default set to OpenRecordingWindow together ensure:

  • Existing configs deserialize without errors and continue to behave as before.
  • New configs get the intended default while still allowing the “do nothing” option.

This wiring looks solid and consistent with how other behavior enums in this struct are handled.

Also applies to: 127-128, 173-201

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.

1 participant