Skip to content

[Sync Framework] Migrate note-taker to sync framework (polling trigger) #26

Description

@Michael-Obele

Overview

Migrate note-taker to the centralized sync framework. This migration tests the PollingTrigger — note-taker currently uses polling-based sync with exponential backoff (2min base, 10min max) instead of event-triggered auto-backup.

Design doc: docs/plans/2026-06-21-sync-framework-design.md

Current state

  • src/routes/apps/(app)/note-taker/+page.svelte — polling-based sync with setInterval, exponential backoff on failure, syncInFlight state
  • src/routes/apps/(app)/note-taker/states.svelte.ts — custom PersistedState wrapper with IndexedDB adapter (noteAdapter), toServerFormat()/fromServerFormat() compatibility layer
  • src/lib/remote/note-taker.remote.tsgetNotes (query), syncNoteData (command), createNoteForm/updateNoteForm (forms), deleteNote (command)

Migration steps

  • Create app DB with createReactiveDB:
    const db = createReactiveDB({
      name: 'note-taker',
      version: 1,
      stores: {
        notes: { keyPath: 'id' },
      },
    });
  • Replace noteAdapter + PersistedState with db.notes.liveAll()
  • Migrate note-taker.remote.ts to factory functions
  • Create SyncManager with polling trigger:
    strategy: serverWins,  // server is source of truth for notes
    trigger: 'polling',
    pollingInterval: 120000,      // 2 minutes (keep existing base)
    maxPollingInterval: 600000,   // 10 minutes (keep existing max)
  • Preserve existing form-based CRUD (createNoteForm, updateNoteForm) — these stay as-is, only the sync layer changes
  • Update +page.svelte — replace polling logic with sync.handleSync() (PollingTrigger handles interval + backoff automatically)
  • Run bun check + svelte-autofixer
  • Test polling sync + backoff on network failure

What stays app-specific

  • Form-based CRUD operations (createNoteForm, updateNoteForm, deleteNote)
  • Data type (Note)
  • serverWins merge strategy (server is source of truth)

Prisma models (existing)

  • Note → store notes

Blocked by

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions