feat: add comments thread to PR detail view
Fetch and display PR comments in the pull request detail page, using the same Gitea issue comments API endpoint. Shows author, timestamp, and body for each comment, with a friendly empty state when no comments exist. Closes leeworks-agents/gitea-mobile#81 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -532,6 +532,13 @@ func (h *Handler) PullDetail(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch comments for this PR (Gitea uses the issues endpoint for PR comments).
|
||||
comments, err := h.Client.GetIssueComments(r.Context(), token, owner, repo, index)
|
||||
if err != nil {
|
||||
slog.Warn("failed to fetch PR comments", "error", err, "owner", owner, "repo", repo, "index", index)
|
||||
// Non-fatal: continue rendering without comments.
|
||||
}
|
||||
|
||||
// Build the content HTML using the template.
|
||||
tmpl, err := template.ParseFiles("internal/templates/pull_detail.html")
|
||||
if err != nil {
|
||||
@@ -543,11 +550,13 @@ func (h *Handler) PullDetail(w http.ResponseWriter, r *http.Request) {
|
||||
type templateData struct {
|
||||
Pull *giteaclient.PullRequest
|
||||
RenderedBody template.HTML
|
||||
Comments []giteaclient.Comment
|
||||
}
|
||||
|
||||
data := templateData{
|
||||
Pull: pr,
|
||||
RenderedBody: renderedBody,
|
||||
Comments: comments,
|
||||
}
|
||||
|
||||
var buf strings.Builder
|
||||
|
||||
Reference in New Issue
Block a user