Added Copilot login through GHE#827
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5804ca2487
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| public var deviceCodeURL: URL { | ||
| URL(string: "https://\(self.host)/login/device/code")! |
There was a problem hiding this comment.
Guard against invalid enterprise host before force unwrap
The new host field is user-editable, but deviceCodeURL force-unwraps URL(string:); inputs that are not valid hostnames (for example foo bar) survive normalizedHost and make URL(string:) return nil, which crashes the login flow as soon as requestDeviceCode() reads this property. This should fail gracefully (validation or throwing) instead of terminating the app.
Useful? React with 👍 / 👎.
| if let parsedHost = URLComponents(string: host)?.host, !parsedHost.isEmpty { | ||
| host = parsedHost |
There was a problem hiding this comment.
Preserve custom port when normalizing enterprise hosts
When the host is provided as a full URL with a non-default port (for example https://ghe.example.com:8443), URLComponents(...).host strips the port and only keeps ghe.example.com, so subsequent device-flow and API requests are sent to port 443 instead of the configured endpoint. This breaks enterprise instances behind custom HTTPS ports.
Useful? React with 👍 / 👎.
|
Deep review pass from current Thanks for the GHE Copilot work. I don't think this is mergeable as-is yet. What I checked:
Best next shape: rebase onto current |
|
Extra live check from current Using my token from
I do not have a GHE host/token in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ab3f24806
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let fetcher = CopilotUsageFetcher( | ||
| token: token, | ||
| enterpriseHost: enterpriseHost.isEmpty ? nil : enterpriseHost) |
There was a problem hiding this comment.
Resolve identity against enterprise host during Copilot login
This enterprise-host login path only applies enterpriseHost to the usage fetch, but account identity lookup in the same flow still calls CopilotUsageFetcher.fetchGitHubIdentity(token:), which is hardcoded to https://api.github.com/user. For enterprise tokens tied to api.<enterpriseHost>, that lookup returns 401/403, so re-auth fails whenever any Copilot account already exists (the code shows “Could Not Identify GitHub Account” and exits), effectively blocking account refresh/login on GHE hosts.
Useful? React with 👍 / 👎.
|
oh wow, that was fast, thanks Peter! |
Adding a textfield in the Settings > Providers > GitHub Copilot to enter your Enterprise host and get logged in through it instead of the default github.com