Skip to content

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

Description

@1nonlypiece

📌 Description

src/hooks/useDraftPersistence.ts stores a single create-wizard draft under one key with no expiry, so starting a new draft silently overwrites the old one and stale drafts linger forever.

This issue adds multiple named drafts and expiry so users can keep more than one in progress and stale drafts are pruned.

🎯 Requirements and Context

This is a feature / enhancement task for the CommitLabs frontend (Next.js + TypeScript). It must be implemented cleanly, fully typed, accessible, and well tested — and must not regress existing behavior.

  • Support multiple drafts keyed by id with created/updated timestamps; keep schema-versioned validation.
  • Add a TTL so expired drafts are pruned on load; never resurrect invalid drafts.
  • Update ResumeDraftPrompt to let users pick among available drafts.
  • Backwards-compatible migration from the existing single-draft key.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b feature/draft-multi-and-expiry

2. Implement the change

  • Primary files to add or modify:
    • src/hooks/useDraftPersistence.ts — multi-draft + TTL.
    • src/components/create/ResumeDraftPrompt.tsx — choose draft.
    • src/hooks/__tests__/useDraftPersistence.test.ts — extend (reference).
  • Add focused tests in src/hooks/useDraftMultiExpiry.test.ts using Jest / Vitest + React Testing Library (happy-dom), covering rendering, interaction, and the edge cases below.
  • Add documentation in docs/DRAFT_MANAGEMENT.md describing the feature, props/API, accessibility behavior, and a usage example; cross-link it from the relevant README/docs.
  • Keep the diff small and reviewer-friendly; reuse existing primitives, hooks, and the typed API client instead of duplicating logic.

3. Cover edge cases

  • multiple drafts persisted
  • expired draft pruned
  • legacy single-draft migrated
  • invalid draft rejected

4. Test and commit

  • Run the suite (e.g. pnpm test / pnpm vitest run) and ensure new lines are covered.
  • Verify keyboard navigation, focus handling, and prefers-reduced-motion where relevant.

Example commit message

feat: multi-draft management and expiry in draft persistence

✅ Guidelines

  • Minimum 95% test coverage on the new/changed lines.
  • Clear, reviewer-friendly documentation (props/API + usage example + accessibility notes).
  • No regressions to existing components, routes, or tests.
  • Fully typed (no any), accessible (labels, roles, live regions where relevant).
  • Timeframe: 96 hours.

🏷️ Labels

type-feature · type-enhancement · area-frontend · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the CommitLabs contributor Discord to coordinate, ask questions, and get unblocked fast: https://discord.gg/WV7tdYkJk
  • Please introduce yourself in the channel before you start so we can avoid duplicate work, pair you with a reviewer, and get your PR merged quickly.
  • Maintainers actively triage this channel and aim for fast, clear, respectful reviews — reach out any time you're blocked.

Metadata

Metadata

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions