Skip to content

[Bug]: GitLab branch review lookup picks a merged MR, so long-lived branches show a stale MR #39554

Closed

Description

@CharlieZi

Summary

When a workspace is on a long-lived branch such as develop and there are no open MRs from that branch, Orca's GitLab hosted-review lookup picks the most recently updated MR for the branch regardless of its state. The workspace card and the review detail pane then show an old, already-merged MR (with its old pipeline and checks) instead of showing no review.

GitHub behaves differently: the branch lookup only considers open PRs unless an explicit linked/fallback PR number is supplied.

What happened?

  • Workspace branch: develop (repository default branch is main)
  • There are no open MRs whose source branch is develop
  • The last MR ever opened from develop is old and already merged
  • Orca shows that MR's title, MERGED state, its last-updated timestamp and its old pipeline/check list on the workspace card and in the review pane
  • It is not a stale local link: orca worktree show reports linkedGitLabMR: null and linkedItems: [], the profile state contains no reference to that MR, and clearing/unlinking does not change the display. The value is recomputed from the current branch on every refresh.

How to reproduce

  1. On a self-hosted GitLab repository, merge an MR whose source branch is a long-lived branch (e.g. develop), then never open another MR from that branch.
  2. Check out that long-lived branch in an Orca workspace.
  3. Focus the workspace. Orca auto-attaches the most recent MR from that branch even though it is merged, and shows that MR's title, merged state and old pipeline on the card and in the review pane.

Root cause (Orca 1.4.253)

  • In orcad-server.js, the GitLab hosted-review provider's getReviewForBranch calls s7a(), which issues:
    GET projects/:id/merge_requests?source_branch=<branch>&order_by=updated_at&sort=desc&per_page=1&with_merge_status_recheck=true
    There is no state parameter, so GitLab returns merged/closed MRs too (its default is all states).
  • The only merged/closed suppression is hz(), which hides such an MR only when the worktree branch equals the repository's default branch (resolved from refs/remotes/origin/HEAD). For a long-lived branch that is not the default branch, the stale merged MR is kept.

Suggested fix

  • Add state=opened to the GitLab branch lookup, aligning it with the GitHub path. Merged reviews should only appear when an explicit linked/fallback MR number is supplied (or via a linked work item).
  • Alternatively, extend hz() so merged/closed MRs are not auto-attached to long-lived branches in general.

Environment

  • Orca 1.4.253 (latest release at filing)
  • macOS
  • Self-hosted GitLab, glab authenticated

Activity

  1. mahedi-emon commented on Nov 7, 2026

    @mahedi-emon
    Contributor

    I traced this in src/main/gitlab/merge-request-lookup.ts. Besides the merged-MR case, per_page=1 sorted by updated_at also lets a newer closed/merged MR hide an open one on the same branch. Rather than state=opened (which would also hide a feature branch’s just-merged MR), I matched the GitHub rule: prefer an open MR, and keep a merged branch match only while the worktree HEAD equals that MR’s head. Opening a PR with tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions