Skip to content

Conversation

hjamet
Copy link
Contributor

@hjamet hjamet commented May 21, 2025

This pull request introduces several significant enhancements to the VoiceNotes Sync plugin, focusing on improved authentication stability, more robust synchronization, new template capabilities, and better user feedback.

Summary of Changes:

The primary goal was to address issues with frequent disconnections by implementing an automatic re-authentication mechanism. Additionally, the plugin now handles API rate limits more gracefully, provides better progress feedback during full syncs, and offers new options for displaying image descriptions and manual note entries within the Obsidian notes.

Key Features & Enhancements:

  1. Automatic Re-authentication:

    • Implemented a system where the plugin attempts to automatically re-login with stored credentials (username and password, held in memory) if an API request fails due to an expired or invalid token (401 error).
    • Ensured credentials from the settings UI are correctly passed to the active API client instance.
    • Improved logout process to clear credentials from the API client.
  2. Rate Limit Handling (429 Errors):

    • The API client now detects "Too Many Requests" (429) errors from the server.
    • It respects the Retry-After header (or uses a default delay) to wait before automatically retrying the request.
    • User is notified in Obsidian if sync is paused due to rate limiting.
  3. Improved Sync Error Handling & Feedback:

    • The main sync process now provides more specific error messages to the user based on the type of error encountered (e.g., authentication failure, rate limiting, credentials not available).
    • Console logging during "Full Sync" has been enhanced to show progress while fetching pages of recordings and while processing individual notes.
  4. Feature: Display Image Descriptions:

    • Added a new setting (default: ON) to show descriptions for image attachments.
    • If enabled, the description provided for an image in VoiceNotes will be displayed in italics directly below the embedded image in the Obsidian note.
    • Optimized image attachment handling to check for local existence before re-downloading.
  5. Feature: Manual Entries ({{entries}} Template Variable):

    • Added support for a new template variable {{entries}}.
    • This variable collates descriptions from "manual note" attachments (identified as type: 3 in the API data).
    • Users can now include these manually added notes from VoiceNotes directly into their Obsidian note structure using the {{entries}} variable in their note template.
    • The default note template has been updated with a section for these entries.

Bug Fixes:

  • Resolved an issue where the settings panel could appear blank or throw an error on opening due to the API client not being fully initialized. Added guards and improved initialization logic.
  • Addressed various TypeScript linter errors (e.g., implicit any types) in the settings panel code.
  • Corrected how the API client instance was referenced and managed within the settings tab to ensure consistency with the main plugin instance.

Testing:

  • Manual testing was performed for login (username/password and token), logout, standard sync, full sync, rate limit scenarios (simulated), image description display, and manual entry display.
  • Console logs were monitored for re-authentication attempts and error handling.

This series of changes aims to make the plugin more reliable, user-friendly, and feature-rich.

hjamet added 3 commits May 21, 2025 11:12
…g username and password handling, improved error notifications, and robust API request management. Added username field to settings and updated API class to manage credentials securely. Improved sync process with detailed logging and error handling for better user experience.
Introduced a new setting to enable or disable the display of image descriptions below attachments. Updated the main functionality to conditionally include descriptions in the generated markdown. Ensured that files are only downloaded if they do not already exist in the vault.
…ate variables

Implemented a new section for manual entries in the generated notes. Updated the handling of attachments to improve markdown formatting and prevent conflicts with variable names. Enhanced the note template to include the new {{entries}} variable for better customization.
@hjamet
Copy link
Contributor Author

hjamet commented May 21, 2025

Should solve #77, #76, #72, #67, #58 and #36

Updated the retry logic for handling 429 status errors by checking both 'retry-after' and 'Retry-After' headers. Set a default retry duration and enhanced logging for better visibility during rate limit scenarios.
Copy link
Member

@kinabalu kinabalu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this, though I am unsure that this is the right approach yet. working on some of this now

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