Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type App struct {
HoverGen uint64
LastHoverLine int
LastHoverCol int
ReviewInbox *ui.ReviewInboxWidget
Problems *ui.ProblemsWidget
References *ui.ReferencesWidget
AllDiagnostics map[string][]ui.Diagnostic
Expand Down
58 changes: 58 additions & 0 deletions internal/app/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ func (a *App) ShowSidebarMoreMenu(sx, sy int) {
ui.MenuSep(),
{Label: "Help", Command: "changes.help"},
}
case "inbox":
items = []ui.ContextMenuItem{
{Label: "Refresh", Command: "review.refresh"},
ui.MenuSep(),
{Label: "Next Unresolved", Command: "review.nextUnresolved"},
{Label: "Previous Unresolved", Command: "review.prevUnresolved"},
}
}
if len(items) > 0 {
openContextMenu(a, items, sx, sy)
Expand Down Expand Up @@ -513,6 +520,57 @@ func registerWidgetCallbacks(app *App) {
app.Changes.OnCommit = app.CommitChanges
app.Changes.OnConfirmDiscard = app.ConfirmDiscard

// Review Inbox callbacks
app.ReviewInbox.OnOpenFile = func(path string, line int) {
absPath := app.resolveCommentPath(path)
app.EditorGroup.OpenFile(absPath)
if line > 0 {
app.EditorGroup.GoToLine(line)
}
app.FocusEditorIfEnabled()
}

app.ReviewInbox.OnMarkVerified = func(commentID int) {
app.setCommentState(commentID, github.StateVerified)
}

app.ReviewInbox.OnMarkDismissed = func(commentID int) {
app.setCommentState(commentID, github.StateDismissed)
}

app.ReviewInbox.OnReopen = func(commentID int) {
app.setCommentState(commentID, github.StateOpen)
}

app.ReviewInbox.OnAddReply = func(comment github.PRComment) {
if app.ReviewInbox.PRNumber == 0 {
return
}
app.ShowInputDialog(
fmt.Sprintf("Reply to @%s", comment.User),
"Enter your reply...",
"",
func(body string) {
if body == "" {
return
}
go func() {
err := github.AddPRComment(
app.ReviewInbox.PROwner,
app.ReviewInbox.PRRepo,
app.ReviewInbox.PRNumber,
body,
)
app.Screen.PostEvent(tcell.NewEventInterrupt(&reviewCommentPostResult{err: err}))
}()
},
)
}

app.ReviewInbox.OnRefresh = func() {
app.ReviewRefreshComments()
}

app.ContentSplit.OnResize = func(height int) {
if height <= 0 {
app.ContentSplit.ShowBottom = false
Expand Down
1 change: 1 addition & 0 deletions internal/app/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func RegisterCommands(app *App) {
registerGitCommands(app)
registerWorkspaceCommands(app)
registerPRCommands(app)
registerReviewCommands(app)
registerHelpCommands(app)
registerOptionsCommands(app)
registerSettingsCommands(app)
Expand Down
62 changes: 62 additions & 0 deletions internal/app/commands_review.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package app

import (
"github.com/eugenioenko/ttt/internal/command"
)

func registerReviewCommands(app *App) {
reg := app.Reg

reg.Register(command.Command{
ID: "sidebar.inbox",
Title: "Show Review Inbox",
Keywords: []string{"view", "review", "pr", "comments", "inbox"},
Handler: func() {
app.ShowPanel("inbox", app.ReviewInbox)
},
})

reg.Register(command.Command{
ID: "review.showInbox",
Title: "Review: Show Inbox",
Keywords: []string{"review", "pr", "comments"},
Handler: func() {
app.ShowPanel("inbox", app.ReviewInbox)
},
})

reg.Register(command.Command{
ID: "review.nextUnresolved",
Title: "Review: Next Unresolved Comment",
Keywords: []string{"review", "pr", "comment", "next"},
Handler: app.ReviewNextUnresolved,
})

reg.Register(command.Command{
ID: "review.prevUnresolved",
Title: "Review: Previous Unresolved Comment",
Keywords: []string{"review", "pr", "comment", "previous"},
Handler: app.ReviewPrevUnresolved,
})

reg.Register(command.Command{
ID: "review.markVerified",
Title: "Review: Mark Comment Verified",
Keywords: []string{"review", "pr", "comment", "verify", "resolve"},
Handler: app.ReviewMarkVerified,
})

reg.Register(command.Command{
ID: "review.addInlineComment",
Title: "Review: Add Inline Comment",
Keywords: []string{"review", "pr", "comment", "add"},
Handler: app.ReviewAddInlineComment,
})

reg.Register(command.Command{
ID: "review.refresh",
Title: "Review: Refresh Comments",
Keywords: []string{"review", "pr", "comment", "refresh"},
Handler: app.ReviewRefreshComments,
})
}
10 changes: 10 additions & 0 deletions internal/app/eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ func RunEventLoop(
if filePath != lastGutterFile {
lastGutterFile = filePath
app.RequestGitGutterForActiveFile()
app.updateCommentMarkers()
}

// Update review progress in status bar
app.Status.ReviewProgress = app.ReviewStatusText()

if filePath != lastBlameFile || line != lastBlameLine {
lastBlameFile = filePath
lastBlameLine = line
Expand Down Expand Up @@ -296,7 +300,13 @@ func RunEventLoop(
app.Root.SetFocus(app.Changes)
app.Sidebar.SetPanelDirty("changes", app.Changes.TotalChanges() > 0)
app.StatusNotify(fmt.Sprintf("Opened PR #%d: %s (%d files)", v.Info.Number, v.Info.Title, len(v.Info.Files)))
// Auto-load review comments when PR is opened
app.LoadReviewCommentsForPR(v.Info.Owner, v.Info.Repo, v.Info.Number)
}
case *ReviewCommentsFetchResult:
app.HandleReviewCommentsFetched(v)
case *reviewCommentPostResult:
app.HandleReviewCommentPosted(v)
}
redraw()
}
Expand Down
Loading
Loading