Enhance app type detection logic to include prompt analysis for Flutter references and minor relaxation in system prompts#3560
Conversation
|
|
||
| final prompt = genAiManager.codeEditPromptController.text.toLowerCase(); | ||
|
|
||
| bool mentionsFlutter(String p) { |
There was a problem hiding this comment.
This change is unrelated to the issue as far as I can tell, could you take this out or submit this as a separate pull requests? Thanks!
There was a problem hiding this comment.
Thanks for the review, @johnpryan!
I believe this logic is actually central to fixing the issue. The root cause of #3509 is that an empty editor defaults to AppType.dart, which triggers the "Pure Dart" system prompt (the one forbidding UI).
This change allows the frontend to detect intent (e.g., "Create a Flutter app") and switch to AppType.flutter before sending the request. This ensures the backend selects the correct flutterPrompt instead of forcing the model to fight against the dartPrompt.
Without this, we are relying 100% on the relaxed system prompt (the other change in this PR) to override the wrong context. This feels like a more robust fix, but I am happy to split it out if you strictly prefer relying on the prompt change alone.
There was a problem hiding this comment.
Actually @johnpryan , I see where you're coming from regarding PR scope. I've just force-pushed a version that reverts the dartpad_ui changes. Let's keep this PR focused strictly on the system prompt relaxation. I'll move the prompt-based detection logic to a separate discussion/PR. This should be ready for review now!
PR HealthLicense Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with 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.
This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with |
11b09eb to
d46bbb2
Compare
… relaxation in system prompts
d46bbb2 to
533d952
Compare
Fixes #3509
This PR addresses the issue where the AI would sometimes incorrectly default to a pure Dart context (CLI/Console) when the user intended to build a Flutter app, particularly when starting from an empty editor.
Changes
pkgs/dartpad_ui/lib/app/genai_editing.dart:_determineAppTypelogic to inspect the prompt for keywords (e.g.,flutter,widget,app,custompainter) if the source code is ambiguous or empty.pkgs/dart_services/lib/src/generative_ai.dart:Verification
AppType.flutterand generated the UI code.