Skip to content

Automatically choose the copilot endpoint in the codespace if it's available#44

Closed
kevinbackhouse wants to merge 3 commits into
GitHubSecurityLab:mainfrom
kevinbackhouse:env-copilot
Closed

Automatically choose the copilot endpoint in the codespace if it's available#44
kevinbackhouse wants to merge 3 commits into
GitHubSecurityLab:mainfrom
kevinbackhouse:env-copilot

Conversation

@kevinbackhouse
Copy link
Copy Markdown
Contributor

During codespace initialization, use a curl command to test whether https://api.githubcopilot.com is working. If so, default to using that.

Copilot AI review requested due to automatic review settings February 7, 2026 13:16
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

Updates the devcontainer initialization to auto-select the GitHub Copilot API endpoint when it’s reachable during Codespaces (or devcontainer) attachment, improving the out-of-box .env defaults for users who have Copilot access.

Changes:

  • Add a curl-based probe in .devcontainer/post-attach.sh to decide between env-default and a new env-copilot template when generating .env.
  • Add MODEL_TEMP guidance to the default env template.
  • Introduce .devcontainer/env-copilot that defaults AI_API_ENDPOINT to https://api.githubcopilot.com.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.devcontainer/post-attach.sh Adds endpoint reachability check to choose which env template is copied to .env.
.devcontainer/env-default Adds commented guidance for setting MODEL_TEMP.
.devcontainer/env-copilot New env template that defaults AI_API_ENDPOINT to the Copilot endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .devcontainer/env-copilot
Comment on lines +21 to +23
if [ -v AI_API_TOKEN ]; then
if curl --fail https://api.githubcopilot.com/models -H "Authorization: Bearer $AI_API_TOKEN" -H "Copilot-Integration-Id: vscode-chat"; then
ENV_VERSION="env-copilot"
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The curl probe can hang or significantly delay post-attach when DNS/TLS or the endpoint is slow/unreachable. Add explicit timeouts (e.g., connect + overall) so Codespaces initialization doesn’t block on a network call, and consider handling transient failures (timeout) as a non-fatal fallback to env-default.

Copilot uses AI. Check for mistakes.
Comment thread .devcontainer/post-attach.sh Outdated
Comment thread .devcontainer/post-attach.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 7, 2026 13:22
@kevinbackhouse kevinbackhouse marked this pull request as ready for review February 7, 2026 13:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .devcontainer/post-attach.sh
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.

2 participants