add reviewer assigning
This commit is contained in:
56
tui.go
56
tui.go
@@ -65,8 +65,10 @@ type threadRepliedMsg struct {
|
||||
}
|
||||
|
||||
type pullRequestUpdatedMsg struct {
|
||||
metadata PullRequestMetadata
|
||||
err error
|
||||
metadata PullRequestMetadata
|
||||
people PullRequestPeople
|
||||
peopleSaved bool
|
||||
err error
|
||||
}
|
||||
|
||||
type autoMergeUpdatedMsg struct {
|
||||
@@ -103,6 +105,12 @@ type branchesLoadedMsg struct {
|
||||
err error
|
||||
}
|
||||
|
||||
type repositoryUsersLoadedMsg struct {
|
||||
owner, repo string
|
||||
users []RepositoryUser
|
||||
err error
|
||||
}
|
||||
|
||||
type detailsEnrichedMsg struct {
|
||||
enrichment PRDetailsEnrichment
|
||||
requestID uint64
|
||||
@@ -146,12 +154,16 @@ type App struct {
|
||||
autoMergeTarget bool
|
||||
mergeMethod string
|
||||
prEditField int
|
||||
prEditEditors [3]textEditor
|
||||
prEditEditors [prEditFieldCount]textEditor
|
||||
prEditOriginal PullRequestMetadata
|
||||
prEditBranches []RepositoryBranch
|
||||
prEditBranchesLoading bool
|
||||
prEditBranchesError string
|
||||
prEditBranchIndex int
|
||||
prEditUsers []RepositoryUser
|
||||
prEditUsersLoading bool
|
||||
prEditUsersError string
|
||||
prEditUserIndex int
|
||||
cursorOutput *terminalCursorOutput
|
||||
|
||||
foldResolved bool
|
||||
@@ -871,6 +883,22 @@ func (m App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.prEditBranchesError = ""
|
||||
m.prEditBranchIndex = 0
|
||||
m.ensurePREditCursorVisible()
|
||||
case repositoryUsersLoadedMsg:
|
||||
if m.writeMode != writePREdit ||
|
||||
msg.owner != m.details.Owner || msg.repo != m.details.Repository {
|
||||
return m, nil
|
||||
}
|
||||
m.prEditUsersLoading = false
|
||||
if msg.err != nil {
|
||||
m.prEditUsersError = msg.err.Error()
|
||||
m.recordHealth("repository user recommendations", healthWarning, msg.err.Error())
|
||||
m.ensurePREditCursorVisible()
|
||||
return m, nil
|
||||
}
|
||||
m.prEditUsers = msg.users
|
||||
m.prEditUsersError = ""
|
||||
m.prEditUserIndex = 0
|
||||
m.ensurePREditCursorVisible()
|
||||
case threadResolvedMsg:
|
||||
m.writeMode = writeNone
|
||||
if msg.err != nil {
|
||||
@@ -960,6 +988,11 @@ func (m App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case pullRequestUpdatedMsg:
|
||||
if msg.err != nil {
|
||||
m.writeMode = writePREdit
|
||||
if msg.peopleSaved {
|
||||
m.applyPREditPeople(msg.people)
|
||||
m.prEditOriginal.Reviewers = slices.Clone(msg.people.Reviewers)
|
||||
m.prEditOriginal.Assignees = slices.Clone(msg.people.Assignees)
|
||||
}
|
||||
m.err = fmt.Errorf("update pull request: %w", msg.err)
|
||||
m.recordHealth("PR metadata update", healthError, msg.err.Error())
|
||||
m.scroll = 0
|
||||
@@ -969,6 +1002,10 @@ func (m App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.details.Title = msg.metadata.Title
|
||||
m.details.Body = msg.metadata.Body
|
||||
m.details.BaseRef = msg.metadata.BaseRef
|
||||
m.applyPREditPeople(PullRequestPeople{
|
||||
Reviewers: msg.metadata.Reviewers,
|
||||
Assignees: msg.metadata.Assignees,
|
||||
})
|
||||
m.details.Mergeable = msg.metadata.Mergeable
|
||||
m.details.MergeState = msg.metadata.MergeState
|
||||
m.details.UpdatedAt = msg.metadata.UpdatedAt
|
||||
@@ -1885,7 +1922,12 @@ func (m App) viewWritePopup() string {
|
||||
}
|
||||
maxLines := max(3, m.height-4)
|
||||
if len(lines) > maxLines {
|
||||
lines = lines[len(lines)-maxLines:]
|
||||
if m.writeMode == writePREditConfirm {
|
||||
start := clamp(m.helpScroll, 0, len(lines)-maxLines)
|
||||
lines = lines[start : start+maxLines]
|
||||
} else {
|
||||
lines = lines[len(lines)-maxLines:]
|
||||
}
|
||||
}
|
||||
for index := range lines {
|
||||
lines[index] = ansi.Truncate(lines[index], width, "")
|
||||
@@ -1916,8 +1958,8 @@ func (m App) helpBindings() []helpBinding {
|
||||
{keyLabel(m.keybindings.Input.Submit), "Review pull request metadata changes"},
|
||||
{keyLabel(m.keybindings.Input.Cancel), "Return to Normal mode or cancel the editor"},
|
||||
{combinedKeyLabel(m.keybindings.Navigation.PageDown, m.keybindings.Navigation.PageUp), "Move through the description by half a page"},
|
||||
{combinedKeyLabel(m.keybindings.Input.PreviousCompletion, m.keybindings.Input.NextCompletion), "Select the previous / next target-branch completion"},
|
||||
{combinedKeyLabel(m.keybindings.Input.NextField, m.keybindings.Input.Newline), "Complete the selected target branch"},
|
||||
{combinedKeyLabel(m.keybindings.Input.PreviousCompletion, m.keybindings.Input.NextCompletion), "Select the previous / next branch or user completion"},
|
||||
{combinedKeyLabel(m.keybindings.Input.NextField, m.keybindings.Input.Newline), "Complete the selected branch or user"},
|
||||
}
|
||||
if m.prEditEditors[prEditBodyField].Modal {
|
||||
bindings = append(bindings,
|
||||
@@ -2022,7 +2064,7 @@ func (m App) helpBindings() []helpBinding {
|
||||
{keyLabel(m.keybindings.Navigation.Up), "Scroll description up"},
|
||||
{combinedKeyLabel(m.keybindings.Navigation.First, m.keybindings.Navigation.Last), "Top / bottom"},
|
||||
{combinedKeyLabel(m.keybindings.Navigation.PageDown, m.keybindings.Navigation.PageUp), "Page down / up"},
|
||||
{keyLabel(m.keybindings.Views.Edit), "Edit title, target branch, and description"},
|
||||
{keyLabel(m.keybindings.Views.Edit), "Edit title, branch, reviewers, assignees, and description"},
|
||||
{keyLabel(m.keybindings.Views.AutoMerge), "Enable or disable auto-merge"},
|
||||
{keyLabel(m.keybindings.Views.MergeNow), "Merge the pull request now when all requirements are met"},
|
||||
{keyLabel(m.keybindings.Views.AI), "Open the local AI review menu"},
|
||||
|
||||
Reference in New Issue
Block a user