fix(workflows/triage): thread issue comments as separate user messages in safety screen; render comment digests oldest→newest in preview and triage contexts

- Safety screen (issue-triage.yml): send issue body first, then each issue comment as its own user message (chronological) for stable stream ordering.
- Issue comment workflow: show recent comments oldest→newest so newest appears at the bottom in both preview and triage contexts.
- No app code changes; build verified with ./build-fast.sh.
This commit is contained in:
James Peter
2025-09-14 12:47:48 +10:00
parent ffd5097c0a
commit e63f5fc354
2 changed files with 35 additions and 16 deletions
+6 -4
View File
@@ -241,8 +241,9 @@ jobs:
lines.push('');
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
if (comments.length) {
lines.push('### Recent issue comments (newest first, up to 10)');
const last = comments.slice(-10).reverse();
lines.push('### Recent issue comments (oldest first, up to 10)');
// Keep chronological order so the newest appears at the bottom
const last = comments.slice(-10);
for (const c of last) {
const when = (c.created_at || '').replace('T',' ').replace('Z','');
lines.push(`- [@${c.user?.login||'unknown'} at ${when}]`);
@@ -503,8 +504,9 @@ jobs:
if (issue && issue.body) { lines.push('## Issue body'); lines.push(issue.body); lines.push(''); }
if (process.env.CONTEXT_TEXT && process.env.CONTEXT_TEXT.trim()) { lines.push('## Triage context'); lines.push(process.env.CONTEXT_TEXT.trim()); lines.push(''); }
if (comments.length) {
lines.push('## Recent comments (newest first, up to 10)');
const last = comments.slice(-10).reverse();
lines.push('## Recent comments (oldest first, up to 10)');
// Chronological order: newest at the bottom
const last = comments.slice(-10);
for (const c of last) {
const when = (c.created_at || '').replace('T',' ').replace('Z','');
lines.push(`- [@${c.user?.login||'unknown'} at ${when}]`);
+29 -12
View File
@@ -311,22 +311,39 @@ jobs:
}
async function callResponses(model) {
const input = [
{
const owner = context.repo.owner; const repo = context.repo.repo;
const issue_number = Number(process.env.ISSUE_NUMBER || 0);
// Fetch issue + comments for per-message threading
const issue = (await github.rest.issues.get({ owner, repo, issue_number })).data;
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
const input = [];
// Message 1: Issue body (as the first user message)
const title = `Issue #${issue.number}: ${issue.title || ''}`;
const body = issue.body || '';
input.push({
type: 'message',
role: 'user',
content: [
{ type: 'input_text', text: title },
{ type: 'input_text', text: body || '(no body provided)' }
]
});
// Messages 2..N: Each comment as its own user message, chronological order
const sorted = comments.slice().sort((a,b) => new Date(a.created_at) - new Date(b.created_at));
for (const c of sorted) {
const header = `Comment by @${c.user?.login || 'unknown'} on ${c.created_at}`;
const txt = String(c.body || '').trim();
input.push({
type: 'message',
role: 'user',
content: [
{ type: 'input_text', text: JSON.stringify({
repo: `${context.repo.owner}/${context.repo.repo}`,
issue_number: Number(process.env.ISSUE_NUMBER || 0),
title: process.env.ISSUE_TITLE || '',
body: process.env.ISSUE_BODY || '',
actor: context.actor
})
}
{ type: 'input_text', text: header },
{ type: 'input_text', text: txt || '(empty comment)' }
]
}
];
});
}
const payload = {
model,