Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
spaces: a space remembers more than the last few seconds (#357)
nyblnet5cd2964359a0
diff --git a/scripts/test-spaces-model.ts b/scripts/test-spaces-model.tsindex 178ecdee..fee7e97c 100644--- a/scripts/test-spaces-model.ts+++ b/scripts/test-spaces-model.ts@@ -337,6 +337,24 @@ for (const [label, input, err] of [// and turning encryption ON must remove what was written before itok(/clearVersions\(/.test(about) && /clearRecovery\(/.test(about),'setting a password clears BOTH the version timeline and the recovery snapshot')++ // THE TIMELINE HAS THE SAME OBLIGATION, and it is easier to get wrong: the+ // recovery guard is an early `return` at the top of the debounce, so anything+ // written further down inherits it — but the SAVE path is a second call site+ // with no such shelter, and that one runs at the exact moment an author who+ // has set a password is writing the file. Both guarded, or the timeline is a+ // plaintext copy of what the encryption was for.+ ok(/addVersion\(/.test(main), 'main.ts writes a version timeline at all')+ const throttled = /Date\.now\(\) - lastVersionAt > VERSION_EVERY_MS[\s\S]{0,120}?addVersion/.test(main)+ ok(throttled, '…on a throttle while editing, so one session cannot spend the cap')+ const saveGuarded = /if \(!isEncryptionActive\(\)\) \{ void addVersion/.test(main)+ ok(saveGuarded, '…and the SAVE path checks encryption itself, having no early return above it')++ // The restore has to go through replaceDoc: it is the one path that+ // checkpoints undo first, which is what makes the note "Restoring is+ // undoable" true rather than reassuring.+ ok(/listVersions\(/.test(about), 'About reads the timeline')+ ok(/store\.replaceDoc\(restored\)/.test(about), '…and restores through replaceDoc, so ⌘Z walks it back')}// ---- find & replace: the number shown IS the number changed ----------------diff --git a/spaces/src/about.ts b/spaces/src/about.tsindex 2a14a002..1485adae 100644--- a/spaces/src/about.ts+++ b/spaces/src/about.ts@@ -35,7 +35,7 @@ import {setEncryptionPassword, isEncryptionActive,canWriteInPlace, openedFileName,} from '../../kernel/src/save.ts'-import { clearVersions, clearRecovery } from '../../kernel/src/autosave.ts'+import { clearVersions, clearRecovery, listVersions, type Snapshot } from '../../kernel/src/autosave.ts'import { t, localeChoices, locale, setLocale } from './i18n'import { appearanceSection } from './appearance'import { esc, textOf } from './sanitize'@@ -520,6 +520,67 @@ export function openAbout(hooks: AboutHooks): void {}// ---- ways out ----------------------------------------------------------+ // ---- the local timeline --------------------------------------------------+ //+ // Undo dies with the tab and the recovery snapshot only ever holds the last+ // few seconds, so before this section the honest answer to "give me back what+ // I wrote this morning" was that there wasn't one. The timeline lives in this+ // browser's IndexedDB — never in the file, never online — which is why the+ // note says so plainly: a space carried to another machine does not bring its+ // history, and that is a property worth stating rather than discovering.+ //+ // Rendered ASYNC into a placeholder. Reading IndexedDB cannot be allowed to+ // hold up the dialog opening, and a space with no versions yet is the common+ // case on a first run — it says so rather than showing an empty box.+ const histSec = section(t('History'))+ const histBody = document.createElement('div')+ histBody.className = 'sp-ab-versions'+ histSec.append(histBody)+ histSec.append(note(t('Versions are kept in this browser only — never in the file, never online. Restoring is undoable.')))++ const renderVersions = (versions: Snapshot[]): void => {+ histBody.textContent = ''+ if (!versions.length) {+ histBody.append(note(isEncryptionActive()+ ? t('This space is encrypted, so no versions are kept.')+ : t('No versions yet — they build up as you write and save.')))+ return+ }+ for (const [i, v] of versions.entries()) {+ const when = new Date(v.at).toLocaleString([], {+ month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit',+ })+ const b = document.createElement('button')+ b.type = 'button'+ b.className = 'sp-ab-version'+ const left = document.createElement('span')+ left.className = 'sp-ab-when'+ left.textContent = when+ const tag = document.createElement('span')+ tag.className = 'sp-ab-vtag'+ tag.textContent = i === 0 ? t('most recent') : ''+ const doIt = document.createElement('span')+ doIt.className = 'sp-ab-vdo'+ doIt.textContent = t('Restore')+ b.append(left, tag, doIt)+ b.addEventListener('click', () => {+ let restored: SpacesDoc+ try { restored = JSON.parse(v.json) as SpacesDoc } catch {+ say(t('That version could not be read')); return+ }+ // replaceDoc checkpoints undo first, so ⌘Z walks this back — the same+ // contract the recovery banner's Restore already honours.+ store.replaceDoc(restored)+ onRepaint()+ close()+ say(t('Restored the version from {when} — ⌘Z undoes it', { when }))+ })+ histBody.append(b)+ }+ }+ renderVersions([])+ void listVersions(doc.docId).then(renderVersions).catch(() => { /* no store, no history */ })+const outSec = section(t('Take it elsewhere'))const copyJson = button(t('Copy document JSON'), () => {// The clipboard copy is a HAND-OUT. Every field under `collab` is a bearerdiff --git a/spaces/src/i18n/de.ts b/spaces/src/i18n/de.tsindex d33a16a7..c759fe81 100644--- a/spaces/src/i18n/de.ts+++ b/spaces/src/i18n/de.ts@@ -556,4 +556,11 @@ export const de: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{pages} Seite(n) und {blocks} Block/Blöcke aus {files} Datei(en) hinzugefügt.","{pages} page(s) and {blocks} block(s) will travel.": "{pages} Seite(n) und {blocks} Block/Blöcke kommen mit.","⌘Z removes the imported pages again.": "Mit ⌘Z verschwinden die importierten Seiten wieder.",+ "History": "Verlauf",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "Versionen liegen nur in diesem Browser — nie in der Datei, nie online. Das Wiederherstellen lässt sich rückgängig machen.",+ "This space is encrypted, so no versions are kept.": "Dieser Space ist verschlüsselt, deshalb werden keine Versionen aufbewahrt.",+ "No versions yet — they build up as you write and save.": "Noch keine Versionen — sie sammeln sich beim Schreiben und Speichern an.",+ "most recent": "neueste",+ "That version could not be read": "Diese Version konnte nicht gelesen werden",+ "Restored the version from {when} — ⌘Z undoes it": "Version vom {when} wiederhergestellt — ⌘Z macht das rückgängig.",}diff --git a/spaces/src/i18n/es.ts b/spaces/src/i18n/es.tsindex c542b019..ff6724c4 100644--- a/spaces/src/i18n/es.ts+++ b/spaces/src/i18n/es.ts@@ -556,4 +556,11 @@ export const es: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{pages} página(s) y {blocks} bloque(s) añadidos desde {files} archivo(s).","{pages} page(s) and {blocks} block(s) will travel.": "Viajarán {pages} página(s) y {blocks} bloque(s).","⌘Z removes the imported pages again.": "⌘Z vuelve a quitar las páginas importadas.",+ "History": "Historial",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "Las versiones se guardan solo en este navegador: nunca en el archivo ni en línea. Restaurar se puede deshacer.",+ "This space is encrypted, so no versions are kept.": "Este espacio está cifrado, así que no se guarda ninguna versión.",+ "No versions yet — they build up as you write and save.": "Aún no hay versiones: se acumulan a medida que escribes y guardas.",+ "most recent": "más reciente",+ "That version could not be read": "No se pudo leer esa versión",+ "Restored the version from {when} — ⌘Z undoes it": "Se restauró la versión del {when}: ⌘Z lo deshace.",}diff --git a/spaces/src/i18n/fr.ts b/spaces/src/i18n/fr.tsindex 8bebbba2..014da0dd 100644--- a/spaces/src/i18n/fr.ts+++ b/spaces/src/i18n/fr.ts@@ -556,4 +556,11 @@ export const fr: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{pages} page(s) et {blocks} bloc(s) ajoutés depuis {files} fichier(s).","{pages} page(s) and {blocks} block(s) will travel.": "{pages} page(s) et {blocks} bloc(s) feront le voyage.","⌘Z removes the imported pages again.": "⌘Z supprime à nouveau les pages importées.",+ "History": "Historique",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "Les versions sont conservées uniquement dans ce navigateur — jamais dans le fichier, jamais en ligne. La restauration est annulable.",+ "This space is encrypted, so no versions are kept.": "Cet espace est chiffré : aucune version n’est conservée.",+ "No versions yet — they build up as you write and save.": "Pas encore de versions — elles s’accumulent à mesure que vous écrivez et enregistrez.",+ "most recent": "la plus récente",+ "That version could not be read": "Cette version n’a pas pu être lue",+ "Restored the version from {when} — ⌘Z undoes it": "Version du {when} restaurée — ⌘Z annule.",}diff --git a/spaces/src/i18n/it.ts b/spaces/src/i18n/it.tsindex e03c3aa3..5aa9316b 100644--- a/spaces/src/i18n/it.ts+++ b/spaces/src/i18n/it.ts@@ -556,4 +556,11 @@ export const it: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{pages} pagine e {blocks} blocchi aggiunti da {files} file.","{pages} page(s) and {blocks} block(s) will travel.": "Viaggeranno {pages} pagina/e e {blocks} blocco/blocchi.","⌘Z removes the imported pages again.": "⌘Z rimuove di nuovo le pagine importate.",+ "History": "Cronologia",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "Le versioni restano solo in questo browser: mai nel file, mai online. Il ripristino si può annullare.",+ "This space is encrypted, so no versions are kept.": "Questo spazio è cifrato, quindi non viene conservata alcuna versione.",+ "No versions yet — they build up as you write and save.": "Ancora nessuna versione: si accumulano mentre scrivi e salvi.",+ "most recent": "più recente",+ "That version could not be read": "Non è stato possibile leggere quella versione",+ "Restored the version from {when} — ⌘Z undoes it": "Ripristinata la versione del {when} — ⌘Z annulla.",}diff --git a/spaces/src/i18n/ja.ts b/spaces/src/i18n/ja.tsindex 7037eb8a..09084455 100644--- a/spaces/src/i18n/ja.ts+++ b/spaces/src/i18n/ja.ts@@ -556,4 +556,11 @@ export const ja: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{files} 個のファイルから {pages} ページ・{blocks} ブロックを追加しました。","{pages} page(s) and {blocks} block(s) will travel.": "{pages} ページ、{blocks} ブロックが移動します。","⌘Z removes the imported pages again.": "⌘Z で、読み込んだページを取り消せます。",+ "History": "履歴",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "バージョンはこのブラウザーにのみ保存されます。ファイルにもオンラインにも残りません。復元は取り消せます。",+ "This space is encrypted, so no versions are kept.": "このスペースは暗号化されているため、バージョンは保存されません。",+ "No versions yet — they build up as you write and save.": "まだバージョンはありません。書いて保存するたびに増えていきます。",+ "most recent": "最新",+ "That version could not be read": "そのバージョンを読み込めませんでした",+ "Restored the version from {when} — ⌘Z undoes it": "{when} のバージョンを復元しました。⌘Z で取り消せます。",}diff --git a/spaces/src/i18n/packed.ts b/spaces/src/i18n/packed.tsindex 16dc818b..fd47a8ea 100644--- a/spaces/src/i18n/packed.ts+++ b/spaces/src/i18n/packed.ts@@ -184,6 +184,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"Hide the page list ([)": ["ページ一覧を隠す([)","隐藏页面列表([)","隱藏頁面清單([)","Ocultar la lista de páginas ([)","Masquer la liste des pages ([)","Seitenliste ausblenden ([)","Nascondi l'elenco delle pagine ([)","Ocultar a lista de páginas ([)"],"Highlight": ["ハイライト","高亮","螢光標示","Resaltado","Surlignage","Hervorhebung","Evidenziazione","Destaque"],"Highlight — ⇧⌘H": ["ハイライト — ⇧⌘H","高亮 — ⇧⌘H","螢光標示 — ⇧⌘H","Resaltado — ⇧⌘H","Surlignage — ⇧⌘H","Hervorhebung — ⇧⌘H","Evidenziazione — ⇧⌘H","Destaque — ⇧⌘H"],+ "History": ["履歴","历史记录","歷史記錄","Historial","Historique","Verlauf","Cronologia","Histórico"],"Icon": ["アイコン","图标","圖示","Icono","Icône","Symbol","Icona","Ícone"],"Image": ["画像","图片","影像","Imagen","Image","Bild","Immagine","Imagem"],"Image added ({size})": ["画像を追加しました({size})","已添加图片 ({size})","已新增圖片 ({size})","Imagen añadida ({size})","Image ajoutée ({size})","Bild hinzugefügt ({size})","Immagine aggiunta ({size})","Imagem adicionada ({size})"],@@ -256,6 +257,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"No issues match this filter.": ["この条件に一致するイシューはありません。","没有符合此筛选条件的事项。","沒有符合此篩選條件的項目。","Ninguna incidencia coincide con este filtro.","Aucun ticket ne correspond à ce filtre.","Keine Issues entsprechen diesem Filter.","Nessuna issue corrisponde a questo filtro.","Nenhuma tarefa corresponde a este filtro."],"No issues yet. Add a status field to any page and it appears here.": ["まだイシューはありません。どれかのページにステータス項目を追加すると、ここに表示されます。","还没有事项。给任意页面添加状态字段,它就会出现在这里。","還沒有項目。為任一頁面新增狀態欄位,它就會出現在這裡。","Aún no hay incidencias. Añade un campo de estado a cualquier página y aparecerá aquí.","Aucun ticket pour l’instant. Ajoutez un champ statut à une page et elle apparaîtra ici.","Noch keine Issues. Gib einer Seite ein Status-Feld, dann erscheint sie hier.","Ancora nessuna issue. Aggiungi un campo stato a una pagina e comparirà qui.","Ainda não há tarefas. Adiciona um campo de estado a qualquer página e ela aparece aqui."],"No pages yet": ["ページがまだありません","还没有页面","尚無頁面","Aún no hay páginas","Aucune page pour l’instant","Noch keine Seiten","Ancora nessuna pagina","Ainda sem páginas"],+ "No versions yet — they build up as you write and save.": ["まだバージョンはありません。書いて保存するたびに増えていきます。","暂无版本。随着你的书写和保存,版本会逐渐累积。","尚無版本。隨著你的書寫與儲存,版本會逐漸累積。","Aún no hay versiones: se acumulan a medida que escribes y guardas.","Pas encore de versions — elles s’accumulent à mesure que vous écrivez et enregistrez.","Noch keine Versionen — sie sammeln sich beim Schreiben und Speichern an.","Ancora nessuna versione: si accumulano mentre scrivi e salvi.","Ainda sem versões — vão-se acumulando à medida que escreves e guardas."],"Not in this file: it needs the network, and the site is told when someone opens the page": ["このファイルの中にはありません。再生にはネットワークが必要で、誰かがこのページを開いたことがそのサイトに伝わります","不在此文件内:播放需要联网,而且该网站会知道有人打开了这个页面","不在這個檔案裡:播放需要網路,而且該網站會知道有人開啟了這個頁面","No está en este archivo: necesita la red, y ese sitio sabrá que alguien ha abierto esta página","N’est pas dans ce fichier : la lecture nécessite le réseau, et ce site saura que quelqu’un a ouvert cette page","Nicht in dieser Datei: das Abspielen braucht das Netz, und die Website erfährt, dass jemand diese Seite geöffnet hat","Non è dentro questo file: per riprodurla serve la rete, e quel sito saprà che qualcuno ha aperto questa pagina","Não está neste ficheiro: precisa da rede, e esse site fica a saber que alguém abriu esta página"],"Not live — turns on when you share": ["未接続 — 共有すると自動的にライブになります","未上线 — 分享时自动开启","未上線 — 分享時自動開啟","Sin conexión — se activa al compartir","Hors ligne — s’active quand vous partagez","Nicht live — startet beim Teilen","Non live — si attiva quando condividi","Fora do ar — ativa quando você compartilha"],"Not loaded — opening it would tell that site you opened this space.": ["未読み込み — 読み込むと、このスペースを開いたことがそのサイトに伝わります。","未加载 — 加载会让该网站知道你打开了这个空间。","未載入 — 載入會讓該網站知道你開啟了這個空間。","No cargada: al cargarla, ese sitio sabría que has abierto este espacio.","Non chargée : la charger indiquerait à ce site que vous avez ouvert cet espace.","Nicht geladen — beim Laden erfährt diese Website, dass du diesen Space geöffnet hast.","Non caricata: caricarla direbbe a quel sito che hai aperto questo spazio.","Não carregada — carregá-la diria a esse site que você abriu este espaço."],@@ -350,6 +352,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"Resolve": ["解決","解决","解決","Resolver","Résoudre","Erledigen","Risolvi","Resolver"],"Restore": ["復元","恢复","還原","Restaurar","Restaurer","Wiederherstellen","Ripristina","Restaurar"],"Restore to the page list": ["ページ一覧に戻す","恢复到页面列表","還原到頁面清單","Restaurar a la lista de páginas","Restaurer dans la liste des pages","Zurück in die Seitenliste","Ripristina nell’elenco delle pagine","Restaurar para a lista de páginas"],+ "Restored the version from {when} — ⌘Z undoes it": ["{when} のバージョンを復元しました。⌘Z で取り消せます。","已恢复 {when} 的版本,按 ⌘Z 可撤销。","已還原 {when} 的版本,按 ⌘Z 可復原。","Se restauró la versión del {when}: ⌘Z lo deshace.","Version du {when} restaurée — ⌘Z annule.","Version vom {when} wiederhergestellt — ⌘Z macht das rückgängig.","Ripristinata la versione del {when} — ⌘Z annulla.","Versão de {when} restaurada — ⌘Z desfaz."],"Room for a board or a table": ["ボードや表にちょうどよい幅","给看板或表格留出空间","給看板或表格留出空間","Espacio para un tablero o una tabla","De la place pour un tableau","Platz für ein Board oder eine Tabelle","Spazio per una bacheca o una tabella","Espaço para um quadro ou uma tabela"],"Rows": ["行","行","列","Filas","Lignes","Zeilen","Righe","Linhas"],"Rows and columns": ["行と列","行和列","列與欄","Filas y columnas","Lignes et colonnes","Zeilen und Spalten","Righe e colonne","Linhas e colunas"],@@ -398,6 +401,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"That is {n} files — importing them all may take a moment. Continue?": ["{n} 個のファイルがあります。すべて読み込むには少し時間がかかります。続けますか?","一共 {n} 个文件,全部导入需要一点时间。继续吗?","共 {n} 個檔案,全部匯入需要一點時間。要繼續嗎?","Son {n} archivos: importarlos todos puede tardar un momento. ¿Continuar?","Cela fait {n} fichiers — tout importer peut prendre un moment. Continuer ?","Das sind {n} Dateien — der Import kann einen Moment dauern. Fortfahren?","Sono {n} file — importarli tutti può richiedere un momento. Continuare?","São {n} ficheiros — importar todos pode demorar um momento. Continuar?"],"That needs to be an http or https address": ["http または https のアドレスを入力してください","这里需要填写 http 或 https 地址","這裡需要填 http 或 https 位址","Tiene que ser una dirección http o https","Il faut une adresse http ou https","Das muss eine http- oder https-Adresse sein","Serve un indirizzo http o https","Tem de ser um endereço http ou https"],"That space is password-protected. Open it, then export the pages you want.": ["そのスペースはパスワードで保護されています。開いてから、必要なページを書き出してください。","该空间受密码保护。请先打开它,再导出你需要的页面。","該空間受密碼保護。請先開啟它,再匯出你需要的頁面。","Ese espacio está protegido con contraseña. Ábrelo y exporta desde allí las páginas que quieras.","Cet espace est protégé par un mot de passe. Ouvrez-le, puis exportez-en les pages voulues.","Dieser Space ist passwortgeschützt. Öffnen Sie ihn und exportieren Sie dort die gewünschten Seiten.","Quello spazio è protetto da password. Aprilo e da lì esporta le pagine che vuoi.","Esse espaço está protegido por palavra-passe. Abra-o e exporte de lá as páginas que quiser."],+ "That version could not be read": ["そのバージョンを読み込めませんでした","无法读取该版本","無法讀取該版本","No se pudo leer esa versión","Cette version n’a pas pu être lue","Diese Version konnte nicht gelesen werden","Non è stato possibile leggere quella versione","Não foi possível ler essa versão"],"The counterpart of Copy document JSON: edit a space in another tool, then bring it back.": ["「文書 JSON をコピー」の対になる機能です。別のツールでスペースを編集して、ここへ戻せます。","“复制文档 JSON”的对应功能:在别的工具里编辑一个空间,再把它带回来。","「複製文件 JSON」的對應功能:在別的工具裡編輯一個空間,再把它帶回來。","La contraparte de Copiar el JSON del documento: edita un espacio en otra herramienta y vuelve a traerlo.","Le pendant de Copier le JSON du document : modifiez un espace dans un autre outil, puis ramenez-le ici.","Das Gegenstück zu „Dokument-JSON kopieren“: Bearbeiten Sie einen Space in einem anderen Werkzeug und bringen Sie ihn zurück.","Il corrispettivo di Copia il JSON del documento: modifica uno spazio in un altro strumento e riportalo qui.","O par de Copiar o JSON do documento: edite um espaço noutra ferramenta e traga-o de volta."],"The day after": ["翌日","后一天","後一天","El día siguiente","Le lendemain","Der Tag danach","Il giorno dopo","O dia seguinte"],"The day before": ["前日","前一天","前一天","El día anterior","La veille","Der Tag davor","Il giorno prima","O dia anterior"],@@ -433,6 +437,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"This page only": ["このページだけ","仅此页面","僅此頁面","Solo esta página","Cette page seulement","Nur diese Seite","Solo questa pagina","Apenas esta página"],"This space has no live session to follow": ["この Space には追従できるライブセッションがありません","此 Space 没有可跟随的实时会话","此 Space 沒有可跟隨的即時會話","Este Space no tiene sesión en vivo que seguir","Cet espace n’a pas de session live à suivre","Dieser Space hat keine Live-Sitzung zum Folgen","Questo Space non ha una sessione live da seguire","Este Space não tem sessão ao vivo para acompanhar"],"This space has no pages.": ["このスペースにはページがありません。","此空间没有页面。","此空間沒有任何頁面。","Este espacio no tiene páginas.","Cet espace n’a aucune page.","Dieser Space hat keine Seiten.","Questo spazio non ha pagine.","Este espaço não tem páginas."],+ "This space is encrypted, so no versions are kept.": ["このスペースは暗号化されているため、バージョンは保存されません。","此空间已加密,因此不保存任何版本。","此空間已加密,因此不保存任何版本。","Este espacio está cifrado, así que no se guarda ninguna versión.","Cet espace est chiffré : aucune version n’est conservée.","Dieser Space ist verschlüsselt, deshalb werden keine Versionen aufbewahrt.","Questo spazio è cifrato, quindi non viene conservata alcuna versione.","Este espaço está cifrado, por isso não são guardadas versões."],"This space is encrypted. Saves stay encrypted.": ["このスペースは暗号化されています。保存しても暗号化されたままです。","此空间已加密。保存时仍保持加密。","此空間已加密。往後的儲存也會維持加密。","Este espacio está cifrado. Los guardados siguen cifrados.","Cet espace est chiffré. Les enregistrements restent chiffrés.","Dieser Space ist verschlüsselt. Speichern bleibt verschlüsselt.","Questo spazio è cifrato. I salvataggi restano cifrati.","Este espaço está encriptado. Continua encriptado sempre que guardar."],"This space is locked": ["このスペースはロックされています","此空间已锁定","此空間已鎖定","Este espacio está bloqueado","Cet espace est verrouillé","Dieser Space ist gesperrt","Questo spazio è bloccato","Este espaço está bloqueado"],"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": ["このウィンドウはまだ v{v} で動作中 — 再読込で完了します。v{v} のバックアップをダウンロード済み。","此窗口仍在运行 v{v} — 重新加载以完成。已下载 v{v} 备份。","此視窗仍在執行 v{v} — 重新載入以完成。已下載 v{v} 備份。","Esta ventana sigue en v{v} — recarga para terminar. Se descargó una copia de seguridad v{v}.","Cette fenêtre tourne encore en v{v} — rechargez pour terminer. Une sauvegarde v{v} a été téléchargée.","Dieses Fenster läuft noch mit v{v} — zum Abschließen neu laden. Ein v{v}-Backup wurde heruntergeladen.","Questa finestra esegue ancora la v{v} — ricarica per completare. È stato scaricato un backup v{v}.","Esta janela ainda está executando a v{v} — recarregue para concluir. Um backup da v{v} foi baixado."],@@ -471,6 +476,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"Verifying…": ["検証中…","验证中…","驗證中…","Verificando…","Vérification…","Verifiziere…","Verifica…","Verificando…"],"Version {v} is available.": ["バージョン {v} が利用可能です。","版本 {v} 可用。","版本 {v} 可用。","Versión {v} disponible.","La version {v} est disponible.","Version {v} ist verfügbar.","È disponibile la versione {v}.","A versão {v} está disponível."],"Version, language, password, exports": ["バージョン・言語・パスワード・書き出し","版本、语言、密码、导出","版本、語言、密碼、匯出","Versión, idioma, contraseña, exportaciones","Version, langue, mot de passe, exports","Version, Sprache, Passwort, Export","Versione, lingua, password, esportazioni","Versão, idioma, senha, exportações"],+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": ["バージョンはこのブラウザーにのみ保存されます。ファイルにもオンラインにも残りません。復元は取り消せます。","版本仅保存在此浏览器中,不会写入文件,也不会上传。恢复操作可以撤销。","版本僅保存在此瀏覽器中,不會寫入檔案,也不會上傳。還原操作可以復原。","Las versiones se guardan solo en este navegador: nunca en el archivo ni en línea. Restaurar se puede deshacer.","Les versions sont conservées uniquement dans ce navigateur — jamais dans le fichier, jamais en ligne. La restauration est annulable.","Versionen liegen nur in diesem Browser — nie in der Datei, nie online. Das Wiederherstellen lässt sich rückgängig machen.","Le versioni restano solo in questo browser: mai nel file, mai online. Il ripristino si può annullare.","As versões ficam apenas neste navegador — nunca no ficheiro, nunca online. Restaurar pode ser desfeito."],"Video": ["動画","视频","影片","Vídeo","Vidéo","Video","Video","Vídeo"],"Video from {host}": ["{host} の動画","来自 {host} 的视频","來自 {host} 的影片","Vídeo de {host}","Vidéo provenant de {host}","Video von {host}","Video da {host}","Vídeo de {host}"],"Video or audio": ["動画または音声","视频或音频","影片或音訊","Vídeo o audio","Vidéo ou audio","Video oder Audio","Video o audio","Vídeo ou áudio"],@@ -501,6 +507,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"bento/spaces is MIT-licensed and carries no third-party runtime — the full notices travel in this file’s source.": ["bento/spaces は MIT ライセンスで、サードパーティのランタイムは含みません。完全な表示はこのファイルのソースに入っています。","bento/spaces 采用 MIT 许可,且不含任何第三方运行时——完整声明就在这个文件的源码里。","bento/spaces 採用 MIT 授權,且不含任何第三方執行環境——完整聲明就在這個檔案的原始碼裡。","bento/spaces tiene licencia MIT y no incluye ningún runtime de terceros: los avisos completos viajan en el código fuente de este archivo.","bento/spaces est sous licence MIT et n’embarque aucun runtime tiers — les mentions complètes voyagent dans le source de ce fichier.","bento/spaces steht unter MIT-Lizenz und enthält keine Fremd-Runtime — die vollständigen Hinweise reisen im Quelltext dieser Datei mit.","bento/spaces è rilasciato con licenza MIT e non include alcun runtime di terze parti: le note complete viaggiano nel sorgente di questo file.","O bento/spaces tem licença MIT e não inclui qualquer runtime de terceiros — os avisos completos viajam no código-fonte deste ficheiro."],"format v{v}": ["フォーマット v{v}","格式 v{v}","格式 v{v}","formato v{v}","format v{v}","Format v{v}","formato v{v}","formato v{v}"],"just now": ["たった今","刚刚","剛剛","ahora mismo","à l'instant","gerade eben","proprio ora","agora mesmo"],+ "most recent": ["最新","最新","最新","más reciente","la plus récente","neueste","più recente","mais recente"],"none": ["なし","无","無","ninguna","aucun","keine","nessuno","nenhuma"],"you": ["あなた","你","你","tú","vous","du","tu","você"],"you: {name} ✎": ["あなた: {name} ✎","你:{name} ✎","你:{name} ✎","tú: {name} ✎","vous : {name} ✎","Sie: {name} ✎","tu: {name} ✎","você: {name} ✎"],diff --git a/spaces/src/i18n/pt.ts b/spaces/src/i18n/pt.tsindex 89f51e34..dbd62e03 100644--- a/spaces/src/i18n/pt.ts+++ b/spaces/src/i18n/pt.ts@@ -556,4 +556,11 @@ export const pt: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "{pages} página(s) e {blocks} bloco(s) acrescentados a partir de {files} ficheiro(s).","{pages} page(s) and {blocks} block(s) will travel.": "Vão viajar {pages} página(s) e {blocks} bloco(s).","⌘Z removes the imported pages again.": "⌘Z remove novamente as páginas importadas.",+ "History": "Histórico",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "As versões ficam apenas neste navegador — nunca no ficheiro, nunca online. Restaurar pode ser desfeito.",+ "This space is encrypted, so no versions are kept.": "Este espaço está cifrado, por isso não são guardadas versões.",+ "No versions yet — they build up as you write and save.": "Ainda sem versões — vão-se acumulando à medida que escreves e guardas.",+ "most recent": "mais recente",+ "That version could not be read": "Não foi possível ler essa versão",+ "Restored the version from {when} — ⌘Z undoes it": "Versão de {when} restaurada — ⌘Z desfaz.",}diff --git a/spaces/src/i18n/zh-Hans.ts b/spaces/src/i18n/zh-Hans.tsindex 0b6b8704..c2c3711e 100644--- a/spaces/src/i18n/zh-Hans.ts+++ b/spaces/src/i18n/zh-Hans.ts@@ -556,4 +556,11 @@ export const zh_Hans: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "从 {files} 个文件新增了 {pages} 个页面、{blocks} 个块。","{pages} page(s) and {blocks} block(s) will travel.": "将带走 {pages} 个页面、{blocks} 个块。","⌘Z removes the imported pages again.": "按 ⌘Z 可以把导入的页面再撤销掉。",+ "History": "历史记录",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "版本仅保存在此浏览器中,不会写入文件,也不会上传。恢复操作可以撤销。",+ "This space is encrypted, so no versions are kept.": "此空间已加密,因此不保存任何版本。",+ "No versions yet — they build up as you write and save.": "暂无版本。随着你的书写和保存,版本会逐渐累积。",+ "most recent": "最新",+ "That version could not be read": "无法读取该版本",+ "Restored the version from {when} — ⌘Z undoes it": "已恢复 {when} 的版本,按 ⌘Z 可撤销。",}diff --git a/spaces/src/i18n/zh-Hant.ts b/spaces/src/i18n/zh-Hant.tsindex 33ac5984..e846752b 100644--- a/spaces/src/i18n/zh-Hant.ts+++ b/spaces/src/i18n/zh-Hant.ts@@ -556,4 +556,11 @@ export const zh_Hant: Catalog = {"{pages} page(s) and {blocks} block(s) added from {files} file(s).": "從 {files} 個檔案新增了 {pages} 個頁面、{blocks} 個區塊。","{pages} page(s) and {blocks} block(s) will travel.": "將帶走 {pages} 個頁面、{blocks} 個區塊。","⌘Z removes the imported pages again.": "按 ⌘Z 可以把匯入的頁面再撤銷掉。",+ "History": "歷史記錄",+ "Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": "版本僅保存在此瀏覽器中,不會寫入檔案,也不會上傳。還原操作可以復原。",+ "This space is encrypted, so no versions are kept.": "此空間已加密,因此不保存任何版本。",+ "No versions yet — they build up as you write and save.": "尚無版本。隨著你的書寫與儲存,版本會逐漸累積。",+ "most recent": "最新",+ "That version could not be read": "無法讀取該版本",+ "Restored the version from {when} — ⌘Z undoes it": "已還原 {when} 的版本,按 ⌘Z 可復原。",}diff --git a/spaces/src/main.ts b/spaces/src/main.tsindex 55fee8c3..54c3476b 100644--- a/spaces/src/main.ts+++ b/spaces/src/main.ts@@ -13,7 +13,7 @@ import {writeUpdatedFileAs, suggestedFileName,isEncryptionActive,} from '../../kernel/src/save.ts'-import { putRecovery, getRecovery, clearRecovery, pruneOld } from '../../kernel/src/autosave.ts'+import { putRecovery, getRecovery, clearRecovery, pruneOld, addVersion } from '../../kernel/src/autosave.ts'import { APP_VERSION } from '../../kernel/src/update.ts'import { t, locale, applyDirection } from './i18n'import { parseDoc, docContentKey, uid, newPage, type SpacesDoc, type ParseResult } from './model'@@ -304,6 +304,11 @@ function boot(doc: SpacesDoc, repaired: string[], frozen?: 'policy' | 'version')return writeUpdatedFileAs(html, out, { suffix })}+ // Two minutes, as in slides. Short enough that a long writing session leaves+ // a usable trail, long enough that the cap is not spent on one afternoon.+ const VERSION_EVERY_MS = 120_000+ let lastVersionAt = 0+async function doSave(): Promise<void> {store.endRun()editor.status(t('Saving…'))@@ -313,6 +318,13 @@ function boot(doc: SpacesDoc, repaired: string[], frozen?: 'policy' | 'version')store.dirty = falseeditor.syncDirty()}+ if (res === 'saved' || res === 'saved-as' || res === 'downloaded') {+ // A SAVE IS THE MOMENT WORTH KEEPING. The throttle below catches long+ // editing runs, but the point somebody chose to write the file is the+ // point they would most want back, so it is never throttled away.+ // Encrypted spaces keep nothing here, for the reason putRecovery does not.+ if (!isEncryptionActive()) { void addVersion(store.doc); lastVersionAt = Date.now() }+ }if (res === 'saved') {void clearRecovery(store.doc.docId)// "Saved" is doing real work here: on a browser without file-system@@ -332,11 +344,30 @@ function boot(doc: SpacesDoc, repaired: string[], frozen?: 'policy' | 'version')// off the disk — and it would do it every few seconds, for the one author who// demonstrably cares. The kernel's putRecovery does not guard this; the// caller must (slides has the same contract).+ //+ // RECOVERY IS NOT HISTORY. putRecovery keeps ONE snapshot per space — the+ // answer to "the tab died", and nothing else. It is overwritten every few+ // seconds, so it cannot answer "put back what I had before lunch", and undo+ // cannot either: the undo stack lives in memory and dies with the reload.+ // Spaces shipped with only the first of those, while slides and dash both+ // keep a timeline. For the app people write PROSE in, that was the wrong one+ // to leave out — a paragraph rewritten badly an hour ago was unrecoverable by+ // any means the app offered.+ //+ // So a version is added on a throttle while editing, and unthrottled on save.+ // The kernel caps and prunes the timeline; both stores stay empty while a+ // password is set.let timer: ReturnType<typeof setTimeout> | undefinedstore.on('doc', () => {clearTimeout(timer)if (isEncryptionActive()) return- timer = setTimeout(() => { void putRecovery(store.doc) }, 2500)+ timer = setTimeout(() => {+ void putRecovery(store.doc)+ if (Date.now() - lastVersionAt > VERSION_EVERY_MS) {+ lastVersionAt = Date.now()+ void addVersion(store.doc)+ }+ }, 2500)})void pruneOld()void offerRecovery(doc, store, editor)diff --git a/spaces/src/styles.css b/spaces/src/styles.cssindex d6de45df..d9a9f762 100644--- a/spaces/src/styles.css+++ b/spaces/src/styles.css@@ -1321,6 +1321,24 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset/* Print shows the placeholder text, never a blank gap the reader can't explain. */@media print { .sp-remote { border-color: #999; background: none; } .sp-remote-load { display: none !important; } }+/* The version timeline. A row is one button so the whole strip is the target —+ a "Restore" word alone is a 44px miss on a touch screen. */+.sp-ab-versions { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px; }+.sp-ab-version {+ display: flex; align-items: center; gap: 10px; width: 100%;+ padding: 7px 9px; border: 1px solid transparent; border-radius: 8px;+ background: transparent; color: var(--ink); font: inherit; font-size: 13px;+ text-align: start; cursor: pointer;+}+.sp-ab-version:hover { background: var(--chrome-2); border-color: var(--line); }+.sp-ab-version:focus-visible { border-color: var(--blue); outline: none; }+.sp-ab-when { font-variant-numeric: tabular-nums; }+.sp-ab-vtag { color: var(--muted); font-size: 12px; }+/* the verb sits at the end and only colours up on approach, so a list of ten+ rows does not read as ten buttons all shouting at once */+.sp-ab-vdo { margin-inline-start: auto; color: var(--muted); }+.sp-ab-version:hover .sp-ab-vdo, .sp-ab-version:focus-visible .sp-ab-vdo { color: var(--blue); }+/* ————— narrow topbar: hide, never scroll —————Measured at 375px: the bar wanted 678px, so seven of eleven controls sat offthe right edge — Save among them, which made the file unsaveable on a phone.