Skip to content
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

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open

Conversation

csells
Copy link
Collaborator

@csells csells commented Feb 3, 2025

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.

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

    • Quick Fixes button to show the analysis-provided quick fixes for each error (not AI, but matches the AI-related feature)
  • Gemini | Generate Code menu item that provides a Prompt dialog containing the following features:

    • set of suggested prompts
    • a retrieval mechanism for the user's last prompt that's remembered between sessions
    • a per-prompt preference for whether to generate Dart or Flutter code, remembered between sessions
    • multi-line text box to gather the user's text prompt
    • support for up to 3 image attachments to send along with the user's text prompt
    • Cancel, Accept and Accept & Run buttons
    • Cmd+Enter (on the mac)/Control+Enter (not on a mac) keyboard shortcuts to invoke the Accept & Run button
    • invoking an Accept button will show the Generating Code dialog with the following features:
      • show syntax colorized code as its generated by the LLM
      • Cancel, Accept and Accept & Run buttons
      • Cmd+Enter (mac)/Control+Enter (not mac) keyboard shortcuts to invoke the Accept & Run button
  • Gemini | Update Code menu item that provides a Prompt dialog with the following differences:

    • the user's last prompt is specific to whether they're creating new code or updating existing code
    • the user's last chosen app type (Dart or Flutter) is specific to whether they're creating or updating code
    • the subsequent Generating Code dialog for updates has the following differences:
      • shows diff output as the LLM generates the code so the user can see the changes before accepting them

Copy link

github-actions bot commented Feb 3, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage

This check for test coverage is informational (issues shown here will not fail the PR).

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/samples/lib/brick_breaker.dart
pkgs/samples/lib/fibonacci.dart
pkgs/samples/lib/google_ai.dart
pkgs/samples/lib/hello_world.dart
pkgs/samples/lib/main.dart
pkgs/samples/lib/sunflower.dart

@csells
Copy link
Collaborator Author

csells commented Feb 3, 2025

I created a commit to add the license header to the three files mentioned and pushed it to my branch on github; I'm not sure why it's not showing up in the list of commits above.

.gitignore Outdated Show resolved Hide resolved
pkgs/dart_services/-X Outdated Show resolved Hide resolved
pkgs/dart_services/lib/src/logging.dart Outdated Show resolved Hide resolved
pkgs/dartpad_ui/lib/editor/editor.dart Outdated Show resolved Hide resolved
pkgs/dartpad_ui/lib/editor/editor.dart Outdated Show resolved Hide resolved
pkgs/dartpad_ui/lib/widgets.dart Show resolved Hide resolved
@johnpryan
Copy link
Contributor

I'm noticing that the editor isn't cleaning up parts of the response properly - it's showing the PRD in the code window:

Screenshot 2025-02-04 at 9 59 09 AM

@csells
Copy link
Collaborator Author

csells commented Feb 4, 2025

I'm noticing that the editor isn't cleaning up parts of the response properly - it's showing the PRD in the code window:

Thanks, @johnpryan. I haven't seen that behavior in a month of testing. It works on my machine. : )

Can you let me know what you were doing so that I can repro?

@johnpryan
Copy link
Contributor

I ran this branch locally and clicked on one of the suggested prompts

@csells
Copy link
Collaborator Author

csells commented Feb 5, 2025

@johnpryan have you changed anything? I can't get that to repro on my box.

@johnpryan
Copy link
Contributor

Weird, I see it happen about 80% of the time. Let me know if you need any more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants