Skip to content

Conversation

@Brendonovich
Copy link
Contributor

@Brendonovich Brendonovich commented Aug 8, 2025

Provides the choice for the recording window to reopen after deleting an in progress recording

Summary by CodeRabbit

  • New Features

    • Added a new setting allowing users to choose what happens after deleting a recording, with options to either close the window or reopen the recording window.
  • Bug Fixes

    • Improved handling of recording cancellation to ensure all related processes are properly stopped.
    • Enhanced error handling in settings initialization to prevent crashes and log errors instead.
  • Chores

    • Removed unused icon declarations to streamline the codebase.

@Brendonovich Brendonovich linked an issue Aug 8, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

A new user-configurable setting for post-recording deletion behavior was introduced across backend and frontend components. The Rust backend added an enum and updated settings storage, while the frontend UI and types were extended to support and display the new option. Additional changes improved actor shutdown logic and removed unused icon declarations.

Changes

Cohort / File(s) Change Summary
Backend: General Settings Enum & Store
apps/desktop/src-tauri/src/general_settings.rs
Added PostDeletionBehaviour enum with serialization; extended GeneralSettingsStore with new field and default value.
Backend: Recording Deletion Flow
apps/desktop/src-tauri/src/recording.rs
Updated deletion logic to respect user-configured post-deletion behavior, altering window control flow accordingly.
Frontend: General Settings UI & Types
apps/desktop/src/routes/(window-chrome)/settings/general.tsx
Added UI for new "After deleting recording" setting, updated types and rendering logic to support new option.
Frontend: Tauri Types
apps/desktop/src/utils/tauri.ts
Added PostDeletionBehaviour type and optional property to GeneralSettingsStore.
Backend: Studio Recording Actor Shutdown
crates/recording/src/studio_recording.rs
Improved Cancel message handling to stop cursor actor before shutting down pipeline.
Frontend: Icon Declarations Cleanup
packages/ui-solid/src/auto-imports.d.ts
Removed global constant declarations for numerous unused icons.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (Settings)
    participant Backend (Tauri)
    participant Window Manager

    User->>UI (Settings): Selects "After deleting recording" option
    UI (Settings)->>Backend (Tauri): Saves postDeletionBehaviour setting

    User->>Backend (Tauri): Deletes a recording
    Backend (Tauri)->>Backend (Tauri): Cancels and deletes recording
    Backend (Tauri)->>Backend (Tauri): Reads postDeletionBehaviour
    alt postDeletionBehaviour == DoNothing
        Backend (Tauri)->>Window Manager: Close main window
    else postDeletionBehaviour == ReopenRecordingWindow
        Backend (Tauri)->>Window Manager: Reopen main recording window
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested labels

codex

Poem

A setting for what happens when recordings are gone,
Should Cap hide away, or swiftly respawn?
The backend now listens, the frontend complies,
Windows may close, or again open wide.
With icons now tidy, and actors shut down,
This bunny hops forward, with nary a frown! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b430aa0 and 7cc81ef.

📒 Files selected for processing (2)
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx (7 hunks)
  • packages/ui-solid/src/auto-imports.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/ui-solid/src/auto-imports.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 852-cap-window-dissappears-after-deleting-current-record

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
  • 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 src/utils.ts and explain its main purpose.
    • @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 comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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: 3

🧹 Nitpick comments (6)
apps/desktop/src/utils/tauri.ts (1)

386-386: PostDeletionBehaviour union matches Rust variants.

Literal values "exit" and "reopenRecordingWindow" are consistent with the Rust enum and rename_all = "camelCase". Consider adding brief docs on the Rust enum variants so tauri-specta emits helpful TS comments.

crates/recording/src/studio_recording.rs (1)

453-461: Cancel path now stops cursor actor before pipeline shutdown — confirm ordering or unify.

You now:

  • stop the cursor actor if present, then
  • shutdown the pipeline.

In Pause you do the opposite (shutdown pipeline first, then stop cursor inside shutdown()). Both orders are arguably safe, but the discrepancy is subtle. Either:

  • document why Cancel needs a different order, or
  • unify the order across paths for predictability.

Also, Cancel intentionally avoids persisting partial cursor data (cursor.json). If that’s the desired behavior, great; otherwise consider reusing the shutdown helper with a flag.

Example (if you prefer pipeline-first for Cancel too):

- if let Some(cursor) = &mut pipeline.cursor
-     && let Some(actor) = cursor.actor.take()
- {
-     actor.stop().await;
- }
-
- pipeline.inner.shutdown().await
+ let res = pipeline.inner.shutdown().await;
+ if let Some(cursor) = &mut pipeline.cursor
+     && let Some(actor) = cursor.actor.take()
+ {
+     actor.stop().await;
+ }
+ res
apps/desktop/src-tauri/src/recording.rs (1)

488-490: Nit: clarify comment or remove.

“Actor hasn't errored, it's just finished” is fine but redundant with the surrounding match. Optional: drop or expand to say why nothing needs to be done on this branch.

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

24-31: New PostDeletionBehaviour enum: serde defaults and casing are correct.

  • rename_all = "camelCase" will map to "exit" and "reopenRecordingWindow" in TS.
  • Default variant Exit defined. Looks good.

Optional nit: add brief doc comments to variants to improve generated TS docs.

apps/desktop/src/routes/(window-chrome)/settings/general.tsx (2)

149-160: Type union extension is fine; consider tightening generics to drop any.

Adding PostDeletionBehaviour to the select types is correct. Optionally, make SelectSettingItem and renderRecordingSelect generic to eliminate the any in options/onChange and prevent cross-setting value mix-ups.

Example:

type SelectValue =
  | MainWindowRecordingStartBehaviour
  | PostStudioRecordingBehaviour
  | PostDeletionBehaviour
  | number;

type SelectSettingItem<T extends SelectValue = SelectValue> = {
  label: string;
  type: "select";
  description: string;
  value: T;
  onChange: (value: T) => void | Promise<void>;
};

function renderRecordingSelect<T extends SelectValue>(
  label: string,
  description: string,
  getValue: () => T,
  onChange: (value: T) => void,
  options: { text: string; value: T }[]
) { /* ... */ }

448-461: Option values look correct; align label with behavior and earlier terminology.

  • Values "exit" and "reopenRecordingWindow" match the intended behaviors. Good.
  • The label “Hide Cap” might be misleading if the behavior actually closes the main window (per backend summary). Consider “Close window” for consistency with the “Main window recording start behaviour” options (“Close”, “Minimise”).

Optional text tweak:

-                              { text: "Hide Cap", value: "exit" },
+                              { text: "Close window", value: "exit" },

Please also confirm that “exit” does not quit the entire app on any OS (especially macOS), but only closes/hides the main window, matching the backend’s “close main window” behavior.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d04f66a and 2998dff.

📒 Files selected for processing (6)
  • apps/desktop/src-tauri/src/general_settings.rs (3 hunks)
  • apps/desktop/src-tauri/src/recording.rs (3 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx (5 hunks)
  • apps/desktop/src/utils/tauri.ts (2 hunks)
  • crates/recording/src/studio_recording.rs (1 hunks)
  • packages/ui-solid/src/auto-imports.d.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/ui-solid/src/auto-imports.d.ts
🔇 Additional comments (6)
apps/desktop/src/utils/tauri.ts (1)

363-363: TS settings shape aligns with Rust serde(camelCase).

The optional postDeletionBehaviour property is correctly added and matches backend naming via serde(camelCase). No action required.

crates/recording/src/studio_recording.rs (1)

324-329: Good cleanup: stop cursor actor when pipeline finishes.

Prevents a dangling cursor actor when the pipeline completes cleanly. Looks correct and side-effect free.

Minor check: this path does not persist cursor events (unlike Pause/Stop which call shutdown()). If that’s intentional for this completion path, we’re good. If not, consider reusing the shutdown helper for symmetry.

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

9-10: Import looks correct.

PostDeletionBehaviour is used later in delete_recording; no issues.

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

90-92: Backwards compatibility: serde(default) on new field is correct.

Existing stores won’t break and will default to Exit. Good addition.


132-133: Default implementation updated — consistent with enum default.

Explicitly setting post_deletion_behaviour: Exit maintains clarity and avoids relying solely on enum default. LGTM.

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

324-329: Render helper type update LGTM.

Extending getValue’s return type to include PostDeletionBehaviour is consistent with the new setting.

@Brendonovich Brendonovich merged commit a1aa344 into main Aug 8, 2025
7 checks passed
This was referenced Aug 12, 2025
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.

Cap window dissappears after deleting current record

2 participants