Skip to content

Show a Warning in the Flutter UI When Sync Resolves Conflicts #25

@TheZupZup

Description

@TheZupZup

Overview

Context: The Python backend already handles sync conflicts automatically using one of three strategies (LAST_WRITE_WINS, KEEP_BOTH, MERGE_STROKES — see nexanote/sync/conflict.py). After a sync, GET /sync/status returns a conflicts_resolved count. The SettingsScreen displays this count in its sync stats section.

The gap: If conflicts were resolved during a sync triggered from the sidebar button, the user gets no feedback — they'd have to navigate to Settings to see the count. Worse, with KEEP_BOTH strategy, a conflict copy is created as a new note, and the user won't know it exists unless they happen to scroll to it.

What needs to be done

  • After any sync completes (in AppState.triggerSync() or wherever getSyncStatus() is called), check if conflicts_resolved > 0
  • If yes, show a persistent (non-auto-dismissing) SnackBar or AlertDialog with a message like: "Sync resolved 2 conflicts. If using 'Keep Both' strategy, conflict copies have been added to your notes."
  • Include an action button in the snackbar: "View notes" — which dismisses the snackbar and calls loadNotes() to refresh the list (so the user can see any new conflict copies)
  • If the sync strategy is KEEP_BOTH, also call loadNotes() automatically after sync so conflict copies appear without requiring manual action

Goal

After a sync that resolved conflicts, the user immediately sees a warning that something was auto-resolved and can navigate to their notes to review the outcome — without needing to open Settings.

Where to look

  • app/lib/services/app_state.darttriggerSync(), add getSyncStatus() call after sync
  • app/lib/widgets/notebook_sidebar.dart — sync button (where the ScaffoldMessenger context is accessible)
  • app/lib/screens/settings_screen.dart — reference for how conflicts_resolved is currently read

Testing steps

  • Set up two instances of the backend, edit the same note on both, sync one — verify the conflict count is > 0 and the warning appears in the Flutter app
  • Verify the "View notes" button reloads the notes list
  • Run a sync with no conflicts — verify no warning appears

Related to: #17, #22, #23

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions