Repository navigation
Add external review link to source control branch panel - #7461
Conversation
Add a button to the branch compare header that opens the review or comparison page directly in the browser. Supports generating comparison and PR/MR creation URLs for GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea.
📝 WalkthroughWalkthroughThis PR adds provider-aware manual review URL generation for source control. It introduces parsing helpers for remotes and refs, a URL builder that handles GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea, and SourceControl state that computes and forwards the URL into the header toolbar. The branch context row can now render a browser-opening review link, and locale files add the corresponding string. en.json also updates SshTargetForm help text. Sequence Diagram(s)sequenceDiagram
participant SourceControl
participant buildSourceControlManualReviewUrlFromContext
participant SourceControlHeaderToolbar
participant SourceControlBranchContextRow
participant ManualReviewLinkButton
participant ShellAPI
SourceControl->>buildSourceControlManualReviewUrlFromContext: derive manualReviewUrl from repo and compare context
buildSourceControlManualReviewUrlFromContext-->>SourceControl: manualReviewUrl or null
SourceControl->>SourceControlHeaderToolbar: manualReviewUrl
SourceControlHeaderToolbar->>SourceControlBranchContextRow: manualReviewUrl
SourceControlBranchContextRow->>ManualReviewLinkButton: render when url is present
ManualReviewLinkButton->>ShellAPI: openUrl(manualReviewUrl)
Related Issues: Unable to determine from the provided information. Related PRs: Unable to determine from the provided information. Suggested labels: source-control, i18n, enhancement Suggested reviewers: Unable to determine from the provided information. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
⚔️ Resolve 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. Comment |
Simplify the SourceControl component by moving the logic for resolving the manual review provider and constructing its URL into dedicated utility functions. Add unit tests for the extracted resolution and URL building logic to ensure correct fallback and maintain correctness and ease verification of its correctness.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts (1)
22-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate field list between
SourceControlManualReviewContextandresolveSourceControlManualReviewProvider's parameter type.The same 8 optional fields (
hostedReviewProvider,hostedReviewCreationProvider,linkedGitHubPR,fallbackGitHubPRNumber,linkedGitLabMR,linkedBitbucketPR,linkedAzureDevOpsPR,linkedGiteaPR) are declared twice. Extracting a shared type avoids the two definitions silently drifting apart if a new linked-provider field is added later.♻️ Suggested extraction
+export type ManualReviewProviderHints = { + hostedReviewProvider?: HostedReviewProvider | null + hostedReviewCreationProvider?: HostedReviewProvider | null + linkedGitHubPR?: number | null + fallbackGitHubPRNumber?: number | null + linkedGitLabMR?: number | null + linkedBitbucketPR?: number | null + linkedAzureDevOpsPR?: number | null + linkedGiteaPR?: number | null +} + -export type SourceControlManualReviewContext = ManualReviewUrlInput & { - hostedReviewProvider?: HostedReviewProvider | null - hostedReviewCreationProvider?: HostedReviewProvider | null - linkedGitHubPR?: number | null - fallbackGitHubPRNumber?: number | null - linkedGitLabMR?: number | null - linkedBitbucketPR?: number | null - linkedAzureDevOpsPR?: number | null - linkedGiteaPR?: number | null -} +export type SourceControlManualReviewContext = ManualReviewUrlInput & ManualReviewProviderHints -export function resolveSourceControlManualReviewProvider(input: { - hostedReviewProvider?: HostedReviewProvider | null - hostedReviewCreationProvider?: HostedReviewProvider | null - linkedGitHubPR?: number | null - fallbackGitHubPRNumber?: number | null - linkedGitLabMR?: number | null - linkedBitbucketPR?: number | null - linkedAzureDevOpsPR?: number | null - linkedGiteaPR?: number | null -}): HostedReviewProvider | null { +export function resolveSourceControlManualReviewProvider( + input: ManualReviewProviderHints +): HostedReviewProvider | null {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6d1fa907-ae5f-4781-8eef-7b614cd6d898
📒 Files selected for processing (4)
src/renderer/src/components/right-sidebar/SourceControl.tsxsrc/renderer/src/components/right-sidebar/source-control-manual-review-url.test.tssrc/renderer/src/components/right-sidebar/source-control-manual-review-url.tssrc/renderer/src/components/right-sidebar/source-control-remote-repo.ts
* feat: add external review link to source control branch panel Add a button to the branch compare header that opens the review or comparison page directly in the browser. Supports generating comparison and PR/MR creation URLs for GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea. * Extract manual review provider resolution to utility module Simplify the SourceControl component by moving the logic for resolving the manual review provider and constructing its URL into dedicated utility functions. Add unit tests for the extracted resolution and URL building logic to ensure correct fallback and maintain correctness and ease verification of its correctness.
Summary
Adds an external review link button (
ManualReviewLinkButton) to the source control branch context panel in the right sidebar. When a repository remote and branch match a supported provider (GitHub, GitLab, Bitbucket, Azure DevOps, or Gitea), this button allows users to open the branch comparison or pull/merge request creation page directly in their default browser.Screenshots
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildUnit tests were explicitly added and verified:
source-control-manual-review-url.test.tscovers URL generation for GitHub (including forks and slash-containing branches), GitLab, Bitbucket, Azure DevOps, and Gitea, along with branch compare fallback and suppression rules.source-control-branch-context-row.test.tsxtests the rendering of the review link button.AI Review Report
Summarized review results:
window.api.shell.openUrloperates identically across all platforms, and URL builders use platform-agnostic string/regex operations. Localization keys have been added for English, Spanish, Japanese, Korean, and Chinese.Security Audit
Summary of security audit:
window.api.shell.openUrlto open validated comparison URLs. The parser limits schemes to standard HTTP/HTTPS protocols to prevent arbitrary protocol handler injection.Notes
None.