Skip to content

Conversation

@jwunderl
Copy link
Member

To allow testing without full deployments (will be restricted / ignored if not valid)

Copy link
Contributor

Copilot AI left a 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 getCopilotServerParam and appendCopilotServerQueryParam in pxt.BrowserUtils to read and safely propagate a validated useCopilotServer query 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 askCopilotQuestionAsync backend 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();
Copy link
Contributor

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?

Copy link
Member Author

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)

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.

3 participants