Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Show the local backstop on browsers that can't write back

nyblnetaaa5d3885668
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f40bd8ea..a4568037 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,14 @@ pre-1.0.
says what will actually happen before any work is at stake, once per browser,
and the Save button describes the real behaviour.
+ Those browsers also now show that your work *is* being kept safe. Bento has
+ always snapshotted the deck into the browser as you edit and offered it back
+ when you reopen, but on Safari and Firefox nothing ever said so — the only
+ signal was an amber dot that never cleared. It now reports when it last
+ backed up, while still showing the file itself as out of date, because it is.
+ (A password-protected deck is never snapshotted, so it stays quiet rather
+ than promise a safety net it doesn't have.)
+
## [1.0.10] — 2026-07-25
- **Table defaults can follow the deck theme.** A deck may now define table
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index e8d20a23..43617adc 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -1574,6 +1574,7 @@ export class Editor {
private autosaveTimer = 0
private lastVersionAt = 0
+ private lastBackupAt = 0
private wireAutosave() {
if (this.store.doc.readonly) return // player file — nothing to autosave
@@ -1594,8 +1595,10 @@ export class Editor {
if (doc.readonly) return
// Never write an encrypted deck's plaintext to IndexedDB; its file
// write-back below stays encrypted via serializeAuto.
+ let snapshotted = false
if (!isEncryptionActive()) {
await putRecovery(doc)
+ snapshotted = true
if (Date.now() - this.lastVersionAt > 120_000) { this.lastVersionAt = Date.now(); await addVersion(doc) }
}
// Silent file write-back once we hold a writable handle (Chrome/Edge).
@@ -1605,8 +1608,32 @@ export class Editor {
await writeUpdatedFile(await serializeAuto(doc))
this.store.setDirty(false)
this.flashSaved()
+ return
} catch { /* keep dirty; the IndexedDB snapshot is the backstop */ }
}
+ // No handle (Safari/Firefox/iOS) or the write failed: the file on disk is
+ // STALE and the deck stays dirty — saying "Saved" here would be a lie. But
+ // the snapshot means the work is not lost, and that was previously
+ // invisible: nothing was shown at all, so the only signal was an amber dot
+ // that never cleared. Say what is actually true.
+ //
+ // Deliberately silent for an ENCRYPTED deck: those are never snapshotted to
+ // IndexedDB (plaintext-to-disk), so on a browser that cannot write back
+ // there is no backstop, and claiming one would be the worst kind of wrong.
+ if (snapshotted) {
+ this.lastBackupAt = Date.now()
+ this.flashSaved(t('Backed up in this browser'))
+ this.refreshDirtyHint()
+ }
+ }
+
+ /** Keep the dirty dot's tooltip honest about the backstop — the file is still
+ * stale, but the work is recoverable, and the user should be able to find
+ * that out by hovering the thing that is worrying them. */
+ private refreshDirtyHint() {
+ if (canWriteInPlace() || !this.lastBackupAt) return
+ const when = new Date(this.lastBackupAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
+ this.dirtyDot.title = t('Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.', { when })
}
private async checkRecovery() {
@@ -1802,10 +1829,10 @@ export class Editor {
}
private savedTimer = 0
- private flashSaved() {
+ private flashSaved(message = t('Saved')) {
let tag = document.querySelector<HTMLElement>('.ed-autosaved')
if (!tag) { tag = div('ed-autosaved'); document.querySelector('.ed-topbar .ed-title')?.after(tag) }
- tag.textContent = t('Saved')
+ tag.textContent = message
tag.classList.add('show')
clearTimeout(this.savedTimer)
this.savedTimer = window.setTimeout(() => tag!.classList.remove('show'), 1400)
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index 518f3625..52d80a33 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const de: Catalog = {
+ "Backed up in this browser": "In diesem Browser gesichert",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "Nicht gespeicherte Änderungen — um {when} in diesem Browser gesichert und beim erneuten Öffnen angeboten. ⌘S lädt eine aktualisierte Kopie herunter.",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "Nicht gespeicherte Änderungen — ⌘S lädt eine aktualisierte Kopie herunter (dieser Browser kann die Datei nicht überschreiben)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "Speichern — aktualisierte Kopie herunterladen (⌘S). Dieser Browser kann die geöffnete Datei nicht überschreiben.",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "Dieser Browser kann Dateien nicht direkt überschreiben. ⌘S lädt stattdessen eine aktualisierte Kopie herunter — deine Arbeit wird außerdem in diesem Browser gespeichert und beim erneuten Öffnen angeboten.",
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index bffb191c..26d5e832 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const es: Catalog = {
+ "Backed up in this browser": "Copia guardada en este navegador",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "Cambios sin guardar — conservados en este navegador a las {when} y se te ofrecerán al reabrir. ⌘S descarga una copia actualizada.",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "Cambios sin guardar — ⌘S descarga una copia actualizada (este navegador no puede reescribir el archivo)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "Guardar — descargar una copia actualizada (⌘S). Este navegador no puede reescribir el archivo abierto.",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "Este navegador no puede reescribir archivos en su sitio. ⌘S descargará una copia actualizada — tu trabajo también se guarda en este navegador y se te ofrecerá si vuelves a abrirlo.",
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 2b4f90f8..efd42050 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const fr: Catalog = {
+ "Backed up in this browser": "Sauvegardé dans ce navigateur",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "Modifications non enregistrées — conservées dans ce navigateur à {when} et proposées à la réouverture. ⌘S télécharge une copie à jour.",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "Modifications non enregistrées — ⌘S télécharge une copie à jour (ce navigateur ne peut pas réécrire le fichier)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "Enregistrer — télécharger une copie à jour (⌘S). Ce navigateur ne peut pas réécrire le fichier ouvert.",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "Ce navigateur ne peut pas réécrire les fichiers sur place. ⌘S téléchargera plutôt une copie à jour — votre travail est aussi conservé dans ce navigateur et vous sera proposé si vous rouvrez le fichier.",
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index 471108d5..2d845223 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const it: Catalog = {
+ "Backed up in this browser": "Salvato in questo browser",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "Modifiche non salvate — conservate in questo browser alle {when} e riproposte alla riapertura. ⌘S scarica una copia aggiornata.",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "Modifiche non salvate — ⌘S scarica una copia aggiornata (questo browser non può riscrivere il file)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "Salva — scarica una copia aggiornata (⌘S). Questo browser non può riscrivere il file aperto.",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "Questo browser non può riscrivere i file sul posto. ⌘S scaricherà invece una copia aggiornata — il tuo lavoro viene conservato anche in questo browser e ti verrà riproposto alla riapertura.",
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index 746671b3..a647ba89 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const ja: Catalog = {
+ "Backed up in this browser": "このブラウザに保存しました",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "未保存の変更 — {when} にこのブラウザへ保存済みで、再度開いたときに復元できます。⌘S は更新されたコピーをダウンロードします。",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "未保存の変更 — ⌘S は更新されたコピーをダウンロードします(このブラウザはファイルを上書きできません)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "保存 — 更新されたコピーをダウンロード(⌘S)。このブラウザは開いているファイルを上書きできません。",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "このブラウザはファイルを直接上書きできません。⌘S は代わりに更新されたコピーをダウンロードします。作業内容はこのブラウザにも保存され、再度開いたときに復元できます。",
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 04b6c0ec..d5bf21cb 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const zhHans: Catalog = {
+ "Backed up in this browser": "已备份到此浏览器",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "未保存的更改 — 已于 {when} 保存在此浏览器中,重新打开时可以恢复。⌘S 将下载更新后的副本。",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "未保存的更改 — ⌘S 将下载更新后的副本(此浏览器无法改写文件)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "保存 — 下载更新后的副本(⌘S)。此浏览器无法改写已打开的文件。",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "此浏览器无法就地改写文件。⌘S 将改为下载更新后的副本 — 你的工作也会保存在此浏览器中,重新打开时可以恢复。",
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index 643acc24..e3e4053e 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -4,6 +4,8 @@
import type { Catalog } from '../i18n'
export const zhHant: Catalog = {
+ "Backed up in this browser": "已備份到此瀏覽器",
+ "Unsaved changes — kept in this browser at {when} and offered back if you reopen. ⌘S downloads an updated copy.": "未儲存的變更 — 已於 {when} 保存在此瀏覽器中,重新開啟時可以還原。⌘S 會下載更新後的副本。",
"Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)": "未儲存的變更 — ⌘S 會下載更新後的副本(此瀏覽器無法改寫檔案)",
"Save — download an updated copy (⌘S). This browser can’t rewrite the open file.": "儲存 — 下載更新後的副本(⌘S)。此瀏覽器無法改寫已開啟的檔案。",
"This browser can’t rewrite files in place. ⌘S will download an updated copy instead — your work is also kept in this browser and offered back if you reopen.": "此瀏覽器無法就地改寫檔案。⌘S 會改為下載更新後的副本 — 你的工作也會保存在此瀏覽器中,重新開啟時可以還原。",