Skip to content

Open a pull request from the TUI#256

Merged
jongio merged 2 commits into
mainfrom
jongio-idea-github-create-pr
Jul 7, 2026
Merged

Open a pull request from the TUI#256
jongio merged 2 commits into
mainfrom
jongio-idea-github-create-pr

Conversation

@jongio

@jongio jongio commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Closes #249

What changed

Wires the existing github.Client.CreatePR into the GitHub panel so you can open a pull request without leaving grut.

Pressing n on the Pull Requests tab starts a multi-step form:

  1. Head branch, prefilled with the current local branch (editable)
  2. Base branch, prefilled with the repository default branch (editable)
  3. Title, required
  4. Body, optional

On submit the PR is created through CreatePR, the list refreshes, and the new PR is selected. The filter resets to All so the new PR is guaranteed visible, and it is inserted optimistically for instant feedback ahead of the server refresh.

Guards

  • No GitHub client: no-op.
  • No current branch detected: warning notification, flow does not start.
  • Current branch not pushed (no upstream and no matching remote branch): warning notification telling you to push first.
  • Head equals base: rejected with a message.
  • Empty title: rejected with a message.
  • Escape cancels at any step and clears the in-progress draft.
  • API failure: clear error notification, nothing inserted.

The current branch is read from the existing git client branch list, which carries local branches even while the panel is in GitHub mode. Base falls back to main when the default branch is unknown.

Keybindings and docs

  • Added the n binding to the github section of internal/keybindings/keybindings.json.
  • Regenerated docs/keybindings.md. The help overlay reads the JSON directly.

How tested

  • go build ./... after every change, all clean.
  • go test ./...: full suite passes, including 16 new tests in internal/panels/gitinfo/gitinfo_test.go covering prefill, default-branch fallback, the no-branch/unpushed/nil-client guards, empty-title and head-equals-base rejection, the full create-then-refresh flow with request-content assertions, empty-body omission, error propagation, cancel reset, pending-reselect consumption, and the n key entry point. Tests use the existing mockGHClientFull.
  • go vet ./...: clean.
  • gofmt: clean.

No new dependencies. Single panel touched (internal/panels/gitinfo/) plus the keybinding registry and generated docs.

Wire the existing github.Client.CreatePR into the GitHub panel. Pressing n
on the Pull Requests tab starts a multi-step form: head branch (prefilled
with the current local branch), base branch (prefilled with the repo default
branch), a required title, and an optional body. On submit the PR is created,
the list refreshes, and the new PR is selected.

Guards: no-op without a GitHub client, warn when there is no current branch
or the branch is not pushed, reject head equal to base, and reject an empty
title. API failures surface as an error notification.

Register the n binding in keybindings.json and regenerate docs/keybindings.md.
Add unit tests covering prefill, the guard cases, the create-then-refresh
flow, request contents, and error paths using the existing GitHub client mock.

Closes #249

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 3, 2026
@jongio jongio self-assigned this Jul 3, 2026
# Conflicts:
#	docs/keybindings.md
#	internal/keybindings/keybindings.json
#	internal/panels/gitinfo/gitinfo.go
#	internal/panels/gitinfo/gitinfo_github.go
#	internal/panels/gitinfo/gitinfo_modal_handlers.go
#	internal/panels/gitinfo/gitinfo_test.go
@jongio jongio merged commit be8730b into main Jul 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open a pull request from the TUI

1 participant