labctl pr view: include the PR discussion comment thread #191
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab#191
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
An agent has no way to READ a PR's discussion comments through labctl.
labctl pr view <n>renders number/title/state/head/url/body/reviews — but not the comment thread, even though the write path exists (labctl pr comment, POST/agent/v1/prs/{n}/comments). Meanwhilelabctl issue viewshows its full thread. A fix agent or lander that needs to catch up on PR conversation (verdict findings, human replies) is blind.The plumbing already exists below the API layer:
tracker.PullComments(ctx, n)(tracker.go:408) is implemented by all backends (forgejo, github, builtin, secretscan passthrough, instrumentation) and is already read internally by the autoland poller (afk/autoland.go:107) and reaper.Design (grilled 2026-07-21)
labctl pr view <n>— no new verb. Issue/PR symmetry:issue viewshows its thread, so doespr view./agent/v1/prs/{n}(prDetailResponse, agentapi/handlers.go:752) with acommentsarray. No separate GET endpoint. Same contract asreviews: always marshals as[], never null. Same no-partial-detail rule: if thePullCommentsread fails, the whole response fails throughwriteTrackerError(handlePRGet, handlers.go:818).PullCommentsreturns). Inline file/line-anchored review comments stay out of scope — no tracker-interface change.Implementation
internal/agentapi/handlers.go: inhandlePRGet, after theReviewsread, calltk.PullComments(r.Context(), n); map into acommentResponse(author, body, createdAt — mirror the issue-view comment JSON shape) appended toprDetailResponseascomments. Non-nil slice so zero comments marshals[].internal/labctl/client.go: addComments []IssueComment-style field toPRDetail(reuse/mirror the existing issue comment client type).internal/labctl/labctl.go: inprintPR(line 615), render comments after the reviews block, oldest first, byte-for-byte theprintIssueconvention:--- comment by <author> (<time>). Update the usage text line forpr viewtoshow PR n (…, body, reviews, comments).pr viewincludes the thread./agent/v1/prs/{n}assertingcommentspresent,[]on empty, ordering oldest-first, and whole-response failure whenPullCommentserrors; labctl render test for the comment block.Semantics notes
pr view's thread equalsissue view's thread there — consistent with the documented write-path semantics (handlers.go:1230), not a bug.pr liststays PullRef-cheap — no comment count added.