Skip to content

Add local autosave and session recovery #40

@laubonghaudoi

Description

@laubonghaudoi

Summary

Add local autosave and recovery for subtitle editing sessions. This strengthens the app's offline/PWA promise without adding accounts, cloud storage, or backend state.

Why this is in scope

The app is intentionally local-first and browser-based. Losing unsaved subtitle edits on refresh or crash is a major workflow risk, and a local recovery layer directly supports the existing privacy/design principles.

Initial scope

Persist subtitle project state locally:

  • Tracks and track names.
  • Active track ID.
  • Subtitle text/timing data.
  • VTT header/prologue metadata.
  • Relevant editor preferences like track labels and QA thresholds if available.

Do not persist media file contents in the first version.

Implementation plan

  1. Define a project snapshot schema.

    • Create lib/local-session.ts.
    • Include a schema version, timestamp, app version if available, and track state.
    • Keep media file names as display-only metadata if useful, but do not assume the file can be reopened.
  2. Choose storage.

    • Use localStorage for a first minimal implementation if snapshots are small enough.
    • Consider IndexedDB if track payloads become large.
    • Namespaced key: subtitle-editor:autosave:v1.
  3. Debounced persistence.

    • Save after subtitle/track changes with a debounce, e.g. 500-1000ms.
    • Avoid writing on every playback tick.
    • Persist only serializable project state, not undo stacks in the first version unless straightforward.
  4. Recovery UX.

    • On app load, detect an autosaved session newer than the empty/default state.
    • Show a small recovery banner/dialog: restore, discard, or download backup.
    • After restore, keep normal editing and saving flows.
  5. Privacy and safety.

    • Add clear copy that autosave is local to the browser only.
    • Provide clear autosave after successful manual download or from settings.
    • Handle corrupt/old snapshots gracefully.
  6. Tests.

    • Add unit tests for serialization/deserialization and version handling.
    • Add component tests for restore/discard if feasible.

Acceptance criteria

  • Edits are saved locally after changes without a backend.
  • Reloading the page offers to restore the previous subtitle session.
  • Users can discard or clear the local autosave.
  • Media files are not silently uploaded or persisted.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions