Skip to content

Conversation

chhoumann
Copy link
Owner

Summary

Implements a comprehensive auto-rename system that automatically updates all file and folder references in QuickAdd when they are renamed in the vault. This addresses issue #769 and extends well beyond the original request to provide complete coverage.

What Changed

🎯 Core Auto-Rename System

  • Complete coverage: Auto-rename now works for destination folders, template files, user scripts, format string references, and global settings
  • Event-driven architecture: Uses Obsidian's vault.on('rename') events for real-time updates
  • Safe operations: Backup/rollback pattern with structuredClone() for error recovery
  • Format string parsing: Regex-based parsing of {{TEMPLATE:path}} and {{FIELD:|folder:path}} syntax

🔧 Technical Implementation

  • New utilities: FolderPathUpdater, FormatStringPathParser for modular path updating
  • Enhanced service: PathRenameHandler with comprehensive file/folder detection and global settings support
  • Recursive processing: Multi-choice traversal and nested path reference handling
  • Settings integration: Zustand store with automatic persistence

⚙️ Comprehensive Settings UI

  • Organized section: Clear "Auto-Rename Settings" with description and hierarchical controls
  • Granular control: Individual toggles for each auto-rename feature type
  • Smart visibility: Sub-settings automatically hide when main toggle is disabled
  • User feedback: Enhanced notifications that inform about global settings updates

📋 Coverage Details

  • Destination folders in choice configurations
  • Template files in Template and Capture choices
  • User scripts in Macro choices
  • Format references in format strings ({{TEMPLATE:path}}, {{FIELD:|folder:path}})
  • Global settings (templateFolderPath, ai.promptTemplatesFolderPath)
  • Notifications with comprehensive update reporting

Testing

  • All 446 tests pass including 24 new auto-rename tests
  • TypeScript compilation succeeds
  • Build successful (6.0mb output)
  • Backward compatibility maintained

Benefits

  • User Experience: No more manually updating broken path references after renames
  • Comprehensive: Covers ALL path references in QuickAdd ecosystem
  • Safe: Backup/rollback prevents data loss on errors
  • Configurable: Users can enable/disable specific auto-rename features
  • Informative: Clear notifications show what was updated

Closes #769

Extends the auto-rename feature to cover all file and folder references throughout QuickAdd, not just basic folder paths in choices.

## New Features

### Extended Auto-Rename Coverage
- Template file paths (templatePath in Template choices)
- Template files for capture creation (createFileIfItDoesntExist.template)
- User script paths in macro commands (IUserScript.path)
- Open file command paths (IOpenFileCommand.filePath)
- Format string embedded references ({{TEMPLATE:path}} and {{FIELD:|folder:path}})

### File Rename Support
- Added support for file renames in addition to folder renames
- Smart detection using file extensions and Obsidian file types
- Separate handling logic for file vs folder renames

### Format String Processing
- New FormatStringPathParser for parsing embedded path references
- Handles {{TEMPLATE:path}} syntax for template references
- Handles {{FIELD:name|folder:path}} syntax for field folder filters
- Preserves filter order and non-path filters during updates

## Technical Implementation

### Core Components
- **FolderPathUpdater**: Extended to handle all choice types and format strings
- **FormatStringPathParser**: New utility for parsing/updating format syntax
- **PathRenameHandler**: Replaces FolderRenameHandler with broader scope
- **Enhanced Settings**: Added granular controls for different rename types

### Updated Choice Handling
- **Capture**: captureTo, template fields, format strings
- **Template**: templatePath, folder.folders, fileNameFormat strings
- **Macro**: user script paths, open file commands
- **Multi**: recursive processing of nested choices

### New Settings
- autoRenameTemplateFiles: Enable/disable template file auto-rename
- autoRenameUserScripts: Enable/disable user script auto-rename
- autoRenameFormatReferences: Enable/disable format string updates
- (autoRenameDestinationFolders: existing folder setting)

## Testing
- Comprehensive test suite for FormatStringPathParser (14 tests)
- Extended FolderPathUpdater tests (10 tests)
- All existing tests pass (446 total)
- Covers edge cases, format preservation, and error handling

## Backward Compatibility
- Maintains all existing functionality
- Existing settings continue to work
- New features default to enabled for seamless experience
- No breaking changes to existing API

Addresses issue #769 with comprehensive solution covering all file/folder references in QuickAdd.
- Extended PathRenameHandler to support global settings auto-rename
- Added monitoring for templateFolderPath and ai.promptTemplatesFolderPath
- Enhanced notification system to include global settings updates
- Replaced basic auto-rename UI with comprehensive organized section
- Added granular controls for all auto-rename features:
  - Destination folders, template files, user scripts
  - Format references, global settings, notifications
- Implemented hierarchical settings with smart visibility management
- Maintained backward compatibility and proper styling

Addresses #769 with comprehensive auto-rename coverage
Copy link

vercel bot commented Aug 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
quickadd Ready Ready Preview Sep 1, 2025 3:35pm

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.

[FEATURE REQUEST] Auto-rename destination folders when those folders are renamed from user in the vault
1 participant