Skip to content

feat(host-service,desktop): GitLab MR discussions, job logs, PR pane and workspace from MR - #8724

Draft
geraudloup wants to merge 14 commits into
ParadevAI:mainfrom
geraudloup:feat/gitlab-glab-review
Draft

geraudloup wants to merge 14 commits into
ParadevAI:mainfrom
geraudloup:feat/gitlab-glab-review

Conversation

@geraudloup

@geraudloup geraudloup commented Oct 21, 2026 •

Copy link
Copy Markdown

What & why

Part of #6445. Follow-up to #8719 and stacked on it: only the last commit is new (compare).

GitLab merge requests get the review features GitHub PRs have, through the same glab calls as #8719:

  • Discussions: in the Review tab and the PR pane. Reading maps diff notes to review threads and other notes to conversation. Reply and resolve/unresolve work too.
  • CI job logs: "Copy job logs" works for a failed GitLab job (glab ci trace), only for jobs of the MR's own project.
  • PR pane:
    • GitLab MR links open in the pane, with content, diff (glab mr diff --raw), merge, close/reopen and ready/draft.
    • A GitLab ref keeps its host in the repo name, so the GitHub fallbacks never read it as a GitHub repo.
    • Writes reuse the GitHub path's sync-after-write.
  • Workspace from an MR:
    • The PR picker searches the project's MRs: by text, 12, !12, or the MR URL.
    • Checkout reads the branch and head from glab mr view.

+454/−13 source lines, +78 test lines.

Not covered:

  • MRs from forks (checkout refuses them).
  • The pane's commit list and +/− line counts.
  • GitLab projects inside a multi-project PR search.

How I tested it

  • Unit tests: the discussion mapping, and GitLab MR links opening the pane. GitHub-path tests run unchanged; their contexts now state "not GitLab".
  • Read paths run live against a self-managed GitLab: threads, content, search, checkout metadata, job log.
  • Write commands checked against a local fake GitLab API: reply, resolve, close/reopen, ready/draft, merge with a squash message.
  • bun test in packages/host-service: 2609 pass. bun run lint is clean.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint passes. bun run typecheck reports no errors in the changed files; the local desktop check fails on unrelated UI-library types.
  • "Allow edits from maintainers" is checked on fork PRs

Summary by cubic

GitLab merge requests get the review features GitHub PRs already have: status and approval display, CI job log copying, discussions with reply and resolve, the PR pane, and workspace creation from an MR. All calls go through the user's own glab CLI, so self-managed instances work without extra setup. GitLab repos keep their host in the repo name so they can never be read as a GitHub repo.

  • A linked MR shows its state and its head pipeline's jobs as checks; merge, create, close/reopen, and ready/draft run through glab.
  • An MR is approved only when GitLab reports approved with at least one approver; a blocking manual job stays a pending check and an optional one counts as skipped.
  • The PR picker searches one GitLab project's MRs by text, !12, 12, or the MR URL; checkout reads branch and head via glab mr view. Fork MRs are refused.
  • "Copy job logs" works only for failed jobs of the MR's own project (glab ci trace); the pane's commit list and line counts are not shown for GitLab.
  • The "View on GitHub" labels in the PR menu and card now read "Open in browser".
  • GitLab hosts are detected by asking glab whether it knows the host (confirmed hosts are remembered; unknown ones are re-asked at each refresh), not by parsing the URL.

Written for commit d311dd4. Summary will update on new commits.

View guided diff

A workspace whose remote is on a GitLab host now shows its merge request
the way a GitHub workspace shows its pull request: state, draft, merged,
the head pipeline as its check, and "review required" when approval is
missing. Create PR opens a merge request with `glab mr create`.

Every GitLab call is a `glab` subprocess, like the `gh` path, so it uses
the user's own `glab auth login`. Superset passes `-R https://<host>/<path>`
built from the remote, and glab maps that host to its API host itself,
so self-managed instances and SSH host aliases work without any host
settings in Superset.

- A host is GitLab when its name contains "gitlab"; other hosts never
  spawn glab.
- The GitLab identity is not written to the project row: avatars, clone
  matching and the Octokit procedures read projects.repo* as GitHub.
- Merge and Ready for review stay hidden for non-GitHub PRs. They call
  GitHub by owner/repo/number, which a GitLab MR can share with a GitHub
  mirror of the same project.
Merge and Ready for review now work for a linked GitLab MR: the github
router runs `glab mr merge` (squash and rebase map to their flags,
auto-merge off so the result matches GitHub's immediate merge) and
`glab mr update --ready`.

The callers send owner/repo/number only, so the host picks GitLab when a
linked GitLab MR has that identity, and refuses when a linked GitHub PR
has it too: a GitLab project and its GitHub mirror share owner/repo, and
a guess could merge the wrong one. The lookup reads the runtime's own
pull_requests rows (the rows the PR chip shows), next to
findPullRequestRow, so github.ts reads no snapshot fields. This replaces
the renderer guard that hid both actions for GitLab MRs, and also covers
mobile.
A GitLab owner now carries its host (`gitlab.example.com/group`, with the
HTTPS port when the remote names one; an SSH port is not the web port):

- MRs of two GitLab instances with the same path and number no longer
  share a cache entry or a pull_requests row.
- An HTTPS remote on a non-default port keeps its port in the glab URL.
- Merge and Ready for review pick GitLab when the owner has a slash,
  which a GitHub owner never has. No stored row is consulted, so a GitHub
  PR can never be routed to glab, and the runtime lookup is gone.

Also from review:
- A merge request without a string sha is skipped instead of being
  stored with headSha "undefined"; a pipeline without a URL has none.
- A failed refresh after creating an MR is logged, as on the GitHub path.
- The PR menu and card say "Open in browser" (an existing catalog
  string) instead of "View on GitHub".

Files that now hold GitLab code are renamed to github-gitlab-*. The
`@superset/shared/github-remote` export keeps its name so its importers
do not change.
Renaming github-remote.ts to github-gitlab-remote.ts showed as a full
delete and re-add, since the GitLab part nearly doubles that small file.
The GitLab parser now lives in its own gitlab-remote.ts (exported as
`@superset/shared/gitlab-remote`), so github-remote.ts and its importers
stay untouched and the change is a plain addition.
…ab errors

- Each job of the MR's head pipeline is a check (`glab ci get`), as each
  GitHub check run is. An allowed-to-fail job counts as neutral, and a
  manual job as skipped, so neither keeps the MR red or pending.
- An MR with at least one approval shows as approved (approvals API,
  reached through the MR's own web host and project id). "Review
  required" still comes from detailed_merge_status.
- execGlab rejects with glab's own reason (its stderr) instead of
  execFile's "Command failed: glab ..." line, which repeated the whole
  command, MR description included. Create, merge and ready failures now
  read like the GitHub path's.
A remote is GitLab when glab has a config entry for its host, not when
the host name contains "gitlab": self-managed instances on any host name
(git.company.com) now link their merge requests.

The check is `glab config get api_host --host <host>`: a local config
read, no network. Each answer is cached per host for five minutes, so a
refresh spawns nothing for a host seen recently, and a later `glab auth
login` is picked up. Only remotes that are not GitHub are checked.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…en GitLab does

- A manual job that may not fail blocks its pipeline, so it stays a
  pending check; only an optional manual job counts as skipped.
- "Approved" needs GitLab's own `approved: true` as well as an approver:
  an approval can exist while required rules are still unmet.
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from 39b8611 to f578c2a Compare October 21, 2026 13:26
…ts gaps

- The PR head and details lookups pick glab or GitHub inside one
  cachedGitHubFetch call instead of repeating it per provider.
- Comments say why a fork MR is never linked (GitLab names the source
  project by id only), why "approved" also needs an approver (GitLab
  reports `approved` when no approval rule applies), and that GitLab has
  no case-drift sweep yet (its source-branch filter is case-sensitive).
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from f578c2a to 352db5b Compare October 21, 2026 13:51
- execGlab moves to its own exec-glab.ts with an ExecGlab type, so GitLab
  code no longer imports it from exec-gh. exec-gh exports the shared
  execCli runner.
- normalizeMergeRequest and toJobCheck become normalizeGitLabMergeRequest
  and toGitLabJobCheck.
The runtime keeps a set of hosts glab has confirmed instead of
re-checking every host every 5 minutes. An unknown host is asked again
at each refresh, one local `glab config get`, so a host added with
`glab auth login` shows at the next refresh without a restart.
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from 352db5b to ed4279f Compare October 21, 2026 14:30
Routers now ask the runtime only for a GitLab identity, through
getGitLabRepository. getProjectRepository returns the GitHub identity
saved on the project row, which routers must not use: resolveGithubRepo
reads the remote as it is now. A GitLab identity is never saved, so it is
always read fresh.
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from ed4279f to daeb64a Compare October 21, 2026 15:05
normalizePullRequest, toCheckRunNode and mapReviewDecision and their
GitLab counterparts build the same shapes, so a change to one usually
needs the other. Each now names its twin.
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from daeb64a to cf17302 Compare October 21, 2026 16:53
- The two runtime tests share one gitlabProject helper and seed the
  workspace upstream, as the GitHub refresh tests do, instead of mocking
  readWorkspaceRefs.
- glab answers come from one table keyed by subcommand.
- The optional failed job had no effect on the assertion and is gone.
- Shorter example hosts keep each remote-parser case on one line.
…and workspace from MR

Builds on the GitLab support in ParadevAI#8719, through the same glab calls:

- Discussions: the Review tab and the PR pane read an MR's discussions
  (diff notes as review threads, other notes as conversation), reply to
  a thread and resolve or reopen it.
- Job logs: "Copy job logs" works for a failed GitLab CI job
  (`glab ci trace`), for jobs of the MR's own project only.
- PR pane: a GitLab MR link opens in Superset's PR pane. Its ref keeps
  the host in the repo name, so the GitHub fallbacks never read it as a
  GitHub repo. Content, diff (`glab mr diff --raw`), merge, close and
  reopen, and ready or draft all run through glab. Writes reuse the
  GitHub path's sync, whose row lookup no longer needs the provider: a
  GitLab owner carries its host and never matches a GitHub one.
- Workspace from an MR: the PR picker searches one GitLab project's MRs
  (text, `!12`, `12` or the MR URL), and checkout reads the MR's branch
  and head with `glab mr view`. MRs from forks are refused for now.
@geraudloup
geraudloup force-pushed the feat/gitlab-glab-review branch from cf17302 to d311dd4 Compare October 21, 2026 17:00

This branch has not been deployed

No deployments
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