From 4b9668fdc576c635d99693813191e7dd006f3d82 Mon Sep 17 00:00:00 2001 From: Hao19911125 <99091644+Hao19911125@users.noreply.github.com> Date: Sun, 12 Apr 2026 15:09:11 +0800 Subject: [PATCH] Clear restored backup dirty history markers --- sync/bme-sync.js | 4 ++++ tests/indexeddb-sync.mjs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/sync/bme-sync.js b/sync/bme-sync.js index ff915cf..31451b2 100644 --- a/sync/bme-sync.js +++ b/sync/bme-sync.js @@ -1120,6 +1120,10 @@ function markManualBackupHistoryForLocalRebind(snapshot = {}, chatId = "") { historyState.processedMessageHashesNeedRefresh = Number.isFinite(lastProcessedAssistantFloor) && lastProcessedAssistantFloor >= 0; + historyState.historyDirtyFrom = null; + historyState.lastMutationReason = ""; + historyState.lastMutationSource = ""; + historyState.lastRecoveryResult = null; meta[RUNTIME_HISTORY_META_KEY] = historyState; return { diff --git a/tests/indexeddb-sync.mjs b/tests/indexeddb-sync.mjs index dc36c20..57adf28 100644 --- a/tests/indexeddb-sync.mjs +++ b/tests/indexeddb-sync.mjs @@ -632,6 +632,13 @@ async function testManualBackupAndRestoreFlow() { 4: "hash-4", }, processedMessageHashesNeedRefresh: false, + historyDirtyFrom: 2, + lastMutationReason: "hash-recheck", + lastMutationSource: "event:message-received", + lastRecoveryResult: { + status: "pending", + fromFloor: 2, + }, }, runtimeBatchJournal: [ { id: "journal-1", processedRange: [0, 0], createdAt: 11 }, @@ -757,6 +764,10 @@ async function testManualBackupAndRestoreFlow() { db.snapshot.meta.runtimeHistoryState.lastProcessedAssistantFloor, 4, ); + assert.equal(db.snapshot.meta.runtimeHistoryState.historyDirtyFrom, null); + assert.equal(db.snapshot.meta.runtimeHistoryState.lastMutationReason, ""); + assert.equal(db.snapshot.meta.runtimeHistoryState.lastMutationSource, ""); + assert.equal(db.snapshot.meta.runtimeHistoryState.lastRecoveryResult, null); assert.ok(Number(db.meta.get("lastBackupRestoredAt")) > 0); const safetyStatus = await getRestoreSafetySnapshotStatus( "chat-backup-flow",