--- name: gitea-review-comment-html-scrape description: "Read inline review comments on the Dankclaw Gitea when pulls/N/comments 404s (Gitea 1.27.3): scrape comment-content blocks and diff anchors from the PR HTML page" --- # Gitea review-comment extraction when the API 404s On the Dankclaw Gitea (192.168.0.143:3000, Gitea 1.27.3) the review-comment API is dead for inline comments: `/api/v1/repos/{owner}/{repo}/pulls/{N}/comments` returns 404 `not found` **even with a valid token**, and `pulls/comments?pull_id=` / `?pull_request_id=` variants 404 too. `/pulls/{N}/reviews` works but its bodies are empty for inline reviews (read `comments_count` for how many exist); `/issues/{N}/comments` shows only conversation comments, never inline ones. ## Procedure 1. Confirm the review exists and how many inline comments it holds: `curl -sS http://192.168.0.143:3000/api/v1/repos/dank/command-center/pulls/{N}/reviews | jq -c '.[] | {id, state, comments_count}'` 2. Scrape the PR page instead (no token needed for a public repo): `curl -sS http://192.168.0.143:3000/dank/command-center/pulls/{N} -o /tmp/pr.html` 3. Extract each comment's text — every inline comment renders a `comment-content` block; dedupe (each comment appears twice in the HTML): ```python import re, html src = open('/tmp/pr.html').read() seen = set() for m in re.finditer(r'comment-content', src): t = html.unescape(re.sub(r'<[^>]+>', ' ', src[m.start()-100:m.start()+800])) t = re.sub(r'\s+', ' ', t).strip()[:400] if t not in seen: seen.add(t); print('>>', t) ``` The comment text appears twice back-to-back inside each block ("text text") — read it once. Blocks start after `Copy Link|Copy Source`; ignore those chrome words. 4. **Locate the file/line anchor** (comment-content blocks carry no `data-path`/`data-line` attrs on this build): search the raw HTML for the comment string, walk *backward* ~4–7 KB, strip tags; the nearby `agent/...` path, `@@ -a,b +c,d @@` hunk header, and surrounding diff context lines identify the anchored file and the quoted source line. ## Replying / housekeeping - Per-conversation resolve API does not exist on this build (404s) — reply to the round as a normal issue comment (`POST /repos/{o}/{r}/issues/{N}/comments`, token via `curl -K` temp cfg, `header = "Authorization: token …"`, 600 perms, `jq -n --arg b "$(cat b.txt)" '{body:$b}'`) listing which note got which fix commit. - Edit a posted comment: `PATCH /repos/{o}/{r}/issues/{N}/comments/{id}` with `{"body": ...}` — use to fix your own typos rather than double-posting. - Token source on this box: `~/.config/secrets/gitea` (grep the remote-URL pattern); never echo it. ## Why this works The PR page is server-rendered with full inline comment bodies; Gitea's "Copy Source" UI element guarantees the raw text is present pre-markdown-render.