From 63d0afb4e24a6026b6522ec94e13add3ac6a5192 Mon Sep 17 00:00:00 2001 From: agent-company Date: Fri, 27 Mar 2026 14:04:56 +0000 Subject: [PATCH] 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) --- internal/handlers/handlers.go | 9 +++++++++ internal/templates/pull_detail.html | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 78d6161..57546bf 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -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 diff --git a/internal/templates/pull_detail.html b/internal/templates/pull_detail.html index 1fea88a..773675e 100644 --- a/internal/templates/pull_detail.html +++ b/internal/templates/pull_detail.html @@ -46,4 +46,21 @@ + +{{if .Comments}} +

Comments

+
+{{range .Comments}} +
+
+ {{.User}} + {{.CreatedAt}} +
+
{{.Body}}
+
+{{end}} +
+{{else}} +

No comments yet.

+{{end}} {{end}}