-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dialog while waiting for rules to process #296
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Caution Review failedThe pull request is closed. WalkthroughThe pull request focuses on significant refactoring of the Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx (4)
59-65
: Remove or implement commented className logic.The commented className logic suggests incomplete styling decisions. Either implement the conditional styling or remove the comments to maintain code clarity.
66-82
: Consider simplifying step rendering logic.The current step rendering logic could be simplified using an object map or switch statement for better maintainability.
- {currentStep === 0 && <IntroStep next={next} />} - {currentStep === 1 && <Step1 back={back} next={next} />} - {currentStep === 2 && <Step2 back={back} next={next} />} - {currentStep === 3 && <Step3 back={back} next={next} />} + {(() => { + const steps = { + 0: <IntroStep next={next} />, + 1: <Step1 back={back} next={next} />, + 2: <Step2 back={back} next={next} />, + 3: <Step3 back={back} next={next} /> + }; + return currentStep <= 3 ? steps[currentStep as keyof typeof steps] : ( + result ? ( + <FinalStepReady + back={back} + next={() => onOpenChange(false)} + result={result} + /> + ) : ( + <FinalStepWaiting back={back} /> + ) + ); + })()}
211-216
: Maintain consistent navigation layout.The button layout in
FinalStepReady
differs from theStepNavigation
pattern used in other steps. Consider using theStepNavigation
component here for consistency.- <div className="flex justify-center"> - <Button variant="outline" onClick={back}> - Back - </Button> - <Button onClick={next}>Test them now!</Button> - </div> + <div className="flex justify-center"> + <StepNavigation + back={back} + next={next} + nextText="Test them now!" + /> + </div>
243-393
: Remove commented out carousel implementation.Large blocks of commented out code should be removed as they add unnecessary noise to the codebase. The code can be retrieved from Git history if needed in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx
(3 hunks)apps/web/app/(app)/automation/RulesPrompt.tsx
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (6)
apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx (2)
13-27
: Well-structured type definitions!The new type definitions are clear, reusable, and follow TypeScript best practices. The hierarchy from
StepProps
toStepContentProps
is logical and promotes code reuse.
88-115
: Well-designed reusable components!The
StepNavigation
andStep
components are well-structured, promoting consistency and reusability across all dialog steps.apps/web/app/(app)/automation/RulesPrompt.tsx (4)
39-39
: LGTM!The import statement is correctly structured and follows the project's import conventions.
94-99
: LGTM!The state management is well-structured with appropriate types for tracking dialog state and processing results.
143-144
: Consider handling concurrent submissions.While the dialog management is good, there's a potential race condition if multiple submissions occur simultaneously. Consider adding a guard clause or disabling the submit button while processing.
Run this script to check for other similar patterns in the codebase:
Also applies to: 149-149
186-190
: Verify dialog accessibility implementation.The dialog integration looks good, but ensure that the
ProcessingPromptFileDialog
component implements proper accessibility features such as:
- Keyboard navigation
- Screen reader announcements for processing status
- Focus management
Run this script to check the dialog component's accessibility implementation:
✅ Verification successful
Dialog implementation has proper accessibility features ✓
The Dialog component is built on RadixUI's Dialog primitive, which provides comprehensive accessibility features including:
- Proper ARIA attributes and roles
- Keyboard navigation and focus management
- Screen reader announcements
- Focus trap within the dialog
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for accessibility-related attributes in the dialog component rg -A 5 'aria-|role=|tabIndex|onKeyDown' "automation/ProcessingPromptFileDialog"Length of output: 158
Script:
#!/bin/bash # Find the dialog component file fd -t f "ProcessingPromptFileDialog" # Once found, examine its contents fd -t f "ProcessingPromptFileDialog" -x cat {}Length of output: 11203
Script:
#!/bin/bash # Look for the base Dialog component fd -t f "dialog.tsx" "components/ui" # If found, examine its contents fd -t f "dialog.tsx" "components/ui" -x cat {}Length of output: 283
Script:
#!/bin/bash # Search for dialog component file anywhere in the repository fd -t f "dialog.tsx" # Search for Dialog component usage patterns ast-grep --pattern 'import { Dialog } from "@/components'Length of output: 263
Script:
#!/bin/bash # Examine the base Dialog component cat apps/web/components/ui/dialog.tsx # Look for accessibility-related patterns rg -A 3 'aria-|role=|focus|keydown' apps/web/components/ui/dialog.tsxLength of output: 4765
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
apps/web/utils/string.ts (1)
40-46
: Consider enhancing pluralization logic for edge casesWhile the current implementation works for basic cases, consider these improvements:
- Handle irregular plurals (e.g., child → children)
- Support special English rules (e.g., words ending in 'y', 'f')
- Add input validation for negative numbers
Example enhancement:
+const IRREGULAR_PLURALS = { + child: "children", + person: "people", + // Add more as needed +}; + export function pluralize( count: number, singular: string, plural = `${singular}s`, ) { + if (count < 0) throw new Error("Count must be non-negative"); + if (IRREGULAR_PLURALS[singular]) { + return count === 1 ? singular : IRREGULAR_PLURALS[singular]; + } return count === 1 ? singular : plural; }apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx (5)
15-29
: LGTM! Well-structured type definitions.The type definitions are clean and follow TypeScript best practices. The separation of concerns between
StepProps
,StepContentProps
, andResultProps
is well thought out.Consider making the step types more reusable by moving them to a separate types file, as they might be useful in other dialog components:
+// types/dialog.ts +export type StepProps = { + back?: () => void; + next?: () => void; +}; + +export type StepContentProps = StepProps & { + title: string; + children: React.ReactNode; +};
61-67
: Clean up commented code.There are commented className configurations that should either be removed or implemented. Commented code can lead to confusion and maintenance issues.
Either remove the commented code or implement it with a clear explanation of its purpose:
- // className={ - // currentStep !== 0 - // ? "max-h-[90vh] overflow-y-auto px-0 sm:max-w-7xl" - // : undefined - // } + className="max-h-[90vh] overflow-y-auto px-0 sm:max-w-7xl"
90-117
: Enhance accessibility for navigation components.While the navigation components are well-structured, they could benefit from improved accessibility.
Consider these accessibility improvements:
function StepNavigation({ back, next }: StepProps) { return ( - <div className="flex gap-2"> + <nav className="flex gap-2" aria-label="Dialog navigation"> {back && ( - <Button variant="outline" onClick={back}> + <Button + variant="outline" + onClick={back} + aria-label="Go to previous step" + > Back </Button> )} - {next && <Button onClick={next}>Next</Button>} + {next && ( + <Button + onClick={next} + aria-label="Proceed to next step" + > + Next + </Button> + )} - </div> + </nav> ); }
147-153
: Optimize image loading behavior.The Image components could benefit from optimization attributes for better user experience.
Add loading and priority attributes to improve image loading behavior:
<Image src="/images/automation/rules.png" alt="Analyzing prompt file" width={500} height={300} + loading="eager" + priority={true} className="rounded-lg shadow" />Also applies to: 162-168, 183-189
218-243
: Simplify message construction logic.The message construction in
getDescription
could be simplified using array methods.Consider this more maintainable approach:
function getDescription() { - let message = ""; - - if (result.createdRules > 0) { - message += `We've created ${result.createdRules} ${pluralize( - result.createdRules, - "rule", - )} for you.`; - } - - if (result.editedRules > 0) { - message += ` We edited ${result.editedRules} ${pluralize( - result.editedRules, - "rule", - )}.`; - } - - if (result.removedRules > 0) { - message += ` We removed ${result.removedRules} ${pluralize( - result.removedRules, - "rule", - )}.`; - } - - return message; + const messages = [ + result.createdRules > 0 && + `We've created ${result.createdRules} ${pluralize(result.createdRules, "rule")} for you`, + result.editedRules > 0 && + `We edited ${result.editedRules} ${pluralize(result.editedRules, "rule")}`, + result.removedRules > 0 && + `We removed ${result.removedRules} ${pluralize(result.removedRules, "rule")}`, + ].filter(Boolean); + + return messages.join(". ") + "."; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
apps/web/public/images/automation/process.png
is excluded by!**/*.png
apps/web/public/images/automation/rule-edit.png
is excluded by!**/*.png
apps/web/public/images/automation/rules.png
is excluded by!**/*.png
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx
(2 hunks)apps/web/components/ui/carousel.tsx
(0 hunks)apps/web/package.json
(0 hunks)apps/web/utils/string.ts
(1 hunks)
💤 Files with no reviewable changes (2)
- apps/web/package.json
- apps/web/components/ui/carousel.tsx
🔇 Additional comments (2)
apps/web/utils/string.ts (1)
40-46
: Implementation looks good for basic pluralization needs!The function provides a clean and simple way to handle basic English pluralization.
apps/web/app/(app)/automation/ProcessingPromptFileDialog.tsx (1)
50-56
: LGTM! Clean step management implementation.The step navigation logic using
useCallback
is well-implemented, and the conditional rendering of steps is clear and maintainable.Also applies to: 73-84
Summary by CodeRabbit
New Features
Refactor
Bug Fixes