feat(kanban): recover from missing sync history

req: sync/007\nreq: sync/020
This commit is contained in:
slhx agent
2026-07-13 16:53:49 +02:00
parent 5ea747d968
commit db57b0c474
4 changed files with 212 additions and 12 deletions
+15
View File
@@ -140,6 +140,21 @@ async function synchronize(command) {
root.dispatchEvent(new CustomEvent("kanban:sync-acknowledged", { detail: canonical }));
source.close();
});
source.addEventListener("snapshot-required", async (event) => {
const missing = JSON.parse(event.data);
const response = await fetch(missing.snapshotUrl);
if (!response.ok) throw new Error(`snapshot failed with ${response.status}`);
const snapshot = await response.json();
const queued = await pendingCommands(database);
root.setAttribute("data-sync-snapshot-sequence", String(snapshot.serverSequence));
root.setAttribute("data-sync-snapshot-schema", String(snapshot.schemaVersion));
root.setAttribute("data-sync-snapshot-card-count", String(snapshot.cards.length));
root.setAttribute("data-sync-rebase-pending-count", String(queued.length));
root.setAttribute("data-sync-canonical-column", snapshot.cards.find((card) => String(card.id) === command.cardId)?.column || "missing");
setPhase("rebase-required", `History is unavailable; loaded snapshot ${snapshot.serverSequence} and preserved ${queued.length} pending command for rebase.`);
root.dispatchEvent(new CustomEvent("kanban:sync-rebase-required", { detail: { snapshot, pending: queued } }));
source.close();
});
} catch (error) {
setOnline(false);
if (error instanceof UploadError && !error.retryable) throw error;