Phase 1: backup, encrypted sync and monthly-usage handling
Safety net and errors, mobile-first, desktop unchanged in behaviour. Backup and persistence - Settings -> Data & backup: 'Export all data' writes one zod-validated JSON (decks, folders, homework, progress, safe settings; the API key is not part of the shape and never appears in the file). - 'Import backup' validates, shows a preview with added/replaced counts and offers merge or replace; invalid files get a friendly error. Storage persistence (navigator.storage.persist) is shown and requestable, with the result reported. - A dismissible nudge appears after 5 new decks or 14 days without a backup and stays snoozed for 14 days. Opt-in encrypted sync (off by default) - New lib/sync.ts: PBKDF2-SHA256 (310k) -> AES-GCM-256, derived key kept as a non-extractable CryptoKey in IndexedDB (lib/sync-key.ts); the passphrase and key never leave the browser. - New POST/GET/DELETE /api/sync following the route pattern (locale, cross-origin guard, body cap, rate limit RATE_LIMIT_SYNC, auth before body parsing, zod validation). One atomic JSON file per random 128-bit sync ID under SYNC_DIR; server-stamped updatedAt is the conflict clock; SYNC_MAX_BYTES and SYNC_TOTAL_BYTES enforced (413 / 507). The server only ever sees an opaque envelope. - Settings -> Sync: enable with a passphrase, copy the sync ID, sync now, last-synced time, explicit keep-this-device / use-synced-copy conflict choice, join from another device (ID + passphrase, wrong passphrase rejected), unlock after the key is gone, delete the synced copy (works even on a locked device). Every data store marks sync dirty on write; pulled payloads are applied without marking dirty again. Monthly usage vs short-term throttling - lib/ollama.ts classifies the real 429 body (monthly/quota/upgrade vs burst) into new 'usage_limit' and 'throttled' kinds, mapped in every route and in the health probe. - The client renders the same localized message in the deck flow, homework, grading and the Settings banner: the required upgrade/new-key copy with 'Open Settings' (jumps to and focuses the key field) and 'Open Ollama'. Input and wizard drafts are kept so Retry works right after swapping the key. No model fallback. Verified: new phase-1 suite 38/38 (backup content + no key, import preview/merge/replace, junk file, persistence row, nudge + snooze, sync enable/upload/opaque blob/push/join/wrong passphrase/delete, server validation 400/401, usage-limit copy and key focus, and the real route mapping against a stub Ollama for both 429 variants) plus regression 74/74, mobile 52/52, wizard 80/80, declutter 116/116, animation 8/8, native 35/35, i18n 25/25. Key parity 638/638. Lint + build clean. SW freezmo-v25.
This commit is contained in:
parent
1dc2992fb5
commit
bb1f4e2018
31 changed files with 1933 additions and 36 deletions
156
lib/i18n-dict.ts
156
lib/i18n-dict.ts
|
|
@ -151,6 +151,70 @@ const en: Record<string, string> = {
|
|||
"settings.haptics": "Haptics",
|
||||
"settings.hapticsNote": "Vibration feedback on supported phones.",
|
||||
|
||||
/* data, backup & sync --------------------------------------------- */
|
||||
"settings.data": "Data & backup",
|
||||
"settings.dataNote": "Everything lives in this browser. Export a backup regularly.",
|
||||
"settings.exportAll": "Export all data",
|
||||
"settings.exportNote": "Decks, homework, progress and settings — never your API key.",
|
||||
"settings.importBackup": "Import backup",
|
||||
"settings.importPreview": "This backup has {decks} decks, {homework} homework results and {folders} folders.",
|
||||
"settings.importMergeNote": "Merge keeps what's here and adds the backup; matching IDs are replaced.",
|
||||
"settings.importReplaceNote": "Replace wipes this browser's data and uses the backup instead.",
|
||||
"settings.importMerge": "Merge",
|
||||
"settings.importReplace": "Replace",
|
||||
"settings.importCancel": "Cancel",
|
||||
"settings.importDone": "Imported {decks} decks and {homework} homework results.",
|
||||
"settings.importFailed": "That backup could not be imported.",
|
||||
"settings.storage": "Storage",
|
||||
"settings.storagePersistent": "Persistent — the browser won't evict your data.",
|
||||
"settings.storageBestEffort": "Best-effort — the browser may clear data under pressure.",
|
||||
"settings.storageRequest": "Ask for persistence",
|
||||
"settings.storageGranted": "Granted — your data is now persistent.",
|
||||
"settings.storageDenied": "The browser declined. Installing the app usually helps.",
|
||||
"settings.backupNudgeTitle": "Back up your decks?",
|
||||
"settings.backupNudgeBody": "You've added decks since your last backup. A backup keeps them safe.",
|
||||
"settings.backupNow": "Back up now",
|
||||
"settings.backupLater": "Not now",
|
||||
"settings.sync": "Sync",
|
||||
"settings.syncNote":
|
||||
"Off by default. Data is encrypted in this browser before upload — the server stores an opaque blob and never sees your data or key.",
|
||||
"settings.syncEnable": "Turn on sync",
|
||||
"settings.syncPassphrase": "Sync passphrase",
|
||||
"settings.syncPassphraseConfirm": "Repeat the passphrase",
|
||||
"settings.syncPassphraseMismatch": "The passphrases don't match.",
|
||||
"settings.syncPassphraseShort": "Use at least 8 characters.",
|
||||
"settings.syncStart": "Start syncing",
|
||||
"settings.syncCancel": "Cancel",
|
||||
"settings.syncId": "Sync ID",
|
||||
"settings.syncCopy": "Copy",
|
||||
"settings.syncCopied": "Copied.",
|
||||
"settings.syncLast": "Last synced {when}",
|
||||
"settings.syncNever": "Not synced yet.",
|
||||
"settings.syncNow": "Sync now",
|
||||
"settings.syncWorking": "Syncing…",
|
||||
"settings.syncDone": "Up to date.",
|
||||
"settings.syncPushed": "Uploaded from this device.",
|
||||
"settings.syncPulled": "Downloaded from the synced copy.",
|
||||
"settings.syncConflict": "This device and the synced copy both changed. Choose which one to keep.",
|
||||
"settings.syncKeepLocal": "Keep this device",
|
||||
"settings.syncKeepRemote": "Use synced copy",
|
||||
"settings.syncJoin": "Join another sync",
|
||||
"settings.syncJoinNote":
|
||||
"Enter the sync ID and passphrase from your other device. Data in this browser is replaced by the synced copy.",
|
||||
"settings.syncJoinId": "Sync ID",
|
||||
"settings.syncJoinAction": "Join",
|
||||
"settings.syncLocked": "Enter your sync passphrase to unlock syncing on this device.",
|
||||
"settings.syncUnlock": "Unlock",
|
||||
"settings.syncForget": "Forget passphrase on this device",
|
||||
"settings.syncDelete": "Delete synced data",
|
||||
"settings.syncDeleteConfirm": "Delete the synced copy from the server? This device keeps its data.",
|
||||
"settings.syncDeleteYes": "Delete",
|
||||
"settings.syncWrongPass": "That passphrase can't unlock the synced copy.",
|
||||
"settings.syncError": "Sync failed. Check your connection and try again.",
|
||||
"settings.syncOff": "Sync is off.",
|
||||
"settings.syncOn": "Sync is on.",
|
||||
"settings.syncNoteKey": "Your API key is never synced.",
|
||||
|
||||
/* offline / share / toasts ---------------------------------------- */
|
||||
"offline.banner": "You're offline — saved decks still work.",
|
||||
"offline.generate": "You're offline — connect to generate.",
|
||||
|
|
@ -693,6 +757,13 @@ const en: Record<string, string> = {
|
|||
"server.healthModelNoteLocal": "Not in the daemon's model list. Run `ollama pull {model}` or check your sign-in.",
|
||||
"server.healthModelNoteCloud": "Not returned by {url}/api/tags. Check the model name and your key's plan.",
|
||||
"server.healthModelsMissing": "Ollama is reachable, but at least one configured model is not available.",
|
||||
"server.usageLimit":
|
||||
"Your free monthly Ollama usage has run out. Upgrade your Ollama account, or create a new one and use the new API key.",
|
||||
"server.ollamaThrottled": "Ollama is temporarily rate limiting requests. Try again in a moment.",
|
||||
"server.syncInvalidId": "That sync ID doesn't look right.",
|
||||
"server.syncTooLarge": "This sync upload is too large.",
|
||||
"server.syncStorageFull": "The sync storage is full. Delete some synced data and try again.",
|
||||
"server.syncNotFound": "No synced data found for that ID.",
|
||||
|
||||
/* folders / files -------------------------------------------------- */
|
||||
"folder.nameRequired": "Give the folder a name.",
|
||||
|
|
@ -704,6 +775,13 @@ const en: Record<string, string> = {
|
|||
"file.documentTooLarge": "“{name}” is larger than 40 MB.",
|
||||
"import.notJson": "That file is not valid JSON.",
|
||||
"import.notDeck": "That file doesn't look like a Freezmo deck.",
|
||||
"import.notBackup": "That file doesn't look like a Freezmo backup.",
|
||||
"error.usageTitle": "Free monthly usage used up",
|
||||
"error.usageBody":
|
||||
"You've run out of your free monthly Ollama usage. Upgrade your Ollama account, or create a new one and use the new API key.",
|
||||
"error.openOllama": "Open Ollama",
|
||||
"error.throttledTitle": "Ollama is busy",
|
||||
"error.throttledBody": "Ollama is temporarily rate limiting requests. Try again in a moment.",
|
||||
"doc.readingPage": "Reading page {n} of {total}…",
|
||||
"doc.readingWord": "Reading the Word document…",
|
||||
"doc.readingSlides": "Reading the slides…",
|
||||
|
|
@ -801,6 +879,70 @@ const cs: Record<string, string> = {
|
|||
"settings.haptics": "Haptika",
|
||||
"settings.hapticsNote": "Vibrace na podporovaných telefonech.",
|
||||
|
||||
/* data, backup & sync --------------------------------------------- */
|
||||
"settings.data": "Data a záloha",
|
||||
"settings.dataNote": "Všechno je v tomto prohlížeči. Zálohuj pravidelně.",
|
||||
"settings.exportAll": "Exportovat všechna data",
|
||||
"settings.exportNote": "Sady, úkoly, pokrok a nastavení — nikdy tvůj API klíč.",
|
||||
"settings.importBackup": "Importovat zálohu",
|
||||
"settings.importPreview": "Záloha obsahuje {decks} sad, {homework} výsledků úkolů a {folders} složek.",
|
||||
"settings.importMergeNote": "Sloučení ponechá stávající data a přidá zálohu; stejná ID se nahradí.",
|
||||
"settings.importReplaceNote": "Nahrazení smaže data v tomto prohlížeči a použije zálohu.",
|
||||
"settings.importMerge": "Sloučit",
|
||||
"settings.importReplace": "Nahradit",
|
||||
"settings.importCancel": "Zrušit",
|
||||
"settings.importDone": "Importováno {decks} sad a {homework} výsledků úkolů.",
|
||||
"settings.importFailed": "Zálohu se nepodařilo importovat.",
|
||||
"settings.storage": "Úložiště",
|
||||
"settings.storagePersistent": "Trvalé — prohlížeč tvá data nesmaže.",
|
||||
"settings.storageBestEffort": "Dočasné — prohlížeč může data při nedostatku místa smazat.",
|
||||
"settings.storageRequest": "Požádat o trvalé úložiště",
|
||||
"settings.storageGranted": "Povoleno — data jsou teď trvalá.",
|
||||
"settings.storageDenied": "Prohlížeč odmítl. Pomůže nainstalovat aplikaci.",
|
||||
"settings.backupNudgeTitle": "Zálohovat sady?",
|
||||
"settings.backupNudgeBody": "Od poslední zálohy jsi přidal sady. Záloha je udrží v bezpečí.",
|
||||
"settings.backupNow": "Zálohovat teď",
|
||||
"settings.backupLater": "Teď ne",
|
||||
"settings.sync": "Synchronizace",
|
||||
"settings.syncNote":
|
||||
"Ve výchozím stavu vypnuto. Data se šifrují v tomto prohlížeči před odesláním — server ukládá jen neprůhledný blob a nikdy nevidí tvá data ani klíč.",
|
||||
"settings.syncEnable": "Zapnout synchronizaci",
|
||||
"settings.syncPassphrase": "Přístupová fráze",
|
||||
"settings.syncPassphraseConfirm": "Zopakuj přístupovou frázi",
|
||||
"settings.syncPassphraseMismatch": "Fráze se neshodují.",
|
||||
"settings.syncPassphraseShort": "Použij aspoň 8 znaků.",
|
||||
"settings.syncStart": "Začít synchronizovat",
|
||||
"settings.syncCancel": "Zrušit",
|
||||
"settings.syncId": "Sync ID",
|
||||
"settings.syncCopy": "Kopírovat",
|
||||
"settings.syncCopied": "Zkopírováno.",
|
||||
"settings.syncLast": "Naposledy synchronizováno {when}",
|
||||
"settings.syncNever": "Zatím nesynchronizováno.",
|
||||
"settings.syncNow": "Synchronizovat teď",
|
||||
"settings.syncWorking": "Synchronizuji…",
|
||||
"settings.syncDone": "Vše je aktuální.",
|
||||
"settings.syncPushed": "Nahráno z tohoto zařízení.",
|
||||
"settings.syncPulled": "Staženo ze synchronizované kopie.",
|
||||
"settings.syncConflict": "Toto zařízení i synchronizovaná kopie se změnily. Vyber, kterou ponechat.",
|
||||
"settings.syncKeepLocal": "Ponechat toto zařízení",
|
||||
"settings.syncKeepRemote": "Použít synchronizovanou kopii",
|
||||
"settings.syncJoin": "Připojit k jiné synchronizaci",
|
||||
"settings.syncJoinNote":
|
||||
"Zadej sync ID a přístupovou frázi z druhého zařízení. Data v tomto prohlížeči nahradí synchronizovaná kopie.",
|
||||
"settings.syncJoinId": "Sync ID",
|
||||
"settings.syncJoinAction": "Připojit",
|
||||
"settings.syncLocked": "Zadej přístupovou frázi a odemkni synchronizaci na tomto zařízení.",
|
||||
"settings.syncUnlock": "Odemknout",
|
||||
"settings.syncForget": "Zapomenout frázi na tomto zařízení",
|
||||
"settings.syncDelete": "Smazat synchronizovaná data",
|
||||
"settings.syncDeleteConfirm": "Smazat synchronizovanou kopii ze serveru? Data v tomto zařízení zůstanou.",
|
||||
"settings.syncDeleteYes": "Smazat",
|
||||
"settings.syncWrongPass": "Touhle frází se synchronizovaná kopie odemknout nedá.",
|
||||
"settings.syncError": "Synchronizace selhala. Zkontroluj připojení a zkus to znovu.",
|
||||
"settings.syncOff": "Synchronizace je vypnutá.",
|
||||
"settings.syncOn": "Synchronizace je zapnutá.",
|
||||
"settings.syncNoteKey": "Tvůj API klíč se nikdy nesynchronizuje.",
|
||||
|
||||
/* offline / share / toasts ---------------------------------------- */
|
||||
"offline.banner": "Jsi offline — uložené sady fungují dál.",
|
||||
"offline.generate": "Jsi offline — pro vytvoření se připoj.",
|
||||
|
|
@ -1343,6 +1485,13 @@ const cs: Record<string, string> = {
|
|||
"server.healthModelNoteLocal": "Není v seznamu modelů daemonu. Spusť `ollama pull {model}` nebo zkontroluj přihlášení.",
|
||||
"server.healthModelNoteCloud": "Není v odpovědi {url}/api/tags. Zkontroluj název modelu a tarif klíče.",
|
||||
"server.healthModelsMissing": "Ollama je dostupná, ale aspoň jeden nakonfigurovaný model není k dispozici.",
|
||||
"server.usageLimit":
|
||||
"Vyčerpal se tvůj měsíční limit Ollama zdarma. Upgraduj svůj účet Ollama, nebo si vytvoř nový a použij jeho nový API klíč.",
|
||||
"server.ollamaThrottled": "Ollama dočasně omezuje požadavky. Zkus to za chvíli znovu.",
|
||||
"server.syncInvalidId": "Tenhle sync ID nevypadá správně.",
|
||||
"server.syncTooLarge": "Tahle synchronizace je příliš velká.",
|
||||
"server.syncStorageFull": "Úložiště synchronizace je plné. Smaž nějaká synchronizovaná data a zkus to znovu.",
|
||||
"server.syncNotFound": "Pro tenhle ID nejsou žádná synchronizovaná data.",
|
||||
|
||||
/* folders / files -------------------------------------------------- */
|
||||
"folder.nameRequired": "Dej složce název.",
|
||||
|
|
@ -1354,6 +1503,13 @@ const cs: Record<string, string> = {
|
|||
"file.documentTooLarge": "„{name}“ je větší než 40 MB.",
|
||||
"import.notJson": "Tento soubor není platný JSON.",
|
||||
"import.notDeck": "Tento soubor nevypadá jako sada Freezmo.",
|
||||
"import.notBackup": "Tento soubor nevypadá jako záloha Freezmo.",
|
||||
"error.usageTitle": "Měsíční limit zdarma vyčerpán",
|
||||
"error.usageBody":
|
||||
"Vyčerpal se tvůj měsíční limit Ollama zdarma. Upgraduj svůj účet Ollama, nebo si vytvoř nový a použij jeho nový API klíč.",
|
||||
"error.openOllama": "Otevřít Ollamu",
|
||||
"error.throttledTitle": "Ollama je zaneprázdněná",
|
||||
"error.throttledBody": "Ollama dočasně omezuje požadavky. Zkus to za chvíli znovu.",
|
||||
"doc.readingPage": "Čtu stranu {n} z {total}…",
|
||||
"doc.readingWord": "Čtu dokument Word…",
|
||||
"doc.readingSlides": "Čtu snímky…",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue