Skip to content

Commit 38d1fec

Browse files
authored
Fix build errors (#39)
### TL;DR Fixed dependency arrays in useEffect hooks and added error logging for the fixer function. ### What changed? - Added error logging in the generate route when the fixer function fails, making it easier to debug issues - Fixed the dependency array in the CodeEditor component's useEffect hook to properly include the `files` dependency instead of just `files.length` - Added missing dependencies (`currentDescription` and `form`) to the PromptForm component's useEffect hook ### How to test? 1. Check the console logs when the fixer function fails to ensure errors are properly logged 2. Verify that the CodeEditor correctly selects the first file when files are loaded 3. Test the PromptForm component with buggy code toggling to ensure the description field updates correctly ### Why make this change? These changes improve the application's stability and maintainability by: - Providing better error visibility when the fixer function fails - Preventing potential React hook dependency issues that could cause unexpected behavior - Ensuring the useEffect hooks run at the appropriate times with all necessary dependencies
2 parents 0ad314c + e59147c commit 38d1fec

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

app/api/generate/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export async function POST(request: NextRequest) {
7171
}
7272
} catch (error) {
7373
// Continue with original files if fixer fails
74+
console.error('Fixer failed:', error);
7475
}
7576
}
7677

components/ui-builder/code-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function CodeEditor({ files = [] }: CodeEditorProps) {
9999
if (!selectedFilePath && files.length > 0) {
100100
setSelectedFilePath(files[0].path);
101101
}
102-
}, [files.length, selectedFilePath]); // Use files.length instead of files array
102+
}, [files, selectedFilePath]); // Include files since we access files[0]
103103

104104
// Get file icon based on extension
105105
const getFileIcon = (path: string) => {

components/ui-builder/prompt-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function PromptForm() {
5050
} else if (!watchUseBuggyCode && currentDescription === buggyCodeText) {
5151
form.setValue('description', '');
5252
}
53-
}, [watchUseBuggyCode]);
53+
}, [watchUseBuggyCode, currentDescription, form]);
5454

5555
async function onSubmit(values: z.infer<typeof formSchema>) {
5656
// Store the prompt and settings in sessionStorage and navigate immediately

0 commit comments

Comments
 (0)