fix: add gh issue comments command

This commit is contained in:
Codex
2026-07-04 12:10:30 +00:00
parent 79aeca5b3b
commit 1ed621a067
9 changed files with 152 additions and 14 deletions
+35
View File
@@ -47,6 +47,7 @@ function renderGhDefaultText(result: GitHubCommandResult): string {
if (result.ok === false) return renderGhError(result);
const command = result.command;
if (isIssueReadResult(result)) return renderIssueView(result);
if (command === "issue comments") return renderIssueComments(result);
if (isPrReadResult(result)) return renderPrView(result);
if (command === "pr list") return renderPrList(result);
if (command === "pr files" || command === "pr diff --stat") return renderPrFiles(result);
@@ -138,6 +139,7 @@ function renderIssueView(result: GitHubCommandResult): string {
` author=${ghText(issue.author)} bodySha=${ghText(issue.bodySha)} bodyPreview=${body.preview}`,
"",
"Next:",
` ${ghText(readCommands.comments ?? `bun scripts/cli.ts gh issue comments ${number} --repo ${result.repo}`)}`,
` ${ghText(readCommands.body ?? `bun scripts/cli.ts gh issue view ${number} --repo ${result.repo} --json body`)}`,
` ${ghText(readCommands.full ?? `bun scripts/cli.ts gh issue view ${number} --repo ${result.repo} --full`)}`,
"",
@@ -147,6 +149,39 @@ function renderIssueView(result: GitHubCommandResult): string {
return lines.join("\n");
}
function renderIssueComments(result: GitHubCommandResult): string {
const issue = record(result.issue);
const comments = arrayOfRecords(result.comments);
const commentRange = record(result.commentRange);
const readCommands = record(result.readCommands);
const rows = comments.slice(0, 40).map((comment) => [
ghText(comment.id),
ghText(comment.author),
shortDate(comment.createdAt),
ghShort(ghText(comment.url), 40),
ghShort(previewFrom(comment), 72),
]);
const lines = [
"gh issue comments (observed)",
"",
rows.length > 0
? ghTable(["COMMENT", "AUTHOR", "CREATED", "URL", "PREVIEW"], rows)
: "No comments found.",
"",
"Summary:",
` repo=${ghText(result.repo)} issue=#${ghText(issue.number ?? result.issueNumber)} total=${ghText(result.totalComments)} returned=${ghText(result.returned)} omitted=${ghText(result.omitted)}`,
` range=${ghText(commentRange.from)}..${ghText(commentRange.to)} title=${ghShort(ghText(issue.title), 96)}`,
"",
"Next:",
` ${ghText(readCommands.full ?? `bun scripts/cli.ts gh issue comments ${ghText(issue.number ?? result.issueNumber)} --repo ${result.repo} --full`)}`,
` ${ghText(readCommands.comment ?? `bun scripts/cli.ts gh issue comment view <commentId> --repo ${result.repo} --full`)}`,
"",
"Disclosure:",
" default comments output is a bounded recent-comment table with body preview; use --full/--raw for structured full bodies.",
];
return lines.join("\n");
}
function renderPrView(result: GitHubCommandResult): string {
const pr = record(result.pullRequest);
const number = ghText(pr.number);