Create GitHub issues with markdown and metadata (#3947)

* Create GitHub issues with markdown and metadata

- Add a reusable rich markdown composer for GitHub issue bodies and comments
- Let new GitHub issues include selected labels and assignees through IPC/RPC
- Preserve created issue metadata in the task list and cover the new API path with tests

* fix: address review findings
This commit is contained in:
Jinjing
2026-05-30 18:25:31 -07:00
committed by GitHub
parent bb6b872386
commit 9ca42f5582
16 changed files with 857 additions and 434 deletions
+21 -14
View File
@@ -5,6 +5,7 @@ surface is broad. */
import type {
ClassifiedError,
GitHubAssignableUser,
GitHubCreateIssueFields,
GitHubCommentResult,
GitHubIssueUpdate,
IssueInfo,
@@ -150,7 +151,8 @@ export async function createIssue(
title: string,
body: string,
preference?: IssueSourcePreference,
connectionId?: string | null
connectionId?: string | null,
fields?: GitHubCreateIssueFields
): Promise<{ ok: true; number: number; url: string } | { ok: false; error: string }> {
const trimmedTitle = title.trim()
if (!trimmedTitle) {
@@ -164,19 +166,24 @@ export async function createIssue(
}
await acquire()
try {
const { stdout } = await ghExecFileAsync(
[
'api',
'-X',
'POST',
`repos/${ownerRepo.owner}/${ownerRepo.repo}/issues`,
'--raw-field',
`title=${trimmedTitle}`,
'--raw-field',
`body=${body}`
],
ghOptions
)
const args = [
'api',
'-X',
'POST',
`repos/${ownerRepo.owner}/${ownerRepo.repo}/issues`,
'--raw-field',
`title=${trimmedTitle}`,
'--raw-field',
`body=${body}`
]
for (const label of fields?.labels ?? []) {
args.push('--raw-field', `labels[]=${label}`)
}
for (const assignee of fields?.assignees ?? []) {
args.push('--raw-field', `assignees[]=${assignee}`)
}
const { stdout } = await ghExecFileAsync(args, ghOptions)
const data = JSON.parse(stdout) as { number?: number; html_url?: string; url?: string }
if (typeof data.number !== 'number') {
return { ok: false, error: 'Unexpected response from GitHub' }