← Zurück zu Craft
AgentCraft

Skill · Version 1.0.0

Automatisches Speichern und Wiederherstellen

Schützt Bearbeitungen durch geordnete Speicherung, getrennte Entwürfe und Wiederherstellung ohne stilles Überschreiben neuerer Serverversionen.

autosave-recovery

Entdecke, wie der Skill hilft

Wann ist der Skill hilfreich?

Nutze ihn, wenn Dokumente über instabile Verbindungen bearbeitet oder nach unterbrochener Speicherung wieder geöffnet werden.

Wobei hilft er dir?

  • Trennt Bearbeitung, Speicherung, Erfolg und Fehlerzustand.
  • Verwirft veraltete Antworten und bindet Entwürfe an Benutzer und Dokument.
  • Vergleicht lokale Entwürfe vor Wiederherstellung mit Serverversionen.

Das könntest du fragen

Stelle Offline-Änderungen ohne Überschreiben eines neueren Serverdokuments wieder her. Bearbeite denselben Absatz offline und auf einem anderen Gerät. Biete vor der Wiederherstellung einen Vergleich und kennzeichne unbestätigte Uploads nicht als gespeichert.

Ausführliche Dokumentation

Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.

Details…Weniger anzeigen

Autosave & Recovery

Use this skill when building saving, autosaving, offline draft caching, network interruption handling, and version conflict recovery for editors.

Explicit Save State Machine & Sequencing

  1. Never Equate Request Dispatch with "Saved":
    • Model persistence with explicit states: saved (clean), modified (dirty, awaiting debounce), saving (request in flight), error (save failed, retry pending), and conflict (server has a newer version).
    • Display these states honestly in the UI so users always know whether their latest edits are on the server.
  2. Monotonic Sequence Numbers & Out-of-Order Guards:
    • Tag every outgoing save with the local revision counter (clientSeq) and last known server version (baseVersion).
    • If the user edits while save $S_1$ is in flight, keep the state modified after $S_1$ resolves (only transitioning to saved when acknowledgedClientSeq === currentClientSeq), and trigger a follow-up save.
    • Ignore or abort stale responses ($S_1$ arriving after $S_2$) so an older response never overwrites newer local state.
  3. Never Rely Solely on Unload Events:
    • Page close (beforeunload / pagehide) requests can be dropped by the browser. Combine debounced server autosave with immediate local draft persistence and warn on navigation when unsaved changes exist.

Local Draft Isolation & Safe Recovery

  • Scope Local Drafts by User, Workspace, and Document:
    • Key local drafts in IndexedDB/storage by (workspaceId, userId, documentId) with baseVersion, updatedAt, and schema version.
    • Purge or isolate sensitive local drafts on logout, workspace revocation, or TTL expiration.
    • Handle storage quota errors (QuotaExceededError) gracefully without crashing the editor or falsely promising offline recovery.
  • Conflict-Safe Reload & Recovery:
    • On load, compare the server's version against any local un-synced draft's baseVersion:
      • If localDraft.baseVersion === server.version and localDraft has un-synced edits, offer to restore the draft.
      • If server.version > localDraft.baseVersion (or a save returns 409 Conflict), never silently overwrite the newer server document. Pause autosave and let the user inspect, merge, or copy their local draft changes safely.

Checklist

  • Does the UI distinguish modified, saving, saved, error, and conflict accurately?
  • Do monotonic sequence/version checks prevent stale in-flight save responses from overwriting newer edits?
  • Are local drafts scoped to (workspaceId, userId, documentId) and cleared on logout?
  • Does recovery check baseVersion against the server so newer server versions are never silently overwritten?

Enthaltene Dateien 1

  • SKILL.md