-
Notifications
You must be signed in to change notification settings - Fork 569
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
Adding Generative AI Features to DartPad #3135
Conversation
… Markdown code blocks
Yup; for the problem view, there's no space between the problem text and the first action button: ![]() For the spinner, it looks too large in context: ![]() And, the contrast for the diff - between the text and the add/remove text style - seemed off. I'm not sure the colors I have are a strict improvement. Perhaps more pastel-like colors? 🤷 It would be hard to get good sets of colors for both light and dark themes. |
I totally seeing the padding issue with the quick fix icon. I'll fix it. Can I talk you out of the size changes on the spinner? It matches the size of the title and it's easy to see w/o it being in the way or too large. I like it. I know what you mean about the lighter colors. I'll take another look at that. |
This is looking good to me after the latest changes to the prompt, thanks @csells! A few other pieces of feedback:
|
Excellent feedback, @johnpryan! A couple of follow up questions:
|
If you find usages of the
This is stored in Hope this helps! |
It's subjective, but to me, the constrained size - in my patch - looks better. ymmv |
… in the console based on the error state of the app
… prompts for Dart/Flutter.
…into Flutter programs
OK. I believe that I have addressed all of feedback from @johnpryan and @devoncarew:
The only real snag was detecting when an error was in the console, as described by this issue. In the meantime, I added a heuristic to In addition, I fixed the following issues I found as I was testing:
|
@johnpryan this looks like another JS focus issue. Any ideas how to deal with it? That's beyond my knowledge of the Flutter and HTML interaction model. |
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.
Code Review
The addition of generative AI features to DartPad is a great step forward. The new features, including the suggest fix button and the generate code menu item, will significantly enhance the user experience. The code is generally well-structured, but there are several areas where improvements can be made to enhance the code's maintainability, readability, and robustness.
Summary of Findings
- Error Handling: The error handling in the
_streamResponse
function could be improved by providing more context-specific error messages and potentially logging the full stack trace for easier debugging. - Code Duplication: There is some code duplication in the
_flutterSystemInstructions
and_dartSystemInstructions
methods. Consider refactoring these into a single method with a parameter to differentiate between Flutter and Dart instructions. - String Interpolation: Consider using string interpolation instead of string concatenation for better readability in several places, such as in the
prompt
variable in thesuggestFix
method. - Null Safety: Ensure that all nullable variables are properly handled to prevent null pointer exceptions. For example, in the
_textOnly
method, theresponse.text
property is nullable and should be handled accordingly. - Code Readability: Improve code readability by adding more comments to explain complex logic, especially in the
cleanCode
method.
Assessment
This pull request introduces generative AI features to DartPad, which is a significant enhancement. The code is generally well-structured, and the new features seem promising. However, there are several areas where improvements can be made to enhance the code's maintainability, readability, and robustness. Addressing these comments before merging is highly recommended. Given the number of comments, it's important to have others review and approve this code before merging.
the remaining conflicting code is strictly additive, so I have no idea why it's showing as conflicting. |
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.
🎉
This PR adds the following generative AI features to DartPad:
Suggest Fix button added to the console to suggest a fix for a run-time error using the Gemini LLM
Suggest Fix button added to each error to suggest a fix for a compile-time using the Gemini LLM
Gemini | Generate Code menu item that provides a Prompt dialog containing the following features:
Gemini | Update Code menu item that provides a Prompt dialog with the following differences: