feat: GitLab repository provider — desktop MRs + cloud dashboard
Superseded by #8235; its separate generated migration prerequisite is #8232.
The replacement is rebuilt on upstream 34ce41f5b2, retains the current GitHub paths, and is submitted as a draft with its validation and remaining acceptance checks stated explicitly. This older generalized-table/backfill design is closed. The original description is preserved below for historical context.
Historical proposal (superseded)
Description
Adds GitLab as a first-class repository provider alongside GitHub, across both halves of the product:
- Desktop — open a workspace on a GitLab repo (gitlab.com or self-managed) and merge requests render natively: PR/MR header, Reviews tab, checks/pipelines, merge, checkout, fork resolution. GitLab SSO login on web/desktop/mobile.
- Cloud — connect a GitLab group from the org dashboard (OAuth or a Group Access Token), sync its projects + merge requests into Postgres, and surface them through the same Electric/tRPC/UI path GitHub uses.
The work is built behind small provider-neutral interfaces, so GitHub behaviour is preserved byte-for-byte — the existing host-service and desktop test suites pass unchanged, and a parity test asserts the GitHub review badge is identical. No new desktop runtime dependencies: GitLab uses glab + the REST API, mirroring how GitHub uses gh + Octokit.
A core design choice: review state is stored verbatim per provider, never reduced. GitHub's review verdict and GitLab's merge-readiness status are different axes, so they're modelled as a provider-discriminated union rather than coerced into a shared enum — GitLab MRs show their own approvals / merge-blocked facts instead of a GitHub-shaped badge.
Related Issues
Closes #2714.
Type of Change
- New feature
- Bug fix
- Documentation
- Refactor
- Other
Testing
- Unit — review-state mappers (the no-reduction model), SSRF guard (loopback / RFC-1918 / link-local / metadata / IPv6), webhook constant-time auth + event routing.
- DB integration (gated; runs in a new CI job against Postgres + the neon-http proxy) — the tRPC GitLab router read path end-to-end, and the GitHub→generic mirror.
- Behaviour preservation — the full existing host-service + desktop suites pass unchanged.
- Live-validated against a real self-managed GitLab instance: connect → sync (projects + MRs with verbatim review facts) → read → disconnect, plus the webhook path.
- History is linear and every commit type-checks in isolation (bisect-green).
Screenshots
GitLab integration dashboard (connected, projects synced from a live group):
Additional Notes
- Migration — the GitHub-specific
github_*tables are generalised into provider-agnosticrepositories/pull_requestsvia expand/contract (migration0059): expand → backfill → dual-write → cut reads over. The old tables + Electric shapes are retained through the client-rollover window; dropping them is a separate, later migration. A maintainer needs to apply0059and run the one-time backfill on deploy. - Security — the GitLab host is user-supplied, so server-side requests are SSRF-guarded at connect and request time (https-only, private/metadata ranges rejected, DNS re-resolved). Tokens are never logged; OAuth scope is minimised to
read_api. - Config — GitLab OAuth needs
GITLAB_CLIENT_ID/GITLAB_CLIENT_SECRET(optional; the connector and login can share one GitLab application). Without it, the token-paste path still works. - Out of scope (follow-ups) — dropping
github_*(the contract migration), token-at-rest encryption (would apply to all providers uniformly), and arbitrary runtime-configured self-managed login (the repo integration already serves arbitrary hosts via token).
Happy to split this into smaller PRs if the maintainers would prefer to review the desktop and cloud halves separately.
Summary by cubic
Adds GitLab as a first-class repo provider across desktop and cloud. Users can open GitLab repos/MRs in desktop, and orgs can connect a GitLab group to sync projects and merge requests without changing existing GitHub behavior. Also fixes a small desktop UI issue by hiding the GitLab approvals chip when no approvals are required.
-
New Features
- Provider-neutral runtime: registry + clients for GitHub and GitLab, host detection, and host-aware creds; all repo reads route through the provider client.
- Review state stored per provider in
review_state_jsonand rendered natively; GitHub badge is unchanged, GitLab shows approvals and merge-blocked chips. - Desktop: native GitLab MR header, reviews, checks, merge, checkout, and fork handling; provider is resolved from the workspace.
- Cloud: connect a GitLab group via OAuth (PKCE,
read_api) or a Group/Personal Access Token; poll-based sync with optional per-project webhooks (constant-time token check); SSRF guard for user-supplied hosts. - Unified DB: new provider-agnostic
repositoriesandpull_requeststables; GitHub data is mirrored (dual-write) on sync/webhooks and a one-time backfill is provided; reads flow through the generic tables. - Sign-in: GitLab social login added on web, desktop, and mobile (optional env-config).
- Tests/CI: unit + DB-backed integration tests for GitLab and the GitHub→generic mirror; CI job runs Postgres-backed tests.
-
Migration
- Apply DB migrations (cloud:
0059_generalize_repos_prs.sql; host-service: addreview_state_json). - Run the one-time backfill to mirror existing GitHub rows into
repositories/pull_requestsbefore relying on generic reads. - Configure env as needed:
GITLAB_CLIENT_ID/GITLAB_CLIENT_SECRET(optional), QStash keys/schedule for poll sync; set per-project GitLab webhooks using the connection’s shared secret if desired. - No breaking change for GitHub;
github_*tables and client shapes remain until a later drop.
- Apply DB migrations (cloud:
Summary by CodeRabbit
-
New Features
- Added GitLab support across sign-in, sign-up, and integrations.
- Introduced a GitLab integrations page with connection status and project listing.
- Added GitLab issue and pull request search, sync, and webhook-driven updates.
-
Bug Fixes
- Improved review status display for GitHub and GitLab pull requests.
- Made repository and pull request data loading work more reliably across supported providers.
-
Chores
- Updated database structures and background jobs to support shared repository data.