Skip to content

feat: Implement draft recovery banner with autosave functionality#483

Open
vestor-dev wants to merge 1 commit into
ritik4ever:mainfrom
vestor-dev:useDraftAutoSvae
Open

feat: Implement draft recovery banner with autosave functionality#483
vestor-dev wants to merge 1 commit into
ritik4ever:mainfrom
vestor-dev:useDraftAutoSvae

Conversation

@vestor-dev
Copy link
Copy Markdown

@vestor-dev vestor-dev commented May 27, 2026

closes #393
closes #394
closes #410
closes #395

  • Update debounce to 2 seconds - Currently using the default 500ms debounce
  • Add draft recovery notification - Let users know their draft was recovered

Summary by CodeRabbit

Release Notes

  • New Features
    • Automatic draft auto-save functionality now saves form progress at regular intervals during stream creation
    • Replaced discard draft button with inline "Draft recovered" banner that displays when a saved draft is detected
    • Draft discard action includes confirmation step and clears all form data and submission state

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@vestor-dev is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

CreateStreamForm now persists form state via autosave every 2 seconds. When a draft exists, an inline recovery banner displays with a discard option that confirms deletion and resets form state. The legacy discard button is removed, and new CSS styles the banner and its controls.

Changes

Draft Recovery Feature

Layer / File(s) Summary
Draft autosave configuration and recovery UI
frontend/src/components/CreateStreamForm.tsx, frontend/src/index.css
useDraftAutosave hook is configured with a 2-second autosave interval. A conditional draft recovery banner renders when a draft exists, offering a discard link that prompts for confirmation and clears the draft, touched state, and submission-attempt state (disabled while submitting). The previous hasDraft discard button is removed from form controls. New CSS rules style .draft-recovery-banner and .draft-recovery-banner__discard-link with base, hover, and disabled states.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A draft now sleeps in storage deep,
Two seconds' grace before you leap,
A banner whispers, "Click to clear,"
Your form data persists right here!
✨ Recovery blooms, no need for fear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fully addresses issue #394 (useDraftAutosave persistence to CreateStreamForm) with autosave at 2 seconds and draft recovery banner; however, issues #393, #410, and #395 requirements are not present in the code changes. Address linked issues #393 (WalletButton network mismatch warning), #410 (ErrorBoundary wrapping), and #395 (CopyableAddress replacement) in this PR or remove them from the linked issues if they are out of scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: implementing draft recovery banner with autosave functionality, which directly matches the modifications to CreateStreamForm and CSS styles.
Out of Scope Changes check ✅ Passed All changes in CreateStreamForm and index.css are directly related to implementing draft autosave and draft recovery banner functionality, with no extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@vestor-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/CreateStreamForm.tsx`:
- Around line 236-260: The banner is shown whenever hasDraft is true (including
autosaves) and performs a destructive discard; change the logic to only show the
banner when a draft was actually restored (introduce or use an explicit flag
like isDraftRestored or restoredDraftTimestamp instead of hasDraft), replace the
discard button with a non-destructive "Dismiss" action that only hides the
banner (e.g., setRestoredDraftVisible(false)) and does not call clearDraft/
setTouched/ setSubmitAttempted, and add a human-readable "created X ago" context
using the restoredDraftTimestamp to render the age; keep the existing disabled
handling via isSubmitting for the dismiss button.

In `@frontend/src/index.css`:
- Around line 223-232: The .draft-recovery-banner__discard-link rule sets font:
inherit which resets font-weight and overrides the intended semibold weight;
update the rule to stop resetting the entire font shorthand—remove font: inherit
or replace it with font-family: inherit so font-weight: 600 on
.draft-recovery-banner__discard-link remains effective and the link renders
semibold.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2e8af361-8930-42e6-8a58-ffd9970043b2

📥 Commits

Reviewing files that changed from the base of the PR and between b6e4bea and 4abf71c.

📒 Files selected for processing (2)
  • frontend/src/components/CreateStreamForm.tsx
  • frontend/src/index.css

Comment on lines +236 to +260
{hasDraft && (
<div
className="draft-recovery-banner"
role="status"
aria-live="polite"
aria-label="Draft recovered"
>
✓ Your unsaved draft has been recovered. You can{" "}
<button
type="button"
className="draft-recovery-banner__discard-link"
onClick={() => {
if (window.confirm("Discard your unsaved stream draft?")) {
clearDraft();
setTouched({});
setSubmitAttempted(false);
}
}}
disabled={isSubmitting}
>
discard it
</button>{" "}
if you prefer to start over.
</div>
)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Recovery banner semantics don’t match restored-draft behavior.

Line 236 uses hasDraft as the trigger, but hasDraft also becomes true for newly autosaved edits (not only restored drafts). This can show a misleading “recovered” banner. Also, Line 244-Line 257 implements destructive discard, while the requirement calls for a non-destructive dismiss and “created X ago” context.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/CreateStreamForm.tsx` around lines 236 - 260, The
banner is shown whenever hasDraft is true (including autosaves) and performs a
destructive discard; change the logic to only show the banner when a draft was
actually restored (introduce or use an explicit flag like isDraftRestored or
restoredDraftTimestamp instead of hasDraft), replace the discard button with a
non-destructive "Dismiss" action that only hides the banner (e.g.,
setRestoredDraftVisible(false)) and does not call clearDraft/ setTouched/
setSubmitAttempted, and add a human-readable "created X ago" context using the
restoredDraftTimestamp to render the age; keep the existing disabled handling
via isSubmitting for the dismiss button.

Comment thread frontend/src/index.css
Comment on lines +223 to +232
.draft-recovery-banner__discard-link {
background: none;
border: none;
color: #166534;
text-decoration: underline;
cursor: pointer;
font-weight: 600;
padding: 0;
font: inherit;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

font: inherit overrides the intended bold discard-link weight.

Line 231 resets font-weight set on Line 229, so the link won’t render as semibold.

Proposed fix
 .draft-recovery-banner__discard-link {
   background: none;
   border: none;
   color: `#166534`;
   text-decoration: underline;
   cursor: pointer;
-  font-weight: 600;
   padding: 0;
   font: inherit;
+  font-weight: 600;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.draft-recovery-banner__discard-link {
background: none;
border: none;
color: #166534;
text-decoration: underline;
cursor: pointer;
font-weight: 600;
padding: 0;
font: inherit;
}
.draft-recovery-banner__discard-link {
background: none;
border: none;
color: `#166534`;
text-decoration: underline;
cursor: pointer;
padding: 0;
font: inherit;
font-weight: 600;
}
🧰 Tools
🪛 Stylelint (17.12.0)

[error] 231-231: Overridden property "font-weight" by shorthand "font" (declaration-block-no-shorthand-property-overrides)

(declaration-block-no-shorthand-property-overrides)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/index.css` around lines 223 - 232, The
.draft-recovery-banner__discard-link rule sets font: inherit which resets
font-weight and overrides the intended semibold weight; update the rule to stop
resetting the entire font shorthand—remove font: inherit or replace it with
font-family: inherit so font-weight: 600 on .draft-recovery-banner__discard-link
remains effective and the link renders semibold.

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

Labels

None yet

Projects

None yet

1 participant