Skip to content

fix: prevent sync from dropping local prompts#19

Open
anwarselo wants to merge 1 commit intobladnman:mainfrom
anwarselo:fix/prevent-sync-data-loss
Open

fix: prevent sync from dropping local prompts#19
anwarselo wants to merge 1 commit intobladnman:mainfrom
anwarselo:fix/prevent-sync-data-loss

Conversation

@anwarselo
Copy link
Copy Markdown

Summary

  • prevent Firestore sync from replacing local data with a partial cloud snapshot
  • recover orphaned prompt markdown files back into the local index
  • rebuild a missing index from prompt files and cover the recovery paths with tests

Problem

PromptLight syncs from Firestore during auth/startup. If the cloud snapshot is non-empty but missing some locally indexed prompts, the current sync flow can overwrite the local index with that partial cloud state. The prompt markdown files remain on disk, but they become orphaned and disappear from the app.

Changes

  • add a sync safety guard that skips cloud downloads when the snapshot would remove existing local prompt IDs
  • load on-disk local data without seeding sample prompts when sync safety checks run
  • reimport orphaned prompt files by scanning the prompt folders and restoring missing index entries
  • rebuild index.json from prompt files when the index is missing
  • prefer non-uncategorized duplicates when the same prompt file exists in multiple folders
  • add regression tests for the cloud guard and local recovery flows

Validation

  • cargo test

Notes

After installing the patched build locally, launching the app once restored a real affected data set from 4 indexed prompts back to 22 indexed prompts by reimporting the existing prompt files.

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.

1 participant