Skip to content

Add external review link to source control branch panel - #7461

Merged
AmethystLiang merged 3 commits into
mainfrom
enable-view-log-in-agent-session
Jul 6, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
enable-view-log-in-agent-session

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

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

  • Compact external link icon button next to the branch compare status.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Unit tests were explicitly added and verified:

  • source-control-manual-review-url.test.ts covers 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.tsx tests the rendering of the review link button.

AI Review Report

Summarized review results:

  • Verified correctness of the URL builder logic for all supported providers under various edge cases (forks, matching push targets, local branch with differing remote tracking branch names).
  • Explicitly checked cross-platform compatibility for macOS, Linux, and Windows. The IPC call window.api.shell.openUrl operates 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:

  • Input Handling: The URL parsing safely processes remote SSH and HTTPS paths, cleaning git prefixes and avoiding malicious path traversal. Segment-level encoding is applied to branch names and owners.
  • Command Execution & IPC: Employs window.api.shell.openUrl to open validated comparison URLs. The parser limits schemes to standard HTTP/HTTPS protocols to prevent arbitrary protocol handler injection.
  • Secrets: No credentials, tokens, or auth headers are requested, processed, or sent.

Notes

None.

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.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This 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)
Loading

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)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main user-visible change: adding an external review link to the source control branch panel.
Description check ✅ Passed The description follows the template and covers summary, screenshots, testing, AI review, security, and notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch enable-view-log-in-agent-session

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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts (1)

22-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate field list between SourceControlManualReviewContext and resolveSourceControlManualReviewProvider'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

📥 Commits

Reviewing files that changed from the base of the PR and between 8cbb928 and c1dc327.

📒 Files selected for processing (4)
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/source-control-manual-review-url.test.ts
  • src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts
  • src/renderer/src/components/right-sidebar/source-control-remote-repo.ts

@AmethystLiang
AmethystLiang merged commit c49a14f into main Jul 6, 2026
1 check passed
@n-leezy n-leezy mentioned this pull request Jul 8, 2026
5 tasks done
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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.
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