Clear restored backup dirty history markers

This commit is contained in:
Hao19911125
2026-04-12 15:09:11 +08:00
parent 288c33f3c3
commit 4b9668fdc5
2 changed files with 15 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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",