Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

keep an inline suggestion applyable when the finding body opens a code fence

[._.]/ Adam Eivy35f9027f49bc
diff --git a/server/lib/prReviewReport.js b/server/lib/prReviewReport.js
index 49c35bc3cd..198a72695d 100644
--- a/server/lib/prReviewReport.js
+++ b/server/lib/prReviewReport.js
@@ -187,12 +187,16 @@ export function renderFinding(raw, { blocking = true } = {}) {
const { title, body, suggestion } = normalizeFindingPresentation(raw);
if (!body) return null;
const marker = blocking ? '⛔ **Blocking**' : '💡 **Non-blocking**';
+ // An odd number of fences in the body leaves one open, which would swallow
+ // the suggestion block below and render it as inert text instead of an
+ // applyable change. Drop the suggestion rather than emit a dead one.
+ const bodyLeavesFenceOpen = ((body.match(/```/g) || []).length % 2) === 1;
return {
body: [
title ? `${marker} — ${title}` : marker,
'',
body,
- ...(suggestion ? ['', '```suggestion', suggestion, '```'] : []),
+ ...(suggestion && !bodyLeavesFenceOpen ? ['', '```suggestion', suggestion, '```'] : []),
].join('\n'),
label: title || line(body, MAX_INDEX_LABEL_CHARS),
};
diff --git a/server/lib/prReviewReport.test.js b/server/lib/prReviewReport.test.js
index 45d71b1978..7cee502268 100644
--- a/server/lib/prReviewReport.test.js
+++ b/server/lib/prReviewReport.test.js
@@ -120,6 +120,17 @@ describe('renderFinding', () => {
expect(renderFinding({ body: 'x', suggestion: '```\nrm -rf /\n```' }).body).not.toContain('```');
});
+ it('drops the suggestion when the body leaves a fence open, so it cannot render as inert text', () => {
+ const rendered = renderFinding({ body: 'Replace it:\n\n```js\nconst a = 1;', suggestion: 'const a = 2;' });
+ expect(rendered.body).not.toContain('```suggestion');
+ expect(rendered.body).toContain('const a = 1;');
+ });
+
+ it('keeps the suggestion when the body fences are balanced', () => {
+ const rendered = renderFinding({ body: 'Today:\n\n```js\nconst a = 1;\n```', suggestion: 'const a = 2;' });
+ expect(rendered.body).toContain('```suggestion\nconst a = 2;\n```');
+ });
+
it('rejects a finding with no usable body', () => {
expect(renderFinding({ title: 'no body' })).toBeNull();
});