Skip to content

Add multi-draft management and draft expiry to useDraftPersistence#1191

Open
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-954
Open

Add multi-draft management and draft expiry to useDraftPersistence#1191
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-954

Conversation

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Fixes #954

Summary

  • Replaces the single-draft localStorage slot with a named DraftMap keyed by id, allowing multiple in-progress drafts simultaneously
  • Adds a 7-day TTL: expired drafts are pruned on every load via pruneExpiredDrafts; stale drafts never resurface
  • Backwards-compatible migration from the legacy commitlabs-create-draft single-draft key (migrated silently on first load, old key removed)
  • Updates ResumeDraftPrompt to list all available drafts with per-draft Resume and Delete actions, accessible role="dialog" markup, and focus rings

Changes

  • src/hooks/useDraftPersistence.ts — multi-draft + TTL + migration; exports pruneExpiredDrafts, migrateLegacyDraft, loadDraftsFromStorage, DRAFT_TTL_MS, NamedDraft, DraftMap
  • src/components/create/ResumeDraftPrompt.tsx — updated props to drafts: NamedDraft[] with onResume(id) / onDeleteDraft(id) callbacks; shows relative timestamps
  • src/hooks/useDraftMultiExpiry.test.ts — new focused test file covering: multiple drafts persisted, expired draft pruned, legacy single-draft migrated, invalid draft rejected, sort order, clearAllDrafts
  • docs/DRAFT_MANAGEMENT.md — feature docs with API reference, types, accessibility notes, and usage example; cross-links existing autosave doc

- Replace single-draft storage with a named DraftMap keyed by id
- Add 7-day TTL; expired drafts pruned on load via pruneExpiredDrafts
- Backwards-compatible migration from legacy commitlabs-create-draft key
- Expose allDrafts (sorted), clearAllDrafts, and per-id saveDraft/clearDraft/resumeDraft
- Update ResumeDraftPrompt to list all available drafts with resume/delete actions
- Add useDraftMultiExpiry.test.ts covering all edge cases (multi-draft, expiry, migration, invalid)
- Add docs/DRAFT_MANAGEMENT.md with API, types, accessibility notes, and usage example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@greatest0fallt1me is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add multi-draft management and draft expiry to useDraftPersistence

1 participant