Skip to content

fix: duplicate regex in prune, redundant cloning in undo/redo, typo#723

Open
fix2015 wants to merge 1 commit into
webadderallorg:mainfrom
fix2015:fix/typo-duplicate-regex-and-undo-perf
Open

fix: duplicate regex in prune, redundant cloning in undo/redo, typo#723
fix2015 wants to merge 1 commit into
webadderallorg:mainfrom
fix2015:fix/typo-duplicate-regex-and-undo-perf

Conversation

@fix2015

@fix2015 fix2015 commented Jul 3, 2026

Copy link
Copy Markdown

A few things I found:

  • `pruneAutoRecordings` had an inline regex `/^recording-.*\.(mp4|mov|webm)$/i` that duplicates the logic from `isAutoRecordingPath`. If the pattern is ever updated in one place but not the other, the prune function will miss files or prune the wrong ones. Replaced the inline regex with a call to `isAutoRecordingPath(entry.name)` which is already imported.

  • undo/redo in `editorHistory.ts` were each cloning snapshots 3 times via `structuredClone` when 2 is sufficient. Since snapshots can contain all zoom/clip/speed/annotation/audio/caption data, that's a meaningful amount of unnecessary copying on every undo/redo action. Reduced to clone once for storage and once for the return value.

  • fixed "seperate" → "separate" typo in audioFilters.ts comment

Summary by CodeRabbit

  • Bug Fixes
    • Improved auto-recording cleanup so matching files are identified more reliably during pruning.
    • Made undo/redo history handling more consistent, helping prevent unexpected editor state issues.

- pruneAutoRecordings had an inline regex that duplicated the logic
  from isAutoRecordingPath — if one gets updated without the other,
  wrong files get pruned. replaced with a call to isAutoRecordingPath.
- undo/redo were cloning snapshots 3 times each when 2 is sufficient.
  reduced the redundant clone to avoid the extra structuredClone cost
  on every undo/redo operation.
- fixed "seperate" → "separate" in audioFilters comment
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR makes three small, unrelated edits: corrects a comment typo in an audio filters constant, replaces a regex-based filename filter with a helper function isAutoRecordingPath in the recording prune logic, and simplifies clone assignment in undo/redo editor history functions.

Changes

Miscellaneous small fixes

Layer / File(s) Summary
Auto-recording prune filter update
electron/ipc/recording/prune.ts
Filters directory entries using isAutoRecordingPath(entry.name) instead of a hardcoded filename regex when building auto-recording stats.
Editor history undo/redo cloning cleanup
src/components/video-editor/editorHistory.ts
undoEditorHistoryStack and redoEditorHistoryStack clone the previous/next snapshot once into a local variable, assign it to stack.current, and return a clone derived from that local.
Comment spelling correction
electron/ipc/recording/audioFilters.ts
Fixed "seperate" to "separate" in a comment on the RECORDING_AUDIO_SIDECAR_DEBUG_ENV constant.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • webadderallorg/Recordly#544: Overlaps with the same undo/redo stack logic in src/components/video-editor/editorHistory.ts via an editor history state-model refactor.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes, but it omits required template sections like Type of Change, Testing Guide, and Checklist. Rewrite the PR body using the template and add the missing sections: Description, Motivation, Type of Change, Related Issue(s), Testing Guide, and Checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title summarizes the three changes and stays concise and specific.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

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

⚠️ Outside diff range comments (1)
electron/ipc/recording/prune.ts (1)

128-136: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

isAutoRecordingPath needs the video-extension check
recording-*.cursor.json and recording-*.{system,mic}.{m4a,wav,webm} also start with recording-, so this prefix-only filter counts sidecars as recordings. That skews retention and sends non-video entries through the video-specific cleanup path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@electron/ipc/recording/prune.ts` around lines 128 - 136, The auto-recording
scan is using only the filename prefix, so sidecar files like cursor JSON and
audio files are being treated as recordings. Update the filter in the recording
pruning flow around the autoRecordingStats Promise.all pipeline to use
isAutoRecordingPath with the video-extension check, so only actual video
recordings are included and sidecars are excluded from the video cleanup path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@electron/ipc/recording/prune.ts`:
- Around line 128-136: The auto-recording scan is using only the filename
prefix, so sidecar files like cursor JSON and audio files are being treated as
recordings. Update the filter in the recording pruning flow around the
autoRecordingStats Promise.all pipeline to use isAutoRecordingPath with the
video-extension check, so only actual video recordings are included and sidecars
are excluded from the video cleanup path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 709df9a0-4555-4163-92ef-56077469e2b3

📥 Commits

Reviewing files that changed from the base of the PR and between 641d223 and f47ff4a.

📒 Files selected for processing (3)
  • electron/ipc/recording/audioFilters.ts
  • electron/ipc/recording/prune.ts
  • src/components/video-editor/editorHistory.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant