-
Notifications
You must be signed in to change notification settings - Fork 616
propagate a query parameter for ai server changes #11070
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
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.
Pull request overview
This PR adds a way to toggle which Copilot/AI backend server is used via a useCopilotServer query parameter, enabling testing against alternate environments without full deployments.
Changes:
- Introduced
getCopilotServerParamandappendCopilotServerQueryParaminpxt.BrowserUtilsto read and safely propagate a validateduseCopilotServerquery parameter. - Updated the webapp AI error explanation flow to use the new helper so Copilot status and start endpoints share the same server selection mechanism.
- Updated the Teacher Tool’s
askCopilotQuestionAsyncbackend request to also append the Copilot server query parameter consistently.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| webapp/src/cloud.ts | Uses appendCopilotServerQueryParam for the Copilot error explanation start and status endpoints so they honor the useCopilotServer query parameter. |
| teachertool/src/services/backendRequests.ts | Routes the Copilot question endpoint through appendCopilotServerQueryParam to support environment selection in Teacher Tool AI requests. |
| pxtlib/browserutils.ts | Adds reusable helpers to parse and validate useCopilotServer from the URL and append it to API URLs using existing query-param utilities. |
| export function appendCopilotServerQueryParam(url: string): string { | ||
| const value = getCopilotServerParam(); | ||
| if (!value) return url; | ||
| const params = new URLSearchParams(); |
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.
I was wondering for extra security if we should check if the user is logged in at this point? Like if there's no login, don't append the query param?
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.
any security for backend endpoints on the front end is fake; a malicious user will just curl or make the request themselves in the dev tools anyways. no harm in the query parameter existing as the back end is the one that determines whether it is a valid request or not.
(besides that all of our copilot integrations are gated on auth already)
To allow testing without full deployments (will be restricted / ignored if not valid)