Skip to content

refactor(desktop): use gh flows for PR discovery, creation, and checkout#1771

Merged
Kitenite merged 1 commit into
mainfrom
kitenite/pr-sometimes-doesnt-match-remote
Feb 25, 2026
Merged

refactor(desktop): use gh flows for PR discovery, creation, and checkout#1771
Kitenite merged 1 commit into
mainfrom
kitenite/pr-sometimes-doesnt-match-remote

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 25, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Streamlined PR creation workflow by integrating GitHub CLI operations
    • Simplified worktree creation process for improved reliability and performance
    • Optimized repository and branch lookup operations

@Kitenite Kitenite changed the title kitenite/pr sometimes doesnt match remote refactor(desktop): use gh flows for PR discovery, creation, and checkout Feb 25, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 182ed72 and 0f4a129.

📒 Files selected for processing (5)
  • apps/desktop/src/lib/trpc/routers/changes/git-operations.ts
  • apps/desktop/src/lib/trpc/routers/projects/utils/github.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/github/github.ts

📝 Walkthrough

Walkthrough

This pull request refactors PR branch handling by shifting from pre-fetching PR branches to using GitHub CLI's pr checkout command post-creation. Changes simplify owner and PR resolution by using gh CLI queries instead of manual JSON parsing and remove legacy branch-tracking and ancestry-verification logic.

Changes

Cohort / File(s) Summary
GitHub CLI Integration
apps/desktop/src/lib/trpc/routers/changes/git-operations.ts, apps/desktop/src/lib/trpc/routers/projects/utils/github.ts
Transitions from manual GitHub URL construction and JSON parsing to delegating operations to GitHub CLI (gh pr create --web --fill --head, gh repo view --jq). Removes GHRepoOwnerResponseSchema and simplifies owner extraction by capturing stdout directly.
PR Branch Handling Refactor
apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts, apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts, apps/desktop/src/lib/trpc/routers/workspaces/utils/github/github.ts
Removes pre-creation fetchPrBranch logic and introduces post-creation gh pr checkout for fork/head resolution. Eliminates remote-ref computation, divergence checks, and ancestry verification. Simplifies PR lookup to single path via getPRByBranchTracking and adds parsePRResponse for schema-based PR parsing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Worktree Manager
    participant Git Operations
    participant GitHub CLI
    participant Local Repo

    User->>Worktree Manager: Create worktree from PR
    Worktree Manager->>Git Operations: createWorktreeFromPr(prInfo)
    
    alt Branch exists locally
        Git Operations->>Local Repo: Create worktree at local branch
    else Branch does not exist
        Git Operations->>Local Repo: Create detached worktree
    end
    
    Git Operations->>GitHub CLI: gh pr checkout <PR#> <branch>
    GitHub CLI->>Local Repo: Resolve fork/head and check out
    GitHub CLI-->>Git Operations: Success
    
    Git Operations-->>Worktree Manager: Worktree ready
    Worktree Manager-->>User: Complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

🐰 Hops with glee through git refactored,
No more branch-fetch pre-sorted!
GitHub CLI takes the lead,
Post-checkout gives us all we need,
Simpler paths, cleaner flows—
That's how the rabbit code now goes! 🌟

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/pr-sometimes-doesnt-match-remote

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.

@Kitenite Kitenite merged commit 5862892 into main Feb 25, 2026
5 of 6 checks passed
@Kitenite Kitenite deleted the kitenite/pr-sometimes-doesnt-match-remote branch February 25, 2026 06:03
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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