feat: add discard all functionality to ideation view#506
Conversation
- Introduced a new button in the IdeationHeader for discarding all ideas when in dashboard mode. - Implemented state management for discard readiness and count in IdeationView. - Added confirmation dialog for discarding ideas in IdeationDashboard. - Enhanced bulk action readiness checks to include discard operations. This update improves user experience by allowing bulk discarding of ideas with confirmation, ensuring actions are intentional.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. Comment |
Summary of ChangesHello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new "Discard All" feature to the ideation view, enabling users to efficiently remove multiple filtered suggestions at once. The functionality is designed with user experience in mind, incorporating a confirmation dialog to prevent unintended actions. This enhancement streamlines the idea management process by providing a clear and safe method for bulk deletion, complementing the existing "Accept All" feature. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully adds the 'Discard All' functionality to the ideation view, including a confirmation dialog to prevent accidental data loss. The code is well-structured and introduces a helpful pluralizeIdea utility to improve consistency in user-facing messages.
My main feedback is regarding concurrency handling for bulk operations. The new 'Discard All' action can run at the same time as 'Accept All', which could lead to race conditions. I've left a comment with a suggestion to introduce an isDiscardingAll state to prevent this, similar to how isAcceptingAll is already handled.
| const confirmDiscardAll = useCallback(() => { | ||
| const count = filteredSuggestions.length; | ||
| for (const { suggestion, job } of filteredSuggestions) { | ||
| removeSuggestionFromJob(job.id, suggestion.id); | ||
| } | ||
| toast.info(`Discarded ${count} ${pluralizeIdea(count)}`); | ||
| }, [filteredSuggestions, removeSuggestionFromJob]); | ||
|
|
||
| // Common readiness state for bulk operations | ||
| const bulkActionsReady = filteredSuggestions.length > 0 && !isAcceptingAll && !addingId; |
There was a problem hiding this comment.
The current implementation lacks protection against concurrent bulk operations. A user could trigger 'Accept All' while the 'Discard All' confirmation is open, leading to a race condition.
To fix this, you should introduce an isDiscardingAll state, similar to the existing isAcceptingAll state, to ensure only one bulk action can run at a time.
-
Add the state near your other state declarations (around line 188):
const [isDiscardingAll, setIsDiscardingAll] = useState(false);
-
Update
confirmDiscardAllto set this state during the operation:const confirmDiscardAll = useCallback(() => { setIsDiscardingAll(true); try { const count = filteredSuggestions.length; for (const { suggestion, job } of filteredSuggestions) { removeSuggestionFromJob(job.id, suggestion.id); } toast.info(`Discarded ${count} ${pluralizeIdea(count)}`); } finally { setIsDiscardingAll(false); } }, [filteredSuggestions, removeSuggestionFromJob]);
-
Update
bulkActionsReadyto be aware of the new state:const bulkActionsReady = filteredSuggestions.length > 0 && !isAcceptingAll && !addingId && !isDiscardingAll;
This will ensure the UI correctly reflects the busy state and prevents concurrent actions by hiding the bulk action buttons while one is in progress.
Changes from branch feature/v0.12.0rc-1768509904121-pjft