Skip to content

feat: GitLab merge request review support#364

Merged
backnotprop merged 3 commits intomainfrom
feat/cr-gitlab
Mar 22, 2026
Merged

feat: GitLab merge request review support#364
backnotprop merged 3 commits intomainfrom
feat/cr-gitlab

Conversation

@backnotprop
Copy link
Owner

Summary

  • Full GitLab MR review parity with existing GitHub PR review
  • Auto-detects platform from URL — github.com routes to gh, any /-/merge_requests/ URL routes to glab
  • Self-hosted GitLab instances supported via --hostname flag
  • Platform-aware UI throughout: labels (PR/MR), icons (GitHub/GitLab), number prefixes (#/!), completion messages

Architecture

  • Extracted GitHub logic into packages/shared/pr-github.ts
  • New packages/shared/pr-gitlab.ts with full glab CLI implementation
  • Widened PRRef/PRMetadata to discriminated unions ("github" | "gitlab")
  • Dispatch functions in pr-provider.ts route by platform
  • Label helpers (getPlatformLabel, getMRLabel, getMRNumberLabel, getDisplayRepo) accept both ref and metadata types

GitLab-specific handling

  • glab mr diff outputs bare diffs — normalized to standard diff --git format
  • glab api requires explicit Content-Type: application/json header for --input -
  • glab has no --jq flag — parse full JSON responses instead
  • Review submission uses 3 separate API calls (note + discussions + approve) vs GitHub's single atomic review endpoint
  • Inline comments submitted in parallel with Promise.allSettled for partial failure resilience
  • Defensive JSON parsing on all context API responses (notes, approvals, pipelines, issues)

Files changed

File Change
packages/shared/pr-provider.ts Widened types, dispatch functions, label helpers
packages/shared/pr-github.ts New — extracted GitHub implementation
packages/shared/pr-gitlab.ts New — full GitLab implementation
packages/server/pr.ts Updated Bun wrapper for dispatching
packages/server/review.ts Platform-agnostic endpoint handling
apps/hook/server/index.ts Platform-aware error messages and status
apps/opencode-plugin/commands.ts Same platform-aware updates
packages/review-editor/App.tsx Platform-aware UI (labels, icons, destination toggle)
packages/review-editor/utils/exportFeedback.ts Platform-aware export headers
packages/ui/components/GitLabIcon.tsx New — GitLab tanuki SVG icon

Test plan

  • All 267 existing tests pass
  • GitHub PR review regression tested (feat: bidirectional AI conversation, context persistence, and approve-with-notes #317)
  • GitLab MR review tested (backnotprop1-group/backnotprop1-project!1)
  • Inline comments post to correct lines on GitLab
  • Multi-line range comments work
  • Platform detection from URL works for both
  • Diff normalization renders multi-file GitLab diffs correctly
  • Completion overlay shows correct platform name

Add full GitLab MR review parity with existing GitHub PR review:

- Auto-detect platform from URL (github.com vs any GitLab host)
- Extract GitHub logic into pr-github.ts, new pr-gitlab.ts implementation
- Widen PRRef/PRMetadata to discriminated unions for type safety
- Dispatch functions route to correct platform implementation
- Platform-aware UI labels (PR/MR, #/!, GitHub/GitLab icons)
- Self-hosted GitLab support via --hostname flag
- Normalize glab diff output to standard git format
- Handle glab CLI differences (no --jq, Content-Type header for --input)
- Defensive JSON parsing for GitLab context API responses

Tested against gitlab.com with inline comments, multi-line ranges,
approval, and PR context tabs (summary, comments, checks).

For provenance purposes, this commit was AI assisted.
- Map GitLab job statuses to UI-expected enums (failed→FAILURE, canceled→NEUTRAL)
- Map GitLab detailed_merge_status to CLEAN/BLOCKED/BEHIND/DIRTY/UNKNOWN
- Fix false approval state on repos without required approvers
- Add shared encodeApiFilePath helper used by both GitHub and GitLab

For provenance purposes, this commit was AI assisted.
- Use shared --panel-header-h CSS variable for consistent header heights
  across file tree search, file header, and annotations panel
- Update GitLab icon to use official tanuki SVG paths with currentColor
- Replace solid primary fill on active file tree items with 30% tinted
  background for better readability and semantic color preservation

For provenance purposes, this commit was AI assisted.
@backnotprop backnotprop merged commit 40002e6 into main Mar 22, 2026
5 checks passed
@backnotprop backnotprop deleted the feat/cr-gitlab branch March 22, 2026 17:23
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