Loading...
Loading...
Generate a comprehensive, actionable plan to implement optimistic updates for every Convex mutation in your React app, delivering instant UI feedback and Sonner toasts for seamless, responsive user experiences.
You are an expert React developer and UX specialist with deep expertise in Convex backend, shadcn/ui (including Sonner toasts), TanStack Query, and optimistic UI patterns for seamless user experiences.
Your goal is to analyze the provided app codebase and generate a comprehensive, actionable plan to add optimistic updates to EVERY Convex mutation. This will make the UI feel instant and responsive: changes appear immediately in the UI, with a success toast from Sonner on confirmation, and automatic reversion on errors.
Key principles:
- Use Convex's built-in optimistic updates where possible (e.g., via useOptimisticUpdate or manual query patching with useQuery).
- For mutations: Optimistically update local state/queries before the mutation resolves.
- On success: Invalidate/revalidate relevant queries and show a success toast (e.g., 'Todo created!').
- On error: Revert optimistic changes, show error toast (e.g., 'Failed to create todo.').
- Ensure no loading spinners block the UI; everything feels immediate.
- Prioritize UX: Reduce perceived latency to <50ms for common actions.
Steps to follow:
1. SCAN the entire provided codebase for all Convex mutations (e.g., useMutation, mutate calls, useConvex mutation hooks).
2. For each mutation, note:
- File/component location.
- Action performed (e.g., createPost, updateUser).
- Affected queries/state (e.g., useQuery('getPosts'), local todos array).
- Current implementation issues (e.g., no optimistic update).
3. Propose implementation:
- Code snippet for optimistic update (using useOptimistic or query.setQueryData).
- Error handling with reversion.
- Sonner toast integration (assume Sonner is set up; import { toast } from 'sonner').
4. Identify global improvements: e.g., custom mutation hooks, query client setup.
Provided codebase/repo details:
[REPO_CODE_OR_KEY_FILES]
App context/description:
[APP_DESCRIPTION]
Target areas (optional):
[SPECIFIC_MUTATIONS_OR_COMPONENTS]
Output in this exact structured format:
## Summary
- Total mutations found: X
- High-impact UX wins: [list]
## Mutations Plan
1. **File: [path] - [Mutation name] ([action])**
- Affected: [queries/state]
- Current: [brief]
- Optimistic code:
```tsx
[code snippet]
```
- Toasts: Success: '[message]', Error: '[message]'
(Repeat for all)
## Global Changes
- [e.g., Convex config, query client wrappers]
## Next Steps
- Prioritized file list to implement.
- Testing checklist for UX (e.g., network throttling).This prompt generates a comprehensive Markdown roadmap for building professional, interactive, agentic CLI coding tools with stunning TUIs, inspired by Claude Code and Aider. Customize placeholders and feed to an AI for an executable build plan.
Generate ultra-detailed, canonical image prompts for Simpsons characters like Ralph Wiggum, optimized for AI generators like Midjourney or DALL-E, ensuring faithful 2D cel-shaded portraits with no background.
Generate a comprehensive, step-by-step Markdown tutorial for building a production-ready Flask web app using a strict 3-layer architecture (presentation, business logic, data), fully customizable for any app functionality.
This reusable prompt template enhances raw AI skill descriptions into clear, structured, markdown-formatted documentation with actionable instructions, examples, and SEO optimization for maximum usability.
Transform vague AI skill descriptions into clear, structured, and professional documentation with this expert prompt template designed for technical writers and prompt engineers.
A professional prompt template for thorough AI-powered code reviews, assessing readability, performance, security, best practices, bugs, and design with scored feedback, detailed breakdowns, refactored code, and prioritized fixes.