Skip to content

Conversation

@Brendonovich
Copy link
Contributor

@Brendonovich Brendonovich commented Oct 14, 2025

Summary by CodeRabbit

  • New Features

    • Added an option to automatically delete instant recordings after upload (toggle in General settings).
  • Improvements

    • Settings reorganized into clearer grouped sections for easier navigation.
    • Recording settings use a consistent selector for choices.
    • macOS-specific App settings grouped for clarity; Server URL and exclusions presented with updated components.
  • Bug Fixes

    • More robust handling when finishing recordings and generating thumbnails; cleanup only runs on success, with errors logged.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds a new delete-instant-recordings-after-upload setting to both backend (Rust) and frontend (TS). Updates recording completion flow to optionally delete instant recording directories post-upload. Refactors settings UI: renames components, introduces SettingGroup, and updates general/experimental settings to use new components and types.

Changes

Cohort / File(s) Summary
Backend settings model
apps/desktop/src-tauri/src/general_settings.rs
Added delete_instant_recordings_after_upload: bool to GeneralSettingsStore with #[serde(default)] and default false.
Recording finish flow
apps/desktop/src-tauri/src/recording.rs
Reworked error handling for thumbnail update; on success, conditionally deletes recording directory when the new setting is enabled, using tokio::fs::remove_dir_all.
Settings UI components (renames)
apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx
Renamed exports: SettingSettingItem, ToggleSettingToggleSettingItem; signatures unchanged aside from names.
Experimental settings usage
apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx
Updated imports/usages to ToggleSettingItem.
General settings page refactor
apps/desktop/src/routes/(window-chrome)/settings/general.tsx
Adopted SettingItem/ToggleSettingItem; introduced SettingGroup; switched Recording UI to SelectSettingItem; reorganized OS-specific blocks; removed prior static types/data.
Frontend settings type
apps/desktop/src/utils/tauri.ts
Extended GeneralSettingsStore type with optional deleteInstantRecordingsAfterUpload?: boolean.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as UI
  participant App as Tauri App
  participant Rec as Recording Service
  participant Set as GeneralSettingsStore
  participant FS as File System

  UI->>Rec: Finish recording
  Rec->>Rec: Update thumbnail (async)
  alt Thumbnail update fails
    Rec->>App: Log error
    Rec-->>UI: Return (no deletion)
  else Thumbnail update succeeds
    Rec->>Set: Get settings
    Set-->>Rec: { delete_instant_recordings_after_upload }
    alt delete_instant_recordings_after_upload == true
      Rec->>FS: remove_dir_all(recording_dir)
      alt Deletion fails
        Rec->>App: Log error
        Rec-->>UI: Return
      else Deletion succeeds
        Rec-->>UI: Return
      end
    else Setting disabled
      Rec-->>UI: Return
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

codex

Poem

A toggle flips—hush, files go poof,
I nibble code beneath the roof.
Thumbnails set, then paths are clear,
A tidy warren, front to rear.
New names hop in, groups align—
Settings bloom like clover fine. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 succinctly and accurately describes the primary enhancement in the changeset, which is the introduction of a feature to automatically delete instant recordings after a successful upload, matching the implementation of the new configuration option and deletion logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch delete-instnat-recording-after-upload

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src-tauri/src/recording.rs (1)

952-975: Don’t gate deletion on thumbnail upload; avoid race with meta save.

  • If video upload succeeded but thumbnail upload fails, we never delete. Deletion should be independent of thumbnail success.
  • Deletion runs in a spawned task and can race with the later meta save, causing spurious “Failed to load recording meta...” errors.

Minimal fix: still attempt deletion even if thumbnail upload fails.

-                                .await;
-                                if let Err(err) = res {
-	                                error!("Error updating thumbnail for instant mode progressive upload: {err}");
-	                                return;
-                                }
+                                .await;
+                                if let Err(err) = res {
+	                                error!("Error updating thumbnail for instant mode progressive upload: {err}");
+	                                // proceed; deletion should not depend on thumbnail success
+                                }
 
                                 if GeneralSettingsStore::get(&app).ok().flatten().unwrap_or_default().delete_instant_recordings_after_upload {
 	                                if let Err(err) = tokio::fs::remove_dir_all(&recording_dir).await {
 	                                	error!("Failed to remove recording files after upload: {err:?}");
-		                                return;
 	                                }
                                 }

Optional follow-up to reduce log noise: when deleteInstantRecordingsAfterUpload is true for instant recordings, skip the meta save at lines ~1017–1024, or downgrade the log if the project path is missing.

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

3-8: Type children via ParentProps; simplify onChange.

Use strict typing and avoid any; pass onChange directly.

-export function SettingItem(props: {
-	pro?: boolean;
-	label: string;
-	description?: string;
-	children: any;
-}) {
+export function SettingItem(
+  props: ParentProps<{ pro?: boolean; label: string; description?: string }>,
+) {

Also:

-      <Toggle
-        size="sm"
-        checked={props.value}
-        onChange={(v) => props.onChange(v)}
-      />
+      <Toggle size="sm" checked={props.value} onChange={props.onChange} />

Add import (outside this hunk):

import type { ParentProps } from "solid-js";

As per coding guidelines.

Also applies to: 32-39

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

303-315: Tighten SelectSettingItem types; remove any.

Make options strongly typed against T.

-const SelectSettingItem = <
-  T extends
-    | MainWindowRecordingStartBehaviour
-    | PostStudioRecordingBehaviour
-    | PostDeletionBehaviour
-    | number,
->(props: {
+const SelectSettingItem = <
+  T extends
+    | MainWindowRecordingStartBehaviour
+    | PostStudioRecordingBehaviour
+    | PostDeletionBehaviour
+    | number,
+>(props: {
   label: string;
   description: string;
   value: T;
   onChange: (value: T) => void;
-  options: { text: string; value: any }[];
+  options: { text: string; value: T }[];
 }) => {

As per coding guidelines.


487-493: Copy nit: fix sentence.

- label="Delete instant mode recordings after upload"
- description="After finishing an instant recording, should Cap will delete it from your device?"
+ label="Delete instant recordings after upload"
+ description="After finishing an instant recording, Cap will delete it from your device."
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2054742 and 76c99bb.

📒 Files selected for processing (6)
  • apps/desktop/src-tauri/src/general_settings.rs (2 hunks)
  • apps/desktop/src-tauri/src/recording.rs (2 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx (2 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (4 hunks)
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx (8 hunks)
  • apps/desktop/src/utils/tauri.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Use strict TypeScript and avoid any; leverage shared types

Files:

  • apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx
  • apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx
  • apps/desktop/src/utils/tauri.ts
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx
  • apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx
  • apps/desktop/src/utils/tauri.ts
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx
apps/desktop/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/desktop/src/**/*.{ts,tsx}: Desktop icons are auto-imported (unplugin-icons); do not import icons manually
Desktop IPC: Call generated tauri_specta commands/events; listen to generated events and use typed interfaces
Use @tanstack/solid-query for server state in the desktop app

Files:

  • apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx
  • apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx
  • apps/desktop/src/utils/tauri.ts
  • apps/desktop/src/routes/(window-chrome)/settings/general.tsx
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format Rust code using rustfmt and ensure all Rust code passes workspace-level clippy lints.
Rust modules should be named with snake_case, and crate directories should be in kebab-case.

Files:

  • apps/desktop/src-tauri/src/general_settings.rs
  • apps/desktop/src-tauri/src/recording.rs
**/tauri.ts

📄 CodeRabbit inference engine (AGENTS.md)

Do not edit auto-generated files named tauri.ts.

NEVER EDIT auto-generated IPC bindings file: tauri.ts

Files:

  • apps/desktop/src/utils/tauri.ts
🧬 Code graph analysis (4)
apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx (1)
apps/desktop/src/components/Toggle.tsx (1)
  • Toggle (37-50)
apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (1)
apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx (1)
  • ToggleSettingItem (24-40)
apps/desktop/src-tauri/src/recording.rs (3)
apps/desktop/src-tauri/src/upload.rs (1)
  • singlepart_uploader (683-713)
apps/desktop/src/utils/tauri.ts (1)
  • GeneralSettingsStore (396-396)
apps/desktop/src-tauri/src/general_settings.rs (1)
  • get (208-219)
apps/desktop/src/routes/(window-chrome)/settings/general.tsx (2)
apps/desktop/src/utils/tauri.ts (4)
  • MainWindowRecordingStartBehaviour (418-418)
  • PostStudioRecordingBehaviour (434-434)
  • PostDeletionBehaviour (433-433)
  • requestPermission (125-127)
apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx (2)
  • SettingItem (3-22)
  • ToggleSettingItem (24-40)
⏰ 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). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (3)
apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx (1)

6-6: LGTM: component rename only.

Renamed to ToggleSettingItem with identical props/behavior. No issues.

Also applies to: 58-66, 74-86, 87-99, 100-112

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

123-124: New setting field wired correctly.

serde(default) + Default(false) ensures backward compatibility; camelCase exposure aligns with TS type.

Also applies to: 189-190

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

396-396: Confirm this change is generated, not manual.

tauri.ts is auto-generated; ensure this property came from regenerating bindings after the Rust change, not by hand. Otherwise it will be overwritten.

As per coding guidelines.

@Brendonovich Brendonovich merged commit b200fe4 into main Oct 15, 2025
15 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