Skip to content

propagate a query parameter for ai server changes#11070

Merged
jwunderl merged 3 commits into
masterfrom
dev/jwunderl/copilot-server-request
May 12, 2026
Merged

propagate a query parameter for ai server changes#11070
jwunderl merged 3 commits into
masterfrom
dev/jwunderl/copilot-server-request

Conversation

@jwunderl
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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.

Comment thread pxtlib/browserutils.ts
export function appendCopilotServerQueryParam(url: string): string {
const value = getCopilotServerParam();
if (!value) return url;
const params = new URLSearchParams();
Copy link
Copy Markdown
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
Copy Markdown
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)

@jwunderl jwunderl enabled auto-merge (squash) May 12, 2026 18:12
@jwunderl jwunderl merged commit 89186c9 into master May 12, 2026
20 checks passed
@jwunderl jwunderl deleted the dev/jwunderl/copilot-server-request branch May 12, 2026 18:23
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