Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Say what saving actually does on browsers without File System Access

nyblnet4901a9bda214
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae9653d2..f40bd8ea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,13 @@ pre-1.0.
## [Unreleased]
+- **Safari and Firefox are told the truth about saving.** Those browsers (and
+ every browser on iPhone and iPad) can't rewrite a file in place — Bento hands
+ back an updated copy instead. The editor used to say the opposite in its
+ tooltips and only admit it in a passing message *after* the first save. It now
+ says what will actually happen before any work is at stake, once per browser,
+ and the Save button describes the real behaviour.
+
## [1.0.10] — 2026-07-25
- **Table defaults can follow the deck theme.** A deck may now define table
diff --git a/kernel/src/save.ts b/kernel/src/save.ts
index 56842d59..d4f8d57e 100644
--- a/kernel/src/save.ts
+++ b/kernel/src/save.ts
@@ -195,6 +195,21 @@ let fileHandle: FsFileHandle | null = null
const hasFsAccess = () => typeof (window as any).showSaveFilePicker === 'function'
+/**
+ * Can this browser rewrite the open file, or only hand back copies?
+ *
+ * The File System Access API is Chrome/Edge only: Safari and Firefox lack it,
+ * and so does EVERY browser on iOS, because they are all WebKit underneath.
+ * Without it there is no writable handle, which costs three things — in-place
+ * save, silent autosave write-back, and in-place self-update.
+ *
+ * Exported because the UI must not promise what the browser cannot do. "⌘S
+ * rewrites this file in place" is the product's central claim and it is simply
+ * false here; saying it anyway and retracting it in a toast after the first
+ * save is worse than saying the true thing up front.
+ */
+export const canWriteInPlace = () => hasFsAccess()
+
async function pickHandle(doc: KernelDoc, suffix = ''): Promise<FsFileHandle | null> {
try {
return await (window as any).showSaveFilePicker({
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 42c4d417..e8d20a23 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -17,7 +17,7 @@ import { renderSlide, renderThumbnail } from '../render'
import { SlideCanvas } from './canvas'
import { PropsPanel } from './panels'
import { startPresentation } from '../present'
-import { hasFileHandle, isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'
+import { canWriteInPlace, hasFileHandle, isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'
import { addVersion, clearRecovery, clearVersions, docContentKey, getRecovery, listVersions, pruneOld, putRecovery, type Snapshot } from '../autosave'
import { insertElements, insertSlides, parseClip, serializeElements, serializeSlides } from './clipboard'
import { openSpeakerWindow, speakerIdleBody } from '../screens'
@@ -29,6 +29,10 @@ import { disconnectOnline, joinFromDoc, mintCollab, mintInvite, onlineTransport,
const i18nT = t
+/** Per-BROWSER, not per-deck: whether the "this browser can't rewrite files"
+ * notice has been acknowledged. It is a property of the browser. */
+const SAVE_NOTICE_KEY = 'bento-save-notice'
+
const SHAPE_MENU: Array<{ kind: ShapeKind; label: string; icon: string; draw?: 'line' | 'path' | 'connector' | 'free' | 'poly'; tip: string }> = [
{ kind: 'rect', label: 'Rectangle', icon: ICONS.rect, tip: 'A rectangle — rounded corners, fills, gradients and shadows in the panel' },
{ kind: 'ellipse', label: 'Ellipse', icon: ICONS.ellipse, tip: 'An ellipse or circle' },
@@ -221,7 +225,13 @@ export class Editor {
}
})
this.dirtyDot = div('ed-dirty')
- this.dirtyDot.title = t('Unsaved changes — ⌘S saves this file in place')
+ // Capability-aware: on Safari/Firefox (and every iOS browser) there is no
+ // File System Access API, so ⌘S CANNOT rewrite this file — it hands back a
+ // copy. Promising in-place saving and retracting it in a toast after the
+ // first save is worse than saying the true thing before any work is lost.
+ this.dirtyDot.title = canWriteInPlace()
+ ? t('Unsaved changes — ⌘S saves this file in place')
+ : t('Unsaved changes — ⌘S downloads an updated copy (this browser can’t rewrite the file)')
const insert = div('ed-group ed-insert')
insert.append(
@@ -262,7 +272,9 @@ export class Editor {
}, 1500)
const undoB = btn(ICONS.undo, '', () => this.store.undo(), t('Undo (⌘Z)'))
const redoB = btn(ICONS.redo, '', () => this.store.redo(), t('Redo (⇧⌘Z)'))
- const saveB = btn(ICONS.save, t('Save'), () => this.save(false), t('Save — rewrite this file in place (⌘S)'))
+ const saveB = btn(ICONS.save, t('Save'), () => this.save(false), canWriteInPlace()
+ ? t('Save — rewrite this file in place (⌘S)')
+ : t('Save — download an updated copy (⌘S). This browser can’t rewrite the open file.'))
saveB.appendChild(this.dirtyDot) // the amber unsaved-changes dot lives ON Save
const pdfB = btn(ICONS.pdf, '', () => this.exportPdf(), t('Export PDF (print)'))
const helpB = btn('<b class="ed-help-q">?</b>', '', () => this.openHelp(), t('Shortcuts & tips (?)'))
@@ -1567,6 +1579,7 @@ export class Editor {
if (this.store.doc.readonly) return // player file — nothing to autosave
void pruneOld()
void this.checkRecovery()
+ this.noticeIfCannotWriteInPlace()
this.store.on('doc', () => this.scheduleAutosave())
}
@@ -1606,6 +1619,33 @@ export class Editor {
this.showRecoveryBanner(snap, recovered)
}
+ /**
+ * Say ONCE, before any work is at risk, that this browser cannot rewrite the
+ * open file. Shown on Safari/Firefox and every iOS browser (all WebKit, none
+ * of which ship the File System Access API).
+ *
+ * Timing is the point. The editor used to state the opposite in its tooltips
+ * and only correct itself in a toast AFTER the first save — by which time the
+ * author had already trusted "⌘S rewrites this file" and, on a deck opened
+ * from disk, had no idea their edits were going to Downloads instead.
+ *
+ * Once per browser, not per deck: it is a property of the browser, and
+ * repeating it every time a file opens would be nagging.
+ */
+ private noticeIfCannotWriteInPlace() {
+ if (canWriteInPlace()) return
+ if (localStorage.getItem(SAVE_NOTICE_KEY) === 'seen') return
+ const bar = div('ed-recover')
+ const msg = document.createElement('span')
+ msg.textContent = t('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.')
+ const ok = document.createElement('button')
+ ok.className = 'ed-btn ed-btn-primary'
+ ok.textContent = t('Got it')
+ ok.addEventListener('click', () => { localStorage.setItem(SAVE_NOTICE_KEY, 'seen'); bar.remove() })
+ bar.append(msg, ok)
+ document.body.appendChild(bar)
+ }
+
private showRecoveryBanner(snap: Snapshot, recovered: import('../model').BentoDoc) {
document.querySelector('.ed-recover')?.remove()
const bar = div('ed-recover')
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index d1a6d034..518f3625 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const de: Catalog = {
+ "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.",
+ "Got it": "Verstanden",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Dieses Bild ist zu groß für die Live-Freigabe (max. etwa 1 MB). Es ist in deiner Kopie gespeichert, aber Mitarbeitende sehen es nicht.",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Diese Änderung ist zu groß für die Live-Freigabe (max. etwa 1 MB). Sie ist in deiner Kopie gespeichert, aber Mitarbeitende sehen sie nicht.",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "Diese Live-Sitzung hat keinen Platz mehr. Deine Änderung ist in deiner Kopie gespeichert, aber Mitarbeitende sehen sie nicht.",
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index 09848bbb..bffb191c 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const es: Catalog = {
+ "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.",
+ "Got it": "Entendido",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Esa imagen es demasiado grande para compartirla en vivo (máx. 1 MB aprox.). Se guarda en tu copia, pero los colaboradores no la verán.",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Ese cambio es demasiado grande para compartirlo en vivo (máx. 1 MB aprox.). Se guarda en tu copia, pero los colaboradores no lo verán.",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "Esta sesión en vivo se ha quedado sin espacio. Tu cambio se guarda en tu copia, pero los colaboradores no lo verán.",
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 1a4e4bf2..2b4f90f8 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const fr: Catalog = {
+ "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.",
+ "Got it": "Compris",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Cette image est trop volumineuse pour le partage en direct (environ 1 Mo max). Elle est enregistrée dans votre copie, mais les collaborateurs ne la verront pas.",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Cette modification est trop volumineuse pour le partage en direct (environ 1 Mo max). Elle est enregistrée dans votre copie, mais les collaborateurs ne la verront pas.",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "Cette session en direct n’a plus de place. Votre modification est enregistrée dans votre copie, mais les collaborateurs ne la verront pas.",
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index 279bdf58..471108d5 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const it: Catalog = {
+ "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.",
+ "Got it": "Ho capito",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Questa immagine è troppo grande per la condivisione dal vivo (circa 1 MB max). È salvata nella tua copia, ma i collaboratori non la vedranno.",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "Questa modifica è troppo grande per la condivisione dal vivo (circa 1 MB max). È salvata nella tua copia, ma i collaboratori non la vedranno.",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "Questa sessione dal vivo ha esaurito lo spazio. La tua modifica è salvata nella tua copia, ma i collaboratori non la vedranno.",
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index 983c1f19..746671b3 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const ja: Catalog = {
+ "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 は代わりに更新されたコピーをダウンロードします。作業内容はこのブラウザにも保存され、再度開いたときに復元できます。",
+ "Got it": "了解",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "この画像はライブ共有には大きすぎます(上限は約 1 MB)。自分のコピーには保存されますが、共同編集者には表示されません。",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "この変更はライブ共有には大きすぎます(上限は約 1 MB)。自分のコピーには保存されますが、共同編集者には表示されません。",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "このライブセッションの容量がいっぱいです。変更は自分のコピーに保存されますが、共同編集者には表示されません。",
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 9a4b9eb8..04b6c0ec 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const zhHans: Catalog = {
+ "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 将改为下载更新后的副本 — 你的工作也会保存在此浏览器中,重新打开时可以恢复。",
+ "Got it": "知道了",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "该图片过大,无法实时共享(上限约 1 MB)。它已保存在你的副本中,但协作者不会看到。",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "该更改过大,无法实时共享(上限约 1 MB)。它已保存在你的副本中,但协作者不会看到。",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "此实时会话空间已满。你的更改已保存在你的副本中,但协作者不会看到。",
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index 66652acf..643acc24 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -4,6 +4,10 @@
import type { Catalog } from '../i18n'
export const zhHant: Catalog = {
+ "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 會改為下載更新後的副本 — 你的工作也會保存在此瀏覽器中,重新開啟時可以還原。",
+ "Got it": "知道了",
"That image is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "此圖片太大,無法即時共用(上限約 1 MB)。它已儲存在你的副本中,但協作者不會看到。",
"That change is too large to share live (about 1 MB max). It’s saved in your copy, but collaborators won’t see it.": "此變更太大,無法即時共用(上限約 1 MB)。它已儲存在你的副本中,但協作者不會看到。",
"This live session has run out of room. Your change is saved in your copy, but collaborators won’t see it.": "此即時工作階段空間已滿。你的變更已儲存在你的副本中,但協作者不會看到。",