Skip to content

Optimize synchronization with two-step metadata check and new interval options#65

Open
adiagarwalrock wants to merge 3 commits into
devfrom
fix/live-sync-payload
Open

Optimize synchronization with two-step metadata check and new interval options#65
adiagarwalrock wants to merge 3 commits into
devfrom
fix/live-sync-payload

Conversation

@adiagarwalrock

Copy link
Copy Markdown
Member

This pull request introduces several optimizations and improvements to the live sync and polling mechanisms for diagrams and notes, as well as some UI and configuration enhancements. The main focus is on reducing unnecessary data transfer during polling by first fetching only metadata (such as id and updatedAt) to check for changes, and only fetching full content if changes are detected. Additionally, the default live sync interval is increased, and users can now select longer sync intervals in the settings.

Live Sync and Polling Optimizations:

  • The useListSync and useLiveSync hooks now perform an initial lightweight metadata fetch (using select=id,updatedAt or select=updatedAt) to detect changes, and only fetch full data if a change is detected. This reduces bandwidth and improves efficiency. [1] [2] [3]
  • The /api/diagrams and /api/notes endpoints support a select query parameter, allowing clients to request only specific fields (e.g., id,updatedAt), and the corresponding data access functions (getDiagramPage, getNotePage) support a metadataOnly flag to return minimal objects for sync checks. [1] [2] [3] [4] [5] [6]
  • New helper functions getDiagramUpdatedAt and getNoteUpdatedAt are added to fetch only the updatedAt field for individual diagrams and notes. The GET handlers for /api/diagrams/[id] and /api/notes/[id] use these when select=updatedAt is requested. (src/app/api/diagrams/[id]/route.tsL12-R12, src/app/api/diagrams/[id]/route.tsR25-R35, [1] src/app/api/notes/[id]/route.tsL14-R14, src/app/api/notes/[id]/route.tsR40-R50, [2]

Live Sync Interval and Settings:

  • The default live sync interval is increased from 5 seconds to 30 seconds to reduce server load and network usage. [1] [2]
  • The settings page now allows users to select longer live sync intervals (1 minute and 5 minutes) for more flexibility.

UI and Minor Improvements:

  • Minor UI tweaks to the DashboardHeader component for improved class order and readability.

These changes collectively improve the scalability and efficiency of live sync, especially for users with large lists of diagrams or notes.

…p metadata check before fetching full data, and add new sync interval options.
Copilot AI review requested due to automatic review settings May 1, 2026 05:11
@github-project-automation github-project-automation Bot moved this to Backlog in Atlantis May 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes client-side live sync/polling for diagrams and notes by adding a lightweight “metadata first” check (updated timestamps) before fetching full payloads, and expands configurable sync intervals. It also introduces API support for metadata-only selection and adds Docker Compose deployment configs.

Changes:

  • Update useLiveSync / useListSync to do a metadata check (select=updatedAt / select=id,updatedAt) before fetching full data.
  • Add metadata-only support in diagrams/notes list + item endpoints and new helpers to fetch only updatedAt.
  • Increase the default live sync interval and add longer interval choices in Settings; add Docker Compose configurations.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/lib/useLiveSync.ts Two-step polling: check updatedAt first, fetch full resource only on change; default interval increased.
src/lib/useListSync.ts Two-step list polling: fetch id,updatedAt first, fetch full list only if changed.
src/lib/store.ts Updates default settings (liveSyncInterval now 30s).
src/lib/notes-data.ts Adds metadataOnly mode for notes paging + getNoteUpdatedAt.
src/lib/data.ts Adds metadataOnly mode for diagrams paging + getDiagramUpdatedAt.
src/components/DashboardHeader.tsx Minor Tailwind class reordering.
src/app/settings/page.tsx Adds 1-minute and 5-minute interval options.
src/app/api/notes/route.ts Supports select=id,updatedAt for metadata-only list responses when bypassing cache.
src/app/api/notes/[id]/route.ts Supports select=updatedAt for fresh metadata-only fetch.
src/app/api/diagrams/route.ts Supports select=id,updatedAt for metadata-only list responses when bypassing cache.
src/app/api/diagrams/[id]/route.ts Supports select=updatedAt for fresh metadata-only fetch.
docker/docker-compose.yml Adds full-stack compose (app + Redis).
docker/docker-compose.simple.yml Adds simplified compose (app only).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/data.ts
Comment thread src/lib/data.ts Outdated
Comment thread src/lib/data.ts Outdated
Comment thread src/lib/store.ts
Comment thread src/lib/notes-data.ts
Comment thread src/lib/notes-data.ts Outdated
Comment thread src/lib/notes-data.ts Outdated
- Refactor `getDiagramPage` and `getNotePage` functions to support metadata-only retrieval.
- Introduce `DiagramMetadataPage` and `NoteMetadataPage` interfaces for structured metadata responses.
- Implement utility functions for normalization of limits and offsets.
- Add sorting capabilities for diagrams and notes based on various criteria.
- Improve database URL resolution with writable path checks for SQLite.
- Update Zustand store to ensure proper merging of persisted settings.
- Enhance type definitions for better clarity and maintainability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants