Improve "Create MR" action: show "View MR" when a merge request already exists

Description

Currently, the VS Code GitLab extension always shows a “Create MR” action, even when an open merge request already exists for the current branch.

It would be useful if the extension could:

  • Detect whether an open MR exists for the current branch
  • Show “View MR” instead of “Create MR” when applicable
  • Fall back to “Create MR” only when no MR exists

Why this helps

  • Avoids accidental duplicate merge requests
  • Matches common GitLab workflow (one MR per branch)
  • Improves UX by making the primary action context-aware
  • Saves time when frequently switching branches

Technical notes

The GitLab API already supports this via:

GET /projects/:id/merge_requests?source_branch=<branch>&state=opened

The extension already:

  • Knows the current branch
  • Has project context
  • Can open MRs in the browser

This could be implemented by conditionally rendering or swapping the command based on API results (with caching to avoid excessive calls)

Expected behavior

  • If an open MR exists for the current branch → show “View MR”
  • If no MR exists → show “Create MR”
  • Clicking “View MR” opens the MR in browser (or extension view)
Assignee Loading
Time tracking Loading