Skip to content

Add Template Mode and enhance parser validation#25

Merged
M-Nikox merged 13 commits into
masterfrom
regex
May 28, 2026
Merged

Add Template Mode and enhance parser validation#25
M-Nikox merged 13 commits into
masterfrom
regex

Conversation

@M-Nikox

@M-Nikox M-Nikox commented May 28, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a major new feature: Template Mode, which allows users to fully customize the output filename format for renamed files via a flexible template editor. In addition, it includes several parser improvements, enhanced rename safety checks, undo/redo performance and reliability improvements, and dependency updates. Below are the most important changes:


New Features: Template Mode

  • Adds a "Template mode" toggle and TemplateEditor component to the UI, enabling users to define custom output filename formats using tokens (e.g., {Show}, {SeasonZ}, {EpisodeZ}, etc.), with live preview and click-to-insert token chips. The template applies to both auto and manual modes, and a reset button restores the default template ({Show} - S{SeasonZ}E{EpisodeZ}). (CHANGELOG.md [1] src/renderer/App.tsx [2] [3] [4] src/renderer/components/TemplateEditor.tsx [5] src/renderer/hooks/usePreviews.ts [6]
  • The preview table and manual mode now always reflect the active template, ensuring consistent output. (src/renderer/App.tsx [1] [2] src/renderer/hooks/usePreviews.ts [3]

Parser and Scanner Improvements

  • Adds support for new anime-special and Japanese episode markers, and introduces a warning for trailing episode-like tokens after a match. Hidden files (dotfiles) are now excluded from scan results. (CHANGELOG.md [1] src/main/file-ops/scanner.ts [2]
  • Tightens the NNN compact format to reduce false positives from codec tags and year values. (CHANGELOG.md CHANGELOG.mdR7-R52)

Rename Safety and Undo/Redo Reliability

  • validateOperation now blocks any rename that would move a file outside its original directory, and explicitly rejects symbolic links as sources. (src/main/file-ops/renamer.ts [1] [2]
  • Undo/redo logic is refactored to use an indexed map for O(1) in-place patching of undo log entries, improving performance and correctness, especially for crash-recovery after cycle/swap operations. Pending undo entries are now more accurately detected. (src/main/file-ops/renamer.ts [1] [2] [3] [4] [5]

Dependency Updates

  • Updates dependencies to latest versions, including Electron, React, TypeScript, and others. (package.json [1] [2]

Tests

  • Adds tests for new parser patterns, trailing-episode-marker warnings, rename preflight blocking, and scanner exclusion of hidden files. (CHANGELOG.md CHANGELOG.mdR7-R52)

These changes provide powerful new customization options for filename formatting, improve parser accuracy, and make the rename and undo/redo features safer and more robust.

M-Nikox and others added 10 commits May 12, 2026 23:52
Agent-Logs-Url: https://github.com/M-Nikox/Slate/sessions/3f93a33c-fc01-4870-a963-7cfb4c706144

Co-authored-by: M-Nikox <101933576+M-Nikox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/M-Nikox/Slate/sessions/3f93a33c-fc01-4870-a963-7cfb4c706144

Co-authored-by: M-Nikox <101933576+M-Nikox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/M-Nikox/Slate/sessions/ce3eeba7-34d9-4534-a811-86b4e5272ede

Co-authored-by: M-Nikox <101933576+M-Nikox@users.noreply.github.com>
…and all real changes

Agent-Logs-Url: https://github.com/M-Nikox/Slate/sessions/4057e71f-70cc-4687-b57f-784be298db40

Co-authored-by: M-Nikox <101933576+M-Nikox@users.noreply.github.com>
Harden parser and rename safety for regex branch
@M-Nikox M-Nikox self-assigned this May 28, 2026
Copilot AI review requested due to automatic review settings May 28, 2026 11:18
@M-Nikox M-Nikox added the enhancement New feature or request label May 28, 2026

Copilot AI 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.

Pull request overview

This PR introduces Template Mode to let users customize renamed output filenames using token-based templates, while also improving parser accuracy/warnings, scanner filtering, and rename/undo safety and reliability.

Changes:

  • Add applyTemplate() + token set and wire template-based naming through renderer previews (auto + manual) with a new TemplateEditor UI.
  • Extend filename parser patterns (anime specials, Japanese markers), tighten compact NNN parsing, and surface structured parser warnings in the UI.
  • Strengthen file operation safeguards (exclude dotfiles in scanner; block cross-directory moves; improve undo-log patching performance and crash recovery).

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/parser/parser.test.ts Adds coverage for new parser patterns/warnings and template application behavior.
tests/main/scanner.test.ts Ensures hidden dotfiles are excluded from scan results.
tests/main/renamer.test.ts Adds coverage for cross-directory rename blocking.
src/shared/parser/parse-filename.ts Adds new episode patterns, tightens compact parsing, and emits trailing-marker warnings.
src/shared/parser/build-name.ts Introduces template tokens, applyTemplate(), and makes buildName() a wrapper over the default template.
src/renderer/hooks/usePreviews.ts Applies templates to all preview rows (auto/manual) and maps parser warning codes to UI messages.
src/renderer/components/TemplateEditor.tsx New template editor UI with token chips, reset, and live preview.
src/renderer/App.tsx Adds template state/mode toggle, shows TemplateEditor, and builds rename destination paths more robustly.
src/main/file-ops/scanner.ts Skips dotfiles during scanning.
src/main/file-ops/renamer.ts Blocks cross-directory moves, rejects symlink sources, and optimizes undo-log updates via indexing.
package.json Bumps app version and updates dependency versions.
CHANGELOG.md Documents Template Mode, parser/scanner updates, rename safety, undo changes, and tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/shared/parser/build-name.ts Outdated
Comment thread src/renderer/App.tsx
Comment thread src/main/file-ops/renamer.ts Outdated
M-Nikox and others added 3 commits May 28, 2026 13:27
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@M-Nikox M-Nikox merged commit e832aba into master May 28, 2026
9 checks passed
@M-Nikox M-Nikox deleted the regex branch May 28, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customizable output filename templates (e.g., {Show} - S{Season}E{Episode} - {Title})

3 participants