Skip to content

feat: synchronize file name#6

Open
edabe wants to merge 4 commits into
leonardsellem:mainfrom
edabe:feature/sync-filename
Open

feat: synchronize file name#6
edabe wants to merge 4 commits into
leonardsellem:mainfrom
edabe:feature/sync-filename

Conversation

@edabe

@edabe edabe commented May 5, 2026

Copy link
Copy Markdown

Synchronizes file name to either match the new pattern, or when the note title in Plaud has changed.

How it works:

When syncing with "Update existing notes" enabled:

  1. The plugin finds existing notes by matching the file_id in frontmatter
  2. It calculates what the filename should be based on the current filename pattern
  3. If the current filename doesn't match the desired filename:
    • The file is renamed to match the new pattern
    • The content is updated with the latest data from the API
    • The action is counted as "renamed" in the sync summary
  4. If the filename already matches, it just updates the content (counted as "updated")

Changes made:

  1. src/plaud-vault.ts:

    • Added rename() method to PlaudVaultAdapter interface
    • Added 'renamed' action type to UpsertPlaudNoteResult
    • Added optional oldPath field to track the previous filename
    • Updated upsertPlaudNote() to compare current filename with desired filename and rename if different
  2. src/main.ts:

    • Implemented rename() method in vault adapter using Obsidian's vault.rename() API
    • Updated formatSyncSummary() to include renamed count in the notification message
  3. src/plaud-sync.ts:

    • Added renamed counter to PlaudSyncSummary interface
    • Updated sync loop to track and count renamed files

Example behavior:

Before: Files named plaud-2025-09-24-meeting-notes.md
After changing pattern to {title}: Files renamed to meeting-notes.md
Sync message: "Plaud sync complete. Created 0, updated 5, renamed 3, skipped 2, failed 0."

The build completed successfully with no errors!

@leonardsellem

Copy link
Copy Markdown
Owner

Thanks for the clear feature write-up. The rename behavior makes sense; I think this PR is close, but it needs a small readiness pass before it is safe to merge.

Minimum fixes:

  • Update the inherited settings test for excludeWithoutTranscript: test/settings-schema.test.mjs still expects the old DEFAULT_SETTINGS key set, so npm test currently fails there.
  • Update the vault tests for the new rename contract. upsertPlaudNote() now calls vault.rename() when the existing filename no longer matches the desired filename, but the mock vault does not implement rename(), and the existing “updates in place” tests use stale filenames. Please add rename() to the mock, make the update-only tests use already-matching filenames, and add/adjust a focused test that expects action: 'renamed', oldPath, the new path, and the content write after rename.
  • Remove the trailing whitespace reported by git diff --check in src/plaud-sync.ts and src/plaud-vault.ts.

I verified npm run build passes, but npm test currently has 3 failures and git diff --check fails. Once those pass, this should be ready to merge.

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