Skip to content

feat(github): MVP-2 connect mutation, callback, settings UI, and getUserTokenForRepo RPC - #3203

Merged
kilo-code-bot[bot] merged 4 commits into
convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/headfrom
convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/gt/maple/72a28820
May 12, 2026
Merged

kilo-code-bot[bot] merged 4 commits into
convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/headfrom
convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/gt/maple/72a28820

Conversation

@kilo-code-bot

@kilo-code-bot kilo-code-bot Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

MVP-2 of the "commit as user via GitHub App user tokens" convoy. Implements the full OAuth connect flow end-to-end:

  • connectUserIdentity tRPC mutation (github-apps-router.ts): generates a signed JWT OAuth state and returns a GitHub authorize URL
  • OAuth callback route (/api/integrations/github/user-connect/callback/route.ts): exchanges the code for a user token via @octokit/oauth-methods, resolves GitHub identity, encrypts and upserts the token into user_github_app_tokens
  • getUserConnectionStatus query: returns connected/expired/disconnected status + login without exposing the token
  • disconnectUserIdentity mutation: revokes the GitHub authorization and deletes the local row
  • Settings UI card (GitHubIntegrationDetails.tsx): "Commit as You" card gated by enableUserTokens flag showing connect/reconnect/disconnect states
  • getUserTokenForRepo RPC in git-token-service (user-github-token-service.ts): decrypts and returns a valid token for a given repo if available; used by cloud-agent-next in MVP-3
  • OAuth state helper (oauth-state.ts): sign/verify HMAC-SHA256 JWT state with TTL
  • GDPR soft-delete (user.ts): deletes user_github_app_tokens rows in softDeleteUser
  • Typecheck fixes: expiresAt union narrowing, toISOString() for timestamp string columns, missing eq import

Verification

  • tsgo --noEmit -p apps/web/tsconfig.json — passes (EXIT 0)
  • pnpm --filter cloudflare-git-token-service run typecheck — passes (EXIT 0)
  • pnpm --filter @kilocode/db run typecheck — passes (EXIT 0)
  • Unit tests (github-apps-router.test.ts, callback/route.test.ts, oauth-state.test.ts) require Postgres — skipped in this environment (no DB available); tests are written and structurally correct

Visual Changes

N/A (settings UI card is feature-flagged behind enableUserTokens)

Reviewer Notes

  • This branch cherry-picks the two MVP-2 implementation commits from gt/toast/4b8b7e18 onto the convoy feature branch head, plus a fix commit for typecheck errors
  • The getUserTokenForRepo RPC is used by MVP-3 (cloud-agent-next) which is in a parallel branch
  • Token expiry defaults to 8h when GitHub App has expiration disabled (per MVP spec)

Toast (gastown) and others added 3 commits May 12, 2026 14:31
- Use 'expiresAt' in auth narrowing for GitHubAppAuthentication union type
- Fix updated_at to use toISOString() (timestamp mode: 'string')
- Fix access_token_expires_at in user.test.ts to use toISOString()
- Add missing eq import in github-apps-router.test.ts
- Narrow userConnectionStatus.login access with 'login' in guard
- Apply oxfmt formatting

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Three groups of unused imports need to be cleaned up — per coding standards the linter will flag these and the correct fix is removal, not _-prefixing.

  1. getUserFromAuth imported in route.ts but never called.
  2. isNull, gt, safeReturnTo, encryptWithSymmetricKey imported in github-apps-router.ts but never referenced.
  3. isNull, lte imported in user-github-token-service.ts but never referenced.

Otherwise the implementation looks correct — HMAC-signed state, timing-safe comparison, encryption-at-rest, GDPR delete in softDeleteUser, repo-access cache, proper fallback in errorRedirect. No secrets are logged.

@kilo-code-bot

kilo-code-bot Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Previously Flagged — All Resolved ✓

The 7 unused import warnings from the first review have all been cleaned up in the follow-up commit (71d1834c6):

File Fix
callback/route.ts Removed getUserFromAuth, eq, and captureMessage imports
github-apps-router.ts Removed isNull, gt, safeReturnTo, and encryptWithSymmetricKey imports
user-github-token-service.ts Removed isNull and lte imports
Files Reviewed (9 files)
  • apps/web/src/app/(app)/integrations/github/page.tsx
  • apps/web/src/app/api/integrations/github/user-connect/callback/route.ts
  • apps/web/src/app/api/integrations/github/user-connect/callback/route.test.ts
  • apps/web/src/components/integrations/GitHubIntegrationDetails.tsx
  • apps/web/src/lib/config.server.ts
  • apps/web/src/lib/integrations/platforms/github/oauth-state.ts
  • apps/web/src/lib/user.ts
  • apps/web/src/routers/github-apps-router.ts
  • services/git-token-service/src/user-github-token-service.ts

Reviewed by claude-4.6-sonnet-20260217 · 239,066 tokens

@kilo-code-bot
kilo-code-bot Bot merged commit 34f0614 into convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/head May 12, 2026
2 checks passed
@kilo-code-bot
kilo-code-bot Bot deleted the convoy/mvp-commit-as-user-via-github-app-user-t/db234b74/gt/maple/72a28820 branch May 12, 2026 14:54
kilo-code-bot Bot added a commit that referenced this pull request May 18, 2026
…serTokenForRepo RPC (#3203)

* feat(github): MVP-2 connect mutation, callback, settings UI, and getUserTokenForRepo RPC

* fix(git-token-service): add missing deps, fix timestamp type, typecheck passes

* fix(web): fix typecheck errors in MVP-2 code

- Use 'expiresAt' in auth narrowing for GitHubAppAuthentication union type
- Fix updated_at to use toISOString() (timestamp mode: 'string')
- Fix access_token_expires_at in user.test.ts to use toISOString()
- Add missing eq import in github-apps-router.test.ts
- Narrow userConnectionStatus.login access with 'login' in guard
- Apply oxfmt formatting

* fix: remove unused imports flagged by code review

---------

Co-authored-by: Toast (gastown) <Toast@gastown.local>
Co-authored-by: Maple (gastown) <Maple@gastown.local>
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.

0 participants