Skip to content

kitenite/halved position#2102

Merged
Kitenite merged 2 commits into
superset-sh:mainfrom
Kitenite:kitenite/halved-position
Mar 6, 2026
Merged

kitenite/halved position#2102
Kitenite merged 2 commits into
superset-sh:mainfrom
Kitenite:kitenite/halved-position

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Mar 6, 2026

Auto create PR on publish branch

Summary by CodeRabbit

  • New Features

    • Enhanced pull request creation workflow with improved support for forked repositories and branch handling.
  • Bug Fixes

    • Improved pull request URL construction and resolution for more reliable PR opening in the browser.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 6, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a68a8e32-f013-486d-8166-a05e8840a836

📥 Commits

Reviewing files that changed from the base of the PR and between 34b80d7 and b8e1072.

📒 Files selected for processing (4)
  • apps/desktop/src/lib/trpc/routers/changes/git-operations.ts
  • apps/desktop/src/lib/trpc/routers/changes/utils/pull-request-url.test.ts
  • apps/desktop/src/lib/trpc/routers/changes/utils/pull-request-url.ts
  • apps/desktop/src/renderer/screens/main/hooks/useCreateOrOpenPR/useCreateOrOpenPR.ts

📝 Walkthrough

Walkthrough

Adds a small auto-create-PR utility with tests, introduces GitHub PR URL utilities and tests, updates backend PR creation flow to build PR compare URLs (handling upstreams/forks), and adjusts frontend components/hooks to use the new utilities and open returned PR URLs.

Changes

Cohort / File(s) Summary
Auto-create PR utility
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/utils/auto-create-pr-after-publish.ts, .../auto-create-pr-after-publish.test.ts, .../index.ts
New shouldAutoCreatePRAfterPublish function and input interface; re-exported from utils index; unit tests covering default branch, existing PR, and no-existing-PR scenarios.
Frontend integration
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx, apps/desktop/src/renderer/screens/main/hooks/useCreateOrOpenPR/useCreateOrOpenPR.ts
ChangesView imports and uses the new utility to compute a local shouldAutoCreatePR flag; PR creation hook captures mutate result and opens result.url in the browser for both initial and retry flows.
PR URL utilities & tests
apps/desktop/src/lib/trpc/routers/changes/utils/pull-request-url.ts, .../pull-request-url.test.ts
New utilities: normalizeGitHubRepoUrl, parseUpstreamRef, buildPullRequestCompareUrl, plus tests validating normalization, upstream parsing, and compare URL construction (forks and branch/name edge cases).
Git operations / PR creation flow
apps/desktop/src/lib/trpc/routers/changes/git-operations.ts
Replaces prior gh-based PR URL extraction with new buildNewPullRequestUrl flow: reads repo metadata, resolves upstream/tracking and merge-base settings, constructs GitHub compare URLs for forks/upstreams, returns URL (or recovers by finding existing open PR); removes gh pr create stdout parsing and adjusts control flow and error handling accordingly.

Sequence Diagram(s)

sequenceDiagram
  actor Client
  participant Router as TRPC Router
  participant Git as Git (local)
  participant RepoMeta as Repo Metadata
  participant Browser

  Client->>Router: request create/open PR
  Router->>Git: get current branch, tracking, config (gh-merge-base)
  Router->>RepoMeta: query remote repo metadata (owner, default branch)
  Router->>Router: parse upstream ref / normalize repo URL
  Router->>Router: build compare URL (baseRepo, baseBranch, headOwner, headBranch)
  Router->>Client: return { success:true, url }
  Client->>Browser: open url in new tab
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through branches, tidy and spry,
Pulled logic into a neat little tie,
URLs stitched for forks and the main,
Tests that hum, no flaky refrain,
A rabbit’s cheer for PRs that fly 🚀

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'kitenite/halved position' is unrelated to the actual changes, which focus on fixing auto PR creation after publishing branches. Update the title to reflect the main change, such as 'fix(desktop): restore PR creation after publish branch' as mentioned in the description.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is minimal and lacks required template sections including Related Issues, Type of Change, Testing, and Additional Notes. Complete the PR description using the template: add Related Issues links, mark Type of Change (appears to be 'New feature'), describe Testing performed, and provide Additional Notes if applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx">

<violation number="1" location="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx:367">
P1: Bug: `hasGitHubRepo` check was dropped when extracting `shouldAutoCreatePRAfterPublish` into a utility. The original inline logic was `hasGitHubRepo && !isDefaultBranch && !hasExistingPR`, but the new function only checks `!hasExistingPR && !isDefaultBranch`. This means workspaces without a GitHub repo will now incorrectly trigger auto-PR creation after a branch publish.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

});
const shouldAutoCreatePRAfterPublish =
hasGitHubRepo && !isDefaultBranch && !hasExistingPR;
const shouldAutoCreatePR = shouldAutoCreatePRAfterPublish({
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 6, 2026

Choose a reason for hiding this comment

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

P1: Bug: hasGitHubRepo check was dropped when extracting shouldAutoCreatePRAfterPublish into a utility. The original inline logic was hasGitHubRepo && !isDefaultBranch && !hasExistingPR, but the new function only checks !hasExistingPR && !isDefaultBranch. This means workspaces without a GitHub repo will now incorrectly trigger auto-PR creation after a branch publish.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx, line 367:

<comment>Bug: `hasGitHubRepo` check was dropped when extracting `shouldAutoCreatePRAfterPublish` into a utility. The original inline logic was `hasGitHubRepo && !isDefaultBranch && !hasExistingPR`, but the new function only checks `!hasExistingPR && !isDefaultBranch`. This means workspaces without a GitHub repo will now incorrectly trigger auto-PR creation after a branch publish.</comment>

<file context>
@@ -364,8 +364,10 @@ export function ChangesView({ onFileOpen, isExpandedView }: ChangesViewProps) {
 	});
-	const shouldAutoCreatePRAfterPublish =
-		hasGitHubRepo && !isDefaultBranch && !hasExistingPR;
+	const shouldAutoCreatePR = shouldAutoCreatePRAfterPublish({
+		hasExistingPR,
+		isDefaultBranch,
</file context>
Suggested change
const shouldAutoCreatePR = shouldAutoCreatePRAfterPublish({
const shouldAutoCreatePR = hasGitHubRepo && shouldAutoCreatePRAfterPublish({
Fix with Cubic

@Kitenite Kitenite merged commit d0163af into superset-sh:main Mar 6, 2026
6 of 7 checks passed
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/lib/trpc/routers/changes/git-operations.ts">

<violation number="1" location="apps/desktop/src/lib/trpc/routers/changes/git-operations.ts:269">
P2: Empty catch block silently swallows errors from multiple git operations (upstream ref resolution and remote URL lookup). At minimum, log a warning with context so fork/upstream debugging is possible.

(Based on your team's feedback about avoiding empty catch blocks that hide failures.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

`branch.${branch}.gh-merge-base`,
]);
return configuredBaseBranch.trim() || null;
} catch {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 6, 2026

Choose a reason for hiding this comment

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

P2: Empty catch block silently swallows errors from multiple git operations (upstream ref resolution and remote URL lookup). At minimum, log a warning with context so fork/upstream debugging is possible.

(Based on your team's feedback about avoiding empty catch blocks that hide failures.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/lib/trpc/routers/changes/git-operations.ts, line 269:

<comment>Empty catch block silently swallows errors from multiple git operations (upstream ref resolution and remote URL lookup). At minimum, log a warning with context so fork/upstream debugging is possible.

(Based on your team's feedback about avoiding empty catch blocks that hide failures.) </comment>

<file context>
@@ -242,22 +242,92 @@ async function findOpenPRByHeadCommit(
+			`branch.${branch}.gh-merge-base`,
+		]);
+		return configuredBaseBranch.trim() || null;
+	} catch {
+		return null;
+	}
</file context>
Fix with Cubic

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