Commit 3884e64732f3

Vincent Demeester <vincent@sbr.pm>
2026-02-16 16:04:06
fix(github): use comments from initial issue fetch
Removed redundant second gh API call for comments. The initial --json response already includes the full comments array, not a totalCount object as assumed.
1 parent 442fe31
Changed files (1)
dots
pi
agent
extensions
github
actions
dots/pi/agent/extensions/github/actions/issue.ts
@@ -141,25 +141,12 @@ export async function handleIssueView(
 		output += `\n## Description\n\n${data.body}\n`;
 	}
 
-	// Get comments if any
-	const commentsCount = data.comments?.totalCount ?? data.comments ?? 0;
-	if (commentsCount > 0) {
-		output += `\n## Comments (${commentsCount})\n`;
-		// Fetch comments separately via gh issue view --comments
-		const commentsResult = await execGh(pi, ctx,
-			["issue", "view", String(params.number), "--comments", "--json", "comments"],
-			{ signal, timeout: 20000 },
-		);
-		if (commentsResult.code === 0) {
-			try {
-				const commentsData = JSON.parse(commentsResult.stdout);
-				const comments = commentsData.comments ?? [];
-				for (const comment of comments) {
-					output += `\n@${comment.author?.login ?? "?"} (${comment.createdAt ?? ""}):\n${comment.body}\n`;
-				}
-			} catch {
-				output += "\n(Could not parse comments)\n";
-			}
+	// Comments are already included in the initial JSON response as an array
+	const comments = Array.isArray(data.comments) ? data.comments : [];
+	if (comments.length > 0) {
+		output += `\n## Comments (${comments.length})\n`;
+		for (const comment of comments) {
+			output += `\n@${comment.author?.login ?? "?"} (${comment.createdAt ?? ""}):\n${comment.body}\n`;
 		}
 	}