feat: add pr option to changes panel#1954
Conversation
Greptile SummaryThis PR adds a "Commit & Create PR" option to the changes panel's split button, wiring it through a new
Confidence Score: 3/5Not 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.
|
| 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
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
No description provided.