-
Notifications
You must be signed in to change notification settings - Fork 616
Add 10-character minimum length validation for AI questions with inline visual feedback #11067
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: jwunderl <[email protected]>
Co-authored-by: jwunderl <[email protected]>
Co-authored-by: jwunderl <[email protected]>
|
@copilot this should also apply after the question has been added to the criteria |
Co-authored-by: jwunderl <[email protected]>
Co-authored-by: jwunderl <[email protected]>
Added validation during evaluation in commit 47a063e. Questions shorter than 10 characters will now show "Question must be at least 10 characters" error when evaluated, preventing the "Unable to reach the AI service" message. |
|
@copilot Give it a warning that turns the text input red unless > 10 characters still, currently it just says "value Required" when empty |
…questions Co-authored-by: jwunderl <[email protected]>
Co-authored-by: jwunderl <[email protected]>
Added inline validation in commits c16721a and 7e8a14d. Custom question text inputs now:
|
teachertool/src/constants.ts
Outdated
| export const UnableToReachAI = lf("Unable to reach the AI service"); | ||
| export const UnexpectedError = lf("An unexpected error occurred"); | ||
| export const Dismiss = lf("Dismiss"); | ||
| export const QuestionTooShort = lf("Question must be at least {0} characters"); |
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.
@copilot this should be lf("Question must be at least {0} characters", Misc.MinAIQuestionLength);
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.
Fixed in commit dfe5b60. Changed QuestionTooShort definition to pass the value to lf at definition time: lf("Question must be at least {0} characters", Misc.MinAIQuestionLength). Updated all usages to reference Strings.QuestionTooShort directly without runtime parameter substitution.
Co-authored-by: jwunderl <[email protected]>
| <Textarea | ||
| id={`ask-ai-custom-text-${p.id}`} | ||
| className={css["textarea"]} | ||
| className={classList(css["textarea"], hasError && css["textarea-error"])} |
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.
| className={classList(css["textarea"], hasError && css["textarea-error"])} | |
| className={classList(css["textarea"], hasError ? css["textarea-error"] : undefined)} |
@copilot has a type error as written
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.
Fixed in commit 506034f. Changed to use ternary operator: hasError ? css["textarea-error"] : undefined to avoid type error from boolean false value.
Co-authored-by: jwunderl <[email protected]>
teachertool/src/constants.ts
Outdated
| namespace Misc { | ||
| export const LearnMoreLink = "https://makecode.microbit.org/teachertool"; // TODO: Replace with golink or aka.ms link | ||
| export const ExperienceId = "code-eval"; | ||
| export const MinAIQuestionLength = 10; |
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.
@copilot this appears to have a bundling error and crashes on use before defined; move misc namespace to top of file to work around
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.
Fixed in commit a7375aa. Moved Misc namespace to the top of the file before Strings namespace to resolve the bundling error.
| const inputs = plan.checks[0] as pxt.blocks.AiQuestionValidatorCheck; | ||
| logDebug(`Asking question: '${inputs.question}' on project with shareId: '${inputs.shareId}'`); | ||
| const response = await askCopilotQuestionAsync(inputs.shareId, inputs.question); | ||
|
|
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.
@copilot this is a good warning on unable to evaluate, but it would be good if the 'ask ai' input itself was marked as needing attention (red / warning icon) until enough text was entered
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.
Fixed in commit a7375aa. The 'ask ai' input now shows validation immediately when text exists but is too short. The red border and validation message ("Question must be at least 10 characters") display as soon as the user types, regardless of checkbox state, providing clear visual feedback about why the question cannot be added or evaluated.
| {customPrompts.length > 0 && ( | ||
| <div className={css["custom-list"]}> | ||
| {customPrompts.map((p, index) => ( | ||
| {customPrompts.map((p, index) => { |
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.
@copilot there's no indication of why 'add selected' won't work right now; indicate on the question itself that it needs more text to it to be added
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.
Fixed in commit a7375aa. Validation messages now appear immediately below each question input when text is too short, clearly indicating why 'add selected' won't work. Users see either "Value Required" (empty) or "Question must be at least 10 characters" (1-9 chars) with a red border around the input.
Co-authored-by: jwunderl <[email protected]>
Plan for AI Question Minimum Length Validation
Summary
This PR adds a minimum length validation of 10 characters for AI questions in the teachertool at three points:
Now questions shorter than 10 characters will:
The error string is now properly localized at definition time by passing the minimum length value to the
lffunction. All type errors and bundling issues have been resolved.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.