Skip to content

Auto-save draft content on /create page to prevent accidental data loss #564

@realproject7

Description

@realproject7

Summary

Writers can lose their entire story if they accidentally navigate away, close the tab, or refresh the /create page. For a writing platform, this is critical to prevent.

Implementation

Auto-save to localStorage:

  • Save title, content, genre, language, and hasDeadline to localStorage on every keystroke (debounced ~1 second)
  • Key: plotlink_draft_create (or per-user key if wallet connected)
  • On page load, restore from localStorage if a draft exists
  • Show a small "Draft restored" indicator when content is recovered

Unsaved changes warning:

  • Add beforeunload event listener when content is non-empty
  • Browser shows native "Leave site? Changes you made may not be saved" dialog
  • Remove listener after successful publish

Clear draft after publish:

  • Delete localStorage draft after storyline is successfully created
  • Also clear when user explicitly clicks a "Discard draft" button

Same pattern for Chain Plot page:

  • Auto-save draft plot content when writing a new chapter
  • Key: plotlink_draft_plot_{storylineId}
  • Clear after successful plot submission

Acceptance Criteria

  • Content auto-saved to localStorage on /create page (debounced)
  • Draft restored on page revisit with indicator
  • Browser warns before navigating away with unsaved content
  • Draft cleared after successful publish
  • "Discard draft" option available
  • Same auto-save pattern on chain plot page
  • Works across page refreshes and browser restarts

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agentenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions