Skip to content

Conversation

@jezweb
Copy link

@jezweb jezweb commented Nov 8, 2025

Summary

Provides clear user feedback when R2 image upload fails but the todo creation/update succeeds.

Problem

Previously, if image upload to R2 failed, the error was only logged to console. Users would see "Todo created successfully!" even though their image didn't upload - a silent failure.

Solution

  • Server actions set a todo-warning cookie when R2 upload fails
  • New WarningToast client component checks and displays the warning
  • Cookie is automatically cleared after being read
  • Short-lived cookie (10 seconds) - just enough for redirect

Changes

  • create-todo.action.ts: Set warning cookie on upload failure
  • update-todo.action.ts: Set warning cookie on upload failure
  • warning-toast.tsx: New component to display cookie-based warnings
  • todo-list.page.tsx: Integrate WarningToast component

User Experience

Before: Image fails to upload → "Todo created successfully!" → user doesn't know image is missing
After: Image fails to upload → "Todo created successfully!" → "⚠️ Image upload failed, but todo was created successfully"

Technical Approach

Using cookies to pass warnings from server actions to client:

  1. Server action detects R2 upload failure
  2. Sets todo-warning cookie (10s expiry)
  3. Redirect happens (normal flow)
  4. Client reads cookie and shows warning toast
  5. Cookie is deleted after display

Alternative approaches considered:

  • ❌ Toast from server action (not possible - client-side only)
  • ❌ Return value from server action (can't return after redirect)
  • ✅ Cookie-based messaging (clean, works with redirects)

Testing

  1. Create todo with image → Force R2 failure → See warning toast
  2. Update todo with image → Force R2 failure → See warning toast
  3. Normal uploads → No warning shown

Prevents silent image upload failures.

- Import cookies() in create-todo and update-todo actions
- Set 'todo-warning' cookie when R2 upload fails
- Create WarningToast component to display cookie-based warnings
- Integrate WarningToast into todo-list page
- Clear warning cookie after displaying

Now users see: 'Image upload failed, but todo was created/updated successfully'
when R2 upload fails but todo operation succeeds. Prevents silent failures.
@coderabbitai
Copy link

coderabbitai bot commented Nov 8, 2025

Warning

Rate limit exceeded

@jezweb has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a44687a and 821c4ac.

📒 Files selected for processing (7)
  • SESSION.md (1 hunks)
  • docs/DATABASE_SCHEMA.md (1 hunks)
  • docs/IMPLEMENTATION_PHASES.md (1 hunks)
  • src/modules/todos/actions/create-todo.action.ts (2 hunks)
  • src/modules/todos/actions/update-todo.action.ts (2 hunks)
  • src/modules/todos/components/warning-toast.tsx (1 hunks)
  • src/modules/todos/todo-list.page.tsx (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

jezweb pushed a commit to jezweb/full-flare-stack that referenced this pull request Nov 8, 2025
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.

1 participant