Skip to content

feat: add pr option to changes panel#1954

Merged
Davidknp merged 2 commits into
mainfrom
add-pr-option
May 11, 2026
Merged

feat: add pr option to changes panel#1954
Davidknp merged 2 commits into
mainfrom
add-pr-option

Conversation

@Davidknp
Copy link
Copy Markdown
Collaborator

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 10, 2026

Greptile Summary

This PR adds a "Commit & Create PR" option to the changes panel's split button, wiring it through a new 'commit-pr' commit action in the store and snapshot type. The feature gates the new action behind a canCreatePr flag and falls back gracefully to 'commit-push' when the action is unavailable.

  • commit-card.tsx: Adds doCommitAndCreatePr, a new 'opening-pr' phase, canCreatePr guard, and conditional rendering of the new split-button option.
  • diff-view-store.ts / view-state.ts: Extracts a CommitAction type and adds 'commit-pr' to all relevant unions and the persisted snapshot.

Confidence Score: 3/5

Not safe to merge as-is — the new action will attempt to create a PR from a commit that was never pushed to the remote.

The core happy-path of the new action is broken: after committing, the changes are never pushed, so the modal is handed a branch reference that either doesn't exist on the remote or points to an older commit. The store and snapshot changes are clean and isolated.

src/renderer/features/tasks/diff-view/changes-panel/components/commit-card.tsx — doCommitAndCreatePr and the canCreatePr guard both need attention before this ships.

Important Files Changed

Filename Overview
src/renderer/features/tasks/diff-view/changes-panel/components/commit-card.tsx Adds 'Commit & Create PR' split-button action and an opening-pr phase; missing push step before opening the PR modal, and canCreatePr guard doesn't require the branch to be published.
src/renderer/features/tasks/diff-view/stores/diff-view-store.ts Extracts CommitAction type and threads 'commit-pr' through commitAction, effectiveCommitAction, and setCommitAction. Clean refactor with no issues.
src/shared/view-state.ts Adds 'commit-pr' to the DiffViewSnapshot.commitAction union — a straightforward type update consistent with the store change.

Sequence Diagram

sequenceDiagram
    participant User
    participant CommitCard
    participant GitStore
    participant Remote
    participant PrModal

    User->>CommitCard: "Click "Commit & Create PR""
    CommitCard->>GitStore: stageAllFiles() [if autoStage]
    GitStore-->>CommitCard: staged
    CommitCard->>GitStore: commit(fullMessage)
    GitStore-->>CommitCard: commitResult
    alt commit failed
        CommitCard->>User: "phase = idle (error)"
    else commit succeeded
        CommitCard->>CommitCard: "phase = opening-pr (500ms)"
        CommitCard->>CommitCard: "phase = idle"
        note over CommitCard,Remote: Missing git.push() — branch not on remote yet
        CommitCard->>PrModal: showCreatePrModal(repositoryUrl, branchName)
        PrModal->>Remote: Create PR (branch may not be published)
    end
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/renderer/features/tasks/diff-view/changes-panel/components/commit-card.tsx:89-115
**Missing push before opening PR modal**

`doCommitAndCreatePr` commits locally but never calls `git.push()`, so when `showCreatePrModal` fires, the new commit exists only in the local repo. The PR creation call will either target an old commit on the remote branch or fail entirely because the branch hasn't been published yet. Compare with `doCommitAndPush`, which explicitly awaits `git.push()` and bails out on failure before proceeding.

### Issue 2 of 2
src/renderer/features/tasks/diff-view/changes-panel/components/commit-card.tsx:36-39
`canCreatePr` only checks that a repository URL and branch name are present; it does not verify that the branch has been pushed to the remote. A user on a purely local branch can reach the button, click "Commit & Create PR", and be presented with the modal for a branch the remote has never seen. Consider also requiring `provisioned.workspace.git.isBranchPublished` (the same flag `effectiveCommitAction` consults).

```suggestion
  const canCreatePr =
    Boolean(provisioned.repositoryStore.repositoryUrl) &&
    Boolean(provisioned.taskBranch) &&
    !hasOpenPr &&
    provisioned.workspace.git.isBranchPublished;
```

Reviews (1): Last reviewed commit: "fix: fix fmt" | Re-trigger Greptile

@Davidknp Davidknp merged commit a8a1b83 into main May 11, 2026
1 check passed
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