Skip to content

fix: manual fix not working - #7

Open
edabe wants to merge 6 commits into
leonardsellem:mainfrom
edabe:fix/manual-sync
Open

fix: manual fix not working#7
edabe wants to merge 6 commits into
leonardsellem:mainfrom
edabe:fix/manual-sync

Conversation

@edabe

@edabe edabe commented May 5, 2026

Copy link
Copy Markdown

PR Description: Fix incremental sync to detect transcribed notes

Problem

The incremental sync feature was not detecting notes that were transcribed after the initial sync. When a user transcribed an existing recording in the Plaud app, running "Plaud Sync: sync now" in Obsidian would show selected: 0 and skip the transcribed note entirely.

Root Cause

The sync logic only checked start_time (the original recording timestamp) to determine if a file had changed. When a note is transcribed:

  • start_time remains unchanged (original recording time)
  • The note's content is updated with transcription, summary, and highlights
  • Manual sync would skip it because start_time <= lastSyncCheckpoint

Solution

Use the edit_time field from the Plaud API to track when files were last modified. The API provides two timestamps with different purposes:

  • edit_time (seconds): When the file was last modified (creation OR transcription)
  • start_time (milliseconds): When the recording was made (for display/filename)

Changes

  1. Added edit_time field to PlaudFileSummary interface
  2. Simplified shouldSyncFile() to use only edit_time for sync decisions
  3. Updated checkpoint logic to track edit_time instead of start_time
  4. Preserved start_time for display purposes (filenames, frontmatter dates)

Benefits

  • Detects both new recordings AND transcribed notes
  • Simplified sync logic (removed complex fallback chains)
  • Single source of truth for "what changed"
  • Maintains correct recording dates in filenames
  • Reduces code complexity

Testing

Tested with the following scenario:

  1. Initial sync with checkpoint at zero → all notes synced
  2. Transcribed an existing note in Plaud web UI
  3. Ran manual sync → note was correctly detected and updated

Before Fix

[plaud-sync] Starting manual sync...
[plaud-sync] Sync completed: {listed: 1000, selected: 0, created: 0, updated: 0, ...}

After Fix

[plaud-sync] Starting manual sync...
[plaud-sync] Sync completed: {listed: 1000, selected: 1, created: 0, updated: 1, ...}

Files Changed

  • src/plaud-api.ts: Added edit_time?: number to PlaudFileSummary
  • src/plaud-sync.ts: Updated sync logic to use edit_time

Backward Compatibility

Fully backward compatible - existing vaults will continue to work. The checkpoint will naturally transition to using edit_time on the next sync.

edabe added 6 commits May 4, 2026 22:11
- Add console logging for plugin load and sync operations
- Show informative message when no new recordings to sync
- Include checkpoint timestamps in console logs
- Improve user experience for incremental sync behavior
- Add edit_time field to PlaudFileSummary interface
- Simplify shouldSyncFile to use only edit_time for sync decisions
- Simplify checkpoint logic to track only edit_time
- Keep start_time for display purposes (filenames, dates)
- Fixes issue where transcribed notes were not detected by manual sync
@leonardsellem

Copy link
Copy Markdown
Owner

Thanks for the detailed root-cause write-up. Switching incremental sync to Plaud edit_time looks like the right direction; this just needs the tests and edge-case contract tightened before merge.

Minimum fixes:

  • Carry forward the readiness fixes from the stacked changes: update the excludeWithoutTranscript settings test, update the rename mock/tests from the filename-sync change, and remove the trailing whitespace reported by git diff --check.
  • Update the sync tests for the new edit_time contract. The existing tests still provide only start_time, so shouldSyncFile() now selects extra files and the checkpoint assertions fail. Please add edit_time values in seconds and assert that the saved checkpoint is the corresponding millisecond high-watermark.
  • Add the core regression for this PR: a recording with an old start_time but a newer edit_time should be selected and updated, proving that newly transcribed notes are detected.
  • Decide and test the missing-edit_time fallback. The current code selects files with no edit_time on every run, but does not advance the checkpoint for them, so legacy/no-edit_time responses can be reprocessed forever. Either fall back to start_time for checkpointing or document/test that always-resync behavior explicitly.

I verified npm run build passes, but npm test currently has 5 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