Automatically choose the copilot endpoint in the codespace if it's available#48
Conversation
There was a problem hiding this comment.
Pull request overview
Updates devcontainer initialization to better bootstrap a Codespaces environment and to prefer the GitHub Copilot API endpoint when it’s reachable/authenticated.
Changes:
- Add a
postCreateCommandscript that creates a Python venv, installs tooling, builds, and installs the package editable. - Update
post-attach.shto generate a.envfile dynamically and (in Codespaces) probehttps://api.githubcopilot.com/modelsto decide whether to defaultAI_API_ENDPOINTtohttps://api.githubcopilot.com. - Remove the
.devcontainer/env-defaulttemplate file (replaced by inline.envgeneration).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .devcontainer/post-create.sh | Adds devcontainer creation-time Python environment setup (venv + deps + build + editable install). |
| .devcontainer/post-attach.sh | Generates .env and attempts to auto-select Copilot endpoint in Codespaces using a curl probe. |
| .devcontainer/env-default | Removes the old .env template now that .env is generated by script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.devcontainer/post-attach.sh
Outdated
| if curl --fail --silent --show-error https://api.githubcopilot.com/models -H "Authorization: Bearer $GITHUB_TOKEN" > /dev/null; then | ||
| USE_GITHUB_TOKEN="true" |
There was a problem hiding this comment.
The curl probe has no timeout, so a transient DNS/network stall could hang postAttachCommand for a long time. Consider adding --connect-timeout/--max-time (and optionally a small retry) so Codespaces attach remains responsive when the Copilot endpoint is slow/unreachable.
7c5185f to
475305a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
During codespace initialization, use a curl command to test whether https://api.githubcopilot.com/ is working. If so, default to using that.