Fix Vocabulary Watcher Integration and OpenGraph Configuration

Fix Vocabulary Watcher Integration and OpenGraph Configuration

Problem

The vocabulary directory was not being properly watched by the frontmatter observer system. When files were added or modified in this directory, they were not triggering the appropriate actions such as extracting frontmatter and applying template defaults. Additionally, when the VocabularyWatcher was implemented, it created an infinite loop by repeatedly processing the same files.
Furthermore, even though OpenGraph was explicitly disabled in the configuration for vocabulary files, the observer was still triggering OpenGraph processing for these files.

Solution

  1. Integrated the VocabularyWatcher with the main FileSystemObserver by:
    • Adding a startVocabularyWatcher method to the FileSystemObserver class
    • Updating the main observer index.ts to call this method
    • Ensuring the VocabularyWatcher uses the same file tracking mechanism as the main observer
  2. Improved the VocabularyWatcher implementation to:
    • Accept the directory path as a parameter instead of using a hardcoded path
    • Use the property collector pattern to prevent unnecessary file writes
    • Integrate with the FileSystemObserver's processed files tracking to prevent infinite loops
    • Properly log validation results to the reporting service
  3. Added proper file processing status tracking:
    • Added static methods to FileSystemObserver to expose the processed files set
    • Modified VocabularyWatcher to use callbacks for file status tracking
    • Ensured files processed by either watcher are marked as processed in both systems
  4. Fixed OpenGraph configuration respect:
    • Updated the FileSystemObserver to properly check if OpenGraph is enabled in the directory configuration before evaluating and processing OpenGraph
    • Modified the OpenGraph processing code to only run when OpenGraph is explicitly enabled (openGraph === true)
    • Added additional logging to show when OpenGraph processing is skipped due to configuration

Files Changed

  • /tidyverse/observers/fileSystemObserver.ts
  • /tidyverse/observers/watchers/vocabularyWatcher.ts
  • /tidyverse/observers/index.ts

Technical Details

The key improvement was implementing a shared file tracking system between the main FileSystemObserver and the specialized VocabularyWatcher. This prevents files from being processed multiple times, which was causing the infinite loop. Additionally, the VocabularyWatcher now uses the same property collector pattern as the main observer, which only updates the specific frontmatter fields that need to be changed rather than rewriting the entire frontmatter.
For the OpenGraph configuration fix, we updated the FileSystemObserver to strictly check if OpenGraph is enabled (openGraph === true) before triggering any OpenGraph-related processing. This ensures that directories with OpenGraph explicitly disabled (like the vocabulary directory) don't have unnecessary OpenGraph processing performed on their files.