Add backup export and import under the log #4

Merged
govtech42 merged 2 commits from feat/backup into main 2026-08-27 14:49:16 +00:00
Owner

Export and import entries between browsers/machines (tenants) — localStorage cannot
cross origins, so a JSON file is the bridge.

What's in

  • Export: downloads pomotimer-backup-YYYY-MM-DD.json with every entry and the
    preferences ({v, exported, cfg, log}).
  • Import: merges by entry id — duplicates are skipped, so importing the same
    file twice is harmless. Invalid rows are ignored; a corrupt file changes nothing and
    shows a warning.
  • Preferences: importing into an empty browser = restore (brings theme, language
    and times); importing into one that already has entries = consolidation (local
    preferences stay untouched).
  • Buttons on the Log actions row, next to Copy/Print; inline feedback
    ("2 new entries · 2 already there").

Details

  • 4 new i18n keys across the six languages.
  • Self-check for the merge logic (mergeLogs) under ?test.
  • README documents the flow in the "Where your data lives" section.

Tested

  • Merge with a duplicate + an invalid row: only the new entries land, local prefs kept.
  • Restore into a clean browser: entries plus theme/language applied on the spot.
  • Corrupt file: log untouched, error message, clears after 6s.
  • Import accepts both the full backup and a raw array of entries.
Export and import entries between browsers/machines (tenants) — localStorage cannot cross origins, so a JSON file is the bridge. ## What's in - **Export**: downloads `pomotimer-backup-YYYY-MM-DD.json` with every entry and the preferences (`{v, exported, cfg, log}`). - **Import**: merges **by entry id** — duplicates are skipped, so importing the same file twice is harmless. Invalid rows are ignored; a corrupt file changes nothing and shows a warning. - **Preferences**: importing into an empty browser = restore (brings theme, language and times); importing into one that already has entries = consolidation (local preferences stay untouched). - Buttons on the Log actions row, next to Copy/Print; inline feedback ("2 new entries · 2 already there"). ## Details - 4 new i18n keys across the six languages. - Self-check for the merge logic (`mergeLogs`) under `?test`. - README documents the flow in the "Where your data lives" section. ## Tested - Merge with a duplicate + an invalid row: only the new entries land, local prefs kept. - Restore into a clean browser: entries plus theme/language applied on the spot. - Corrupt file: log untouched, error message, clears after 6s. - Import accepts both the full backup and a raw array of entries.
A third tab next to the timer and the clock. Day shows stacked hourly bars
(focus + break, trimmed to the active range); Week shows bars per weekday;
Month is a calendar of dots sized by focus time (area-proportional); Year is
a heatmap grouped by month. Every view carries the focus/break/block totals,
a focus-break ratio split bar and the average focus by time of day. Tapping
a day anywhere drills into the Day view.

Everything is aggregated on the fly from the existing log — no new storage,
no chart library, charts are plain divs. Monday-first everywhere, matching
the ISO week numbers shown in the month view. The model's "Interruptions"
stat is deliberately replaced by "Blocks": interruptions are not tracked and
tracking them would mean new storage.

Ten new i18n keys across the six languages; month, weekday and date names
come from Intl. Self-checks cover the ISO week (Sep 2026 = week 36), the
ratio rounding (20% / 23%, validated against the reference app) and the
splitting of entries across hour and period boundaries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Export downloads a JSON file with every entry plus the preferences; Import
reads one back and merges by entry id, so duplicates are skipped and
importing the same file twice is harmless. Invalid rows are ignored and a
corrupt file leaves the current data untouched. Importing into an empty
browser also restores the preferences (theme, language, times) — importing
into one that already has entries deliberately keeps the local preferences.

This is the bridge between browser+origin pairs: localStorage cannot cross
origins, a file can. Four new i18n keys across the six languages, and a
self-check for the merge logic.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
govtech42/pomolog!4
No description provided.