Skip to content

Commit

Permalink
feat: add pr details pane (#8)
Browse files Browse the repository at this point in the history
- Adds a "PR Details" pane which lists the following
	- PR Metadata
	- Description
	- Status checks
	- Issues referenced
	- Files changed
	- Commits
	- Comments
- Adds better navigation for review comments pane
  • Loading branch information
dhth authored Aug 2, 2024
1 parent 2d71d56 commit 216a78b
Show file tree
Hide file tree
Showing 19 changed files with 1,601 additions and 490 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prs
.quickrun
cosign.key
cosign.pub
justfile
debug.log
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

const (
defaultPRCount = 30
maxPRCount = 100
defaultPRCount = 20
maxPRCount = 50
)

func expandTilde(path string) string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/help.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

var (
helpText = `prs lets you stay updated on the PRs you care about without leaving the terminal.
helpText = `prs lets you stay updated on pull requests from the terminal.
Usage: prs [flags]
`
Expand Down
14 changes: 6 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ func Execute() {
}

if config.Query != nil {
if strings.Contains(*config.Query, "is:issue") || strings.Contains(*config.Query, "is: issue") {
die("is:issue cannot be used in the query")
}
if strings.Contains(*config.Query, "type:issue") || strings.Contains(*config.Query, "type: issue") {
die("type:issue cannot be used in the query")
}

if !strings.Contains(*config.Query, "type:pr") && !strings.Contains(*config.Query, "type: pr") {
updatedQuery := fmt.Sprintf("type: pr %s", *config.Query)
config.Query = &updatedQuery
}
}

var mode ui.Mode
Expand All @@ -88,14 +86,14 @@ func Execute() {
}

if mode == ui.QueryMode && config.Query == nil {
sampleQuery := "is:pr repo:neovim/neovim sort:updated-desc"
sampleQuery := "is:pr author:@me sort:updated-desc state:open"
config.Query = &sampleQuery
}

opts := ghapi.ClientOptions{
EnableCache: true,
CacheTTL: time.Minute * 1,
Timeout: 5 * time.Second,
CacheTTL: time.Second * 30,
Timeout: 8 * time.Second,
}

ghClient, err := ghapi.NewGraphQLClient(opts)
Expand Down
4 changes: 4 additions & 0 deletions cosign.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdDBCZ4oEQo3OXXuWYk9rFcJIMLf6
bPuAsJHlkUoXLGqsyQnR9PP/ZyYUgOftnMulcPKtNFf+/GxT7ZQG9S/pBw==
-----END PUBLIC KEY-----
8 changes: 5 additions & 3 deletions internal/utils/assets/gruvbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"h1": {
"prefix": "# ",
"suffix": "",
"color": "#fe8019",
"color": "#d3869b",
"bold": true
},
"h2": {
"prefix": "## ",
"color": "#83a598"
},
"h3": {
"prefix": "",
"prefix": "### ",
"color": "#83a598"
},
"h4": {
Expand All @@ -51,7 +51,9 @@
},
"emph": {
"color": "#83a598",
"italic": true
"italic": true,
"prefix": " ",
"suffix": " "
},
"strong": {
"color": "#fe8019",
Expand Down
64 changes: 41 additions & 23 deletions ui/assets/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,25 @@

## Views

prs has 5 views:
prs has 6 views:

- PR List View
- PR Details View
- PR Timeline List View
- PR Review Comments View
- Repo List View (only applicable when -mode=repos)
- PR Timeline Item Detail View
- Repo List View (only applicable when --mode=repos)
- Help View (this one)

## Keyboard Shortcuts

### General

```text
tab Switch focus between PR List and PR Timeline Pane
1 Switch focus to PR List View
2 Switch focus to PR Timeline List View
3 Switch focus to PR Review Comments View
ctrl+s Switch focus to Repo List View
? Switch focus to Help View
```

### PR List/Timeline List View


```text
ctrl+v Show PR details
ctrl+d Show PR diff
q/esc/ctrl+c go back
Q quit from anywhere
? Open Help View
d Open PR Details View
ctrl+v Show PR details using gh
```

### PR List View
Expand All @@ -42,16 +34,42 @@ prs has 5 views:
🟡 implies REVIEW_REQUIRED
✅ implies APPROVED
ctrl+b Open PR in the browser
⏎/tab/shift+tab/2 Switch focus to PR Timeline View
ctrl+s Switch focus to Repo List View (when --mode=repos)
ctrl+d Show PR diff
ctrl+r Reload PR list
enter Switch focus to PR Timeline View for currently selected PR
enter Show commit/revision range
ctrl+b Open PR in browser
```

### PR Details View

```text
h/N/← Go to previous section
l/n/→ Go to next section
1/2/3... Go to specific section
J/] Go to next PR
K/[ Go to previous PR
d Go back to last view
ctrl+b Open PR in browser
```

### Timeline List View


```text
tab/shift+tab/1 Switch focus to PR List View
⏎/3 Show details for PR timeline item (when applicable)
ctrl+d Show PR diff
ctrl+b Open timeline item in browser
ctrl+r Reload PR timeline
```

### PR Timeline View
### Timeline Item Detail View


```text
1 Switch focus to PR List View
2 Switch focus to PR Timeline List View
ctrl+d Show PR diff
ctrl+b Open timeline item in browser
ctrl+r Reload timeline list
enter Switch focus to Review Comments View for currently selected item
```
17 changes: 11 additions & 6 deletions ui/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ func openURLInBrowser(url string) tea.Cmd {
openCmd = "xdg-open"
}
c := exec.Command(openCmd, url)
return tea.ExecProcess(c, func(err error) tea.Msg {
if err != nil {
return urlOpenedinBrowserMsg{url: url, err: err}
}
return tea.Msg(urlOpenedinBrowserMsg{url: url})
})
err := c.Run()
return func() tea.Msg {
return urlOpenedinBrowserMsg{url: url, err: err}
}
}

func showDiff(repoOwner, repoName string, prNumber int, pager *string) tea.Cmd {
Expand Down Expand Up @@ -113,6 +111,13 @@ func fetchAuthoredPRs(ghClient *ghapi.GraphQLClient, authorLogin string, prCount
}
}

func fetchPRMetadata(ghClient *ghapi.GraphQLClient, repoOwner, repoName string, prNumber int) tea.Cmd {
return func() tea.Msg {
metadata, err := getPRMetadata(ghClient, repoOwner, repoName, prNumber)
return prMetadataFetchedMsg{repoOwner, repoName, prNumber, metadata, err}
}
}

func fetchPRTLItems(ghClient *ghapi.GraphQLClient, repoOwner string, repoName string, prNumber int, tlItemsCount int, setItems bool) tea.Cmd {
return func() tea.Msg {
prTLItems, err := getPRTLData(ghClient, repoOwner, repoName, prNumber, tlItemsCount)
Expand Down
Loading

0 comments on commit 216a78b

Please sign in to comment.