fix(copilot): add username fallback and consistent file name prefix

- Add 'github-user' fallback in WaitForAuthorization when FetchUserInfo
  returns empty Login (fixes malformed 'github-copilot-.json' filenames)
- Standardize Web API file name to 'github-copilot-<user>.json' to match
  CLI path convention (was 'github-<user>.json')

Addresses Gemini Code Assist review comments on PR #291.
This commit is contained in:
Howard Dong
2026-02-25 17:17:51 +08:00
parent 43e531a3b6
commit fc346f4537
2 changed files with 7 additions and 2 deletions

View File

@@ -1974,7 +1974,7 @@ func (h *Handler) RequestGitHubToken(c *gin.Context) {
Type: "github-copilot",
}
fileName := fmt.Sprintf("github-%s.json", username)
fileName := fmt.Sprintf("github-copilot-%s.json", username)
label := userInfo.Email
if label == "" {
label = username

View File

@@ -87,9 +87,14 @@ func (c *CopilotAuth) WaitForAuthorization(ctx context.Context, deviceCode *Devi
log.Warnf("copilot: failed to fetch user info: %v", err)
}
username := userInfo.Login
if username == "" {
username = "github-user"
}
return &CopilotAuthBundle{
TokenData: tokenData,
Username: userInfo.Login,
Username: username,
Email: userInfo.Email,
Name: userInfo.Name,
}, nil