Skip to content

feat: auto-link GitHub profile from OAuth#1356

Draft
evanjacobson wants to merge 4 commits intofeature/user-profile-connect-social-accountsfrom
feature/user-profile-autoconnect-github
Draft

feat: auto-link GitHub profile from OAuth#1356
evanjacobson wants to merge 4 commits intofeature/user-profile-connect-social-accountsfrom
feature/user-profile-autoconnect-github

Conversation

@evanjacobson
Copy link
Contributor

Summary

  • When a user links GitHub via OAuth, their profile card automatically shows https://github.com/<username> derived from the OAuth display_name, overriding any manually set github_url
  • The edit profile modal replaces the GitHub text input with a link to /connected-accounts when GitHub is OAuth-linked, fully excluding the field from state, validation, and mutation
  • Manual github_url is preserved in the DB and resurfaces if the user unlinks GitHub

Blocked by

Test plan

  • Link GitHub via OAuth → profile card shows https://github.com/<login>
  • Edit profile modal shows "Linked via GitHub" message instead of text input
  • Clicking "Change in Connected Accounts" navigates to /connected-accounts
  • Saving LinkedIn-only changes works when GitHub is OAuth-linked
  • Unlink GitHub → manual github_url resurfaces in both card and edit modal
  • Users without GitHub OAuth linked see existing manual input behavior
  • GitHub login with special characters (if any) is validated before storage

When a user links GitHub via OAuth, their profile card now shows
the GitHub profile URL derived from the OAuth display_name, overriding
any manually set github_url. The edit modal replaces the GitHub text
input with a link to /connected-accounts when GitHub is OAuth-linked.
When GitHub is linked via OAuth, the edit modal now fully excludes the
GitHub field from state, validation, and mutation — preventing stale
manual values from interfering. Also validates GitHub login format
and improves comment accuracy on display_name assignments.
Replace inline auth provider query in profile page with a dedicated
getOAuthDisplayNames function that returns a Map<AuthProviderId, string>
for O(1) lookup. Query filters for non-null display_name in SQL.
@evanjacobson evanjacobson changed the base branch from main to feature/user-profile-connect-social-accounts March 21, 2026 01:51
@evanjacobson evanjacobson marked this pull request as ready for review March 21, 2026 02:54
@evanjacobson evanjacobson marked this pull request as draft March 21, 2026 02:54
google_user_image_url: user.image || '',
provider: account.provider,
provider_account_id: account.providerAccountId,
display_name: validLogin,
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: Existing GitHub links never get this value

display_name is only set when a provider row is first inserted. On later GitHub sign-ins, findAndSyncExistingUser() returns the user without updating user_auth_provider, so accounts that were already linked before this rollout keep display_name = null and never show the new auto-linked GitHub URL/UI unless the user unlinks and relinks.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 21, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
src/lib/user.server.ts 131 Existing GitHub-linked accounts never get display_name refreshed, so they do not pick up the new auto-linked GitHub URL/UI unless they unlink and relink.
src/lib/user.ts 693 The branch reads user_auth_provider.display_name, but the checked-in Drizzle schema in this branch does not define that column yet, so it will not type-check/build until the schema update is included.
Other Observations (not in diff)

No additional issues found outside the diff.

Files Reviewed (5 files)
  • src/app/(app)/profile/page.tsx - 0 issues
  • src/components/profile/EditProfileDialog.tsx - 0 issues
  • src/components/profile/UserProfileCard.tsx - 0 issues
  • src/lib/user.server.ts - 1 issue
  • src/lib/user.ts - 1 issue

Reviewed by gpt-5.4-20260305 · 377,160 tokens

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.

1 participant